Perl Program

Availability

Perl program information on this site is © Copyright skrb.org. Permission is hereby granted to use this code in any way provided that the above copyright is included in all copies. That having been said, if you find a problem in any of this software I would love to hear from you.

GetArgs

This is a library routine for parsing command arguments and switches (yes, I know there are several of these, but when I originally wrote this none supported all the features I wanted).

The call takes a simple description of the supported options, positional arguments, variables to set with the supplied values, and help text to be provided to the user as part of the usage message. Support is automatic for -usage, --usage, -help, --help, and -?; and for the end of switch arguments marker '--'.

  • Full Detailed Description
  • This package provides the routine 'getargs' for parsing command line arguments. It automates most of a standard command line interface by taking a picture of the expected arguments of the form:
    ( <4tuple> [, <4tuple> ]... ) <4tuple> ::= , , , ::= '-' for switch arguments (these are order independent
  • Full The Perl
  • package getargs; sub main'getargs #'
    {local(@Picture) = @_;
    # Now parse the argument picture
    local( $Type, $Keyword, $Key, $Size, $Variable, $Tuple );
    local( %Sizes, %Switches );
    local( $Options, $Mandatories, @Positional, $Target, %Targets );
    for ( $Tuple = 0; $Tuple < $#Picture; $Tuple += 4 )

Web Request Tester

wwwreq is a utility for constructing a simple request for a web server, sending it, and displaying the full response. It is intended as a tool for doing some simple discovery of what is supported by a web server.

  • Full Detailed Description
  • Provides -usage, --usage, -help, --help, and -?
    (if the 'usage' or 'help' switches are specified in the picture,the caller will get it like any other switch).
    Provides '--' for the end of switch arguments.
    Switch and Optional arguments not specified in @ARGV are not defined by getargs - you can either test for that or just assign them default values before calling getargs.
  • Full The Perl Description
  • Used only with the 'TRACE' method, it limits the number of proxies which may forward the request. No limit is sent if this option is not specified.
    --useragent
    Specify a User Agent string to send (defaults to '$DefaultUserAgent') Specify a null string argument to disable sending a User Agent string. Not valid with 0.9.

    Symbolic Link manipulations

    Shadow

    The shadow creates a directory tree that is a shadow of another tree; the directories are real, but the files in them are symbolic links to the originals. It is probably not useful except on unix-style platforms.

    This kind of directory is very useful in a variety of software development contexts.

    • Detailed Description
    • $ShadowDir = '.';
      $Verbose = 0;
      $SkipDefault = '^(RCS|SCCS|CVS)$';
      $Skip = $ENV{ 'SHADOWSKIP' } || $SkipDefault;
      $TreeOnly = 0;
      $Usage = <<_help_message_ makes a copy if specified>
    • The Perl
    • This script uses the getargs argument parser

    Mkreal (make real)

    Complements the 'shadow' script; it converts a symbolic link into a copy of the file to which the link pointed.

    Relink

    Creates or modifies symbolic links; can be used in place of 'ln -s'.

    • The Perl
    • #!/usr/bin/perl foreach ( @ARGV )
      { if ( -l ) { if ( -f ){
      $Real = readlink; unlink; `cp $Real $_`; unless ( $? ) {
      $Mode = (stat( $_ ))[2]; chmod( ($Mode | 0200) , $_ ); } else {
      warn "??? $?\n"; } } else { warn "'$_' does not represent a file:\n\t$Real\n";
      } } else { warn "'$_' is not a link.\n"; } }
    This script uses the getargs argument parser