SPUG: running script with the variables on the same line

Jay Scherrer jay at scherrer.com
Sun May 29 19:31:04 PDT 2005


I was thinking of $argv, but is that only used for files?

Jay Scherrer

On Sun, 2005-05-29 at 18:03 -0700, Tim Maher wrote:
> On Sun, May 29, 2005 at 06:51:34PM -0600, Medrano-Zaldivar, L E wrote:
> > List,
> > 
> > I have a quetion how can I set a script to grap the variables values
> > on the same line where I'm running the script. For example:
> > 
> > perl script.pl variable1 variable2
> > 
> > What I mean with this is the script can grap this values. I hope I examplain.
> >
> > Luis
> 
> What you're looking for is the "switch" option, -s, and this syntax:
> perl -s script.pl -variable1=value1 -variable2=value2
> 
> This invocation will set $variable1 in the program to value1, etc.
> 
> If you've got odd stuff in the values, then you'll probably
> need to add quotes like so:
> 
> perl -s script.pl -variable1="value1" -variable2="value2"
> 
> WARNING: I've never tried this on Windoze, so there might be complications
> I don't foresee there.
> 
> "perldoc perlrun" provides the documentation for this feature.
> 
> -Tim
> *--------------------------------------------------------------------------*
> | Tim Maher, PhD     (206) 781-UNIX      (866) DOC-PERL     (866) DOC-UNIX |
> | tim(AT)Consultix-Inc.Com  http://TeachMePerl.Com  http://TeachMeUnix.Com |
> *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*
> |   Watch for my Summer, 2005 book: "Minimal Perl for UNIX/Linux People"   |
> *--------------------------------------------------------------------------*
> _____________________________________________________________
> Seattle Perl Users Group Mailing List  
>      POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
>     MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med
>     WEB PAGE: http://seattleperl.org/



More information about the spug-list mailing list