On Sep 10, 1:18 pm, [EMAIL PROTECTED] (Mathew Snyder) wrote:
> Thanks. But I'm confused by
>
> > my %start; @start{qw<month day year>} = split /\//, shift;
> > my %end; @end{qw<month day year>} = split /\//, shift;
>
> What's happening here?
Quite a bit, actually. Let's go right to left. First, shift()
without an argument removes and returns the first element of @ARGV
(the command line arguments).
Second, the split is taking that argument, for example '07/20/2007'
and returning a list of the three elements ('07', '20', '2007);
Third, it's using hash slices.
@foo{'a', 'b', 'c'} = (1, 2, 3);
is the same as:
$foo{a} = 1;
$foo{b} = 2;
$foo{c} = 3;
The above is also using the qw// operator, using < and > as the
delimiters. This creates a list of single quoted strings. So if the
first element of @ARGV was 07/20/2007, this code makes these three
assignmetns:
$start{month} = '07';
$start{day} = '20';
$start{year} = '2007';
(and the same for %end and the second element of @ARGV)
Paul Lalli
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/