Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Arguments in Perl


  • Please log in to reply
3 replies to this topic

#1 smith

smith

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 149 posts

Posted 02 November 2006 - 06:39 AM

How do I accept and manipulate arguments in PERL?

./perlscript.pl $arg1 $arg2


???
  • 0

for (int i;;) {

   cout << "Smith";

}


#2 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 02 November 2006 - 09:47 AM

Here ya go:-
http://www.devdaily....plqa00001.shtml
is this what you wanted?
  • 0

#3 Guest_The Fear_*

Guest_The Fear_*
  • Guest

Posted 06 June 2007 - 09:36 AM

Hi.
$argv1,$argv2,...
all in @ARGV.
example:
./perl sample.pl $argv1 $argv2
@ARGV = $argv1,$argv2
$ARGV[0] = $argv1
$ARGV[1] = $argv2

#Good luck
  • 0

#4 KevinADC

KevinADC

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 125 posts

Posted 08 June 2007 - 06:39 PM

Hi.
$argv1,$argv2,...
all in @ARGV.
example:
./perl sample.pl $argv1 $argv2
@ARGV = $argv1,$argv2
$ARGV[0] = $argv1
$ARGV[1] = $argv2

#Good luck


The above code is not quite correct. Perl sends the arguments to the program in the @ARGV array. You get them back out of the @ARGV array like so:


my ($arg1,$arg2) = @ARGV;

or:

my $arg1 = $ARGV[0];
my $arg2 = $ARGV[1];

  • 0




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download