In the message dated: Fri, 20 Dec 2013 11:45:14 -0500,
The pithy ruminations from Brandon Allbery on 
<Re: [lopsa-tech] A PERL question> were:
=> On Fri, Dec 20, 2013 at 11:35 AM, john boris <jbori...@gmail.com> wrote:
=> 
=> > The perl script is called like this from another shell script that does
=> > some worlk
=> >
=> > perl weekdays.pl $school
=> >
=> 
=> Change this to
=> 
=>     perl weekdays.pl "$school"
=> 

[PEDANTIC HAT ON]

I'd suggest:

        weekdays.pl -s "$school"

and ideally also accept:

        weekdays.pl --school "$school"
        weekdays.pl --school="$school"

Except for an input filename as the final command-line argument, I'm
strongly opposed to any 'bare' argument (not preceeded by a flag). Using
flags can also make the command-line parsing easier, through the use of
'getopts', or by something like:

        #### horrible, untested, pseudo-code follows ###
        if ( $ARGV[$i] eq "-s" || $ARGV[$i] =~ /^--school$/ )
        {
                $i++;
                while ( ! $ARGV[$i] =~ /^-/ )
                {
                        $school=$school . " " . $ARGV[$i];
                        $i++;
                }
        }
        else
        {
                if ( $ARGV[$i] =~ /^--school=/ )
                {
                        ($school,$ARGV[$i])=~s/^.*=//;
                }
        }


I've seen way too much legacy code that has things like:

        program.pl  xsize  ysize parm1 parm2 zsize input output

The lack of flags (option names) makes usage and maintenance difficult
-- particularly months & years later when the specific meaning given to
the _position_ of each argument has been forgotten.

[PEDANTIC HAT OFF]

Mark

=> -- 
=> brandon s allbery kf8nh                               sine nomine associates
=> allber...@gmail.com                                  ballb...@sinenomine.net
=> unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
=> 
=> _______________________________________________
=> Tech mailing list
=> Tech@lists.lopsa.org
=> https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech
=> This list provided by the League of Professional System Administrators
=>  http://lopsa.org/
=> 

-- 
Mark Bergman    Biker, Rock Climber, Unix mechanic, IATSE #1 Stagehand
'94 Yamaha GTS1000A^2
berg...@panix.com

http://wwwkeys.pgp.net:11371/pks/lookup?op=get&search=bergman%40panix.com

I want a newsgroup with a infinite S/N ratio! Now taking CFV on:
rec.motorcycles.stagehands.pet-bird-owners.pinballers.unix-supporters
15+ So Far--Want to join? Check out: http://www.panix.com/~bergman 
_______________________________________________
Tech mailing list
Tech@lists.lopsa.org
https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech
This list provided by the League of Professional System Administrators
 http://lopsa.org/

Reply via email to