View Single Post
Old 09-22-2004, 05:49 PM  
lb_vee
Confirmed User
 
Join Date: May 2004
Posts: 886
Quote:
Originally posted by archael
alright im gonna give this a try.

But I also meant to ask, i see the $_ and @_ everywhere but have no idea what that means.

Can you explain it?

Thanks,
Jon
I'll start with @_.

When you define a subroutine, perl by default takes arguments as an array in the @_ array;

example:
Code:
sub bob()
{
 my $firstArg = @_[0];
 my $secondArg=@_[1];
}
The $_ is the current value in a loop pretty much.

Instead of :
Code:
foreach my $thisItem (@array)
{
  print $thisItem;
}
you can do :

Code:
foreach (@array)
{
  print $_; ### same as this item
}
lb_vee is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote