On Wednesday 09 Jun 2010 10:44:35 Gopal Karunakar wrote: > Hi, > > How can i declare a simple perl script file which will take arguments > from the user? an example will be take two numbers and give the sum as > output. > > Thanks in advance, >
See @ARGV: [code] #!/usr/bin/perl use strict; use warnings; my $n1 = shift(@ARGV); my $n2 = shift(@ARGV); print "$n1 + $n2 = ", ($n1+$n2), "\n"; [/code] [console] shlomi:~$ perl cmd-line-1.pl 5 6 5 + 6 = 11 shlomi:~$ [/console] Also see Getopt::Long. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Interview with Ben Collins-Sussman - http://shlom.in/sussman God considered inflicting XSLT as the tenth plague of Egypt, but then decided against it because he thought it would be too evil. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/