[EMAIL PROTECTED] wrote: > Sorry to bother everyone, but i was working on this yesterday and i > couldn't get it to work. I guess i have the wrong syntax for passing > variables in from the command line. > > Here's my script: > > ===== crypt.pl ===== > #!/usr/bin/perl > my $pwd = $1; > my $seed = $2; > my $key = substr(crypt("$pwd","$seed"),2); > print $key; > ================= > > For example, I want to type: > > crypt.pl string1 string2 > > and it should spit out the value of $key. > > Right now both variables are returning null. Any suggestions?
You must be a shell programmer :~) The command-line arguments in Perl are in the global @ARGV array. You can access them directly, as in: my $pwd = $ARGV[0]; # first argument my $seed = $ARGV[1]; # second argument Or, you can shift them off the array: my $pwd = shift @ARGV; my $seed = shift @ARGV; Since @ARGV is the default target for the shift() function when used outside a function, you can use the idiom: my $pwd = shift; my $seed = shift; Finally, you can assign them as a list: my ($pwd, $seed) = @ARGV; HTH -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>