perl - Running script and defining object value in terminal window -


when run perl scripts, open terminal window on mac , write "perl test1.pl" after moving folder containing perl script.

often find myself wanting run same perl many times, @ same time, minor changes.

for example perl script "test1.pl" looks this:

$year = 2001; <rest of code uses $year> 

i want execute "test1.pl" $year = 2001, $year = 2002, etc. run script $year = 2001, adjust script $year = 2002, save, open new terminal window, run again, repeat.

is there way submit perl script designate in terminal window value $year?

i'm thinking like: "perl test1.pl, $year = 2001"

thanks!

one way (of many ways) is:

my $year = (@argv) ? shift : 2001; 

then run as:

perl test1.pl 2002 

2001 defualt if don't specify year on command line. see also: perldoc -v @argv


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -