in reply to Re (2): Array for system() call
in thread Array for system() call

Here is an example of why using @arr[0] is just asking from trouble...
#!/usr/bin/perl -wT use strict; my @arr; @arr[0] = localtime(); $arr[1] = localtime(); print "\$arr[0] = $arr[0]\n"; print "\$arr[1] = $arr[1]\n";
Any guesses about the output of this simple script? Select area below to find out.

=OUTPUT Scalar value @arr[0] better written as $arr[0] at ./arrayslice.pl line + 6. $arr[0] = 58 $arr[1] = Tue Oct 23 14:30:58 2001
5 points for anyone who expected $arr[0] to contain an integer. 20 points for anyone who knew it would contain the seconds value, *not* the number of elements in the list returned by localtime().

(10 points for anyone who coded up an example because they weren't sure... woohoo)

-Blake

Replies are listed 'Best First'.
Re: (4): Array for system() call
by dmmiller2k (Chaplain) on Oct 23, 2001 at 23:46 UTC

    Thanks for the example, blakem

    dmm

    You can give a man a fish and feed him for a day ...
    Or, you can teach him to fish and feed him for a lifetime