Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Re (2): Array for system() call

by blakem (Monsignor)
on Oct 23, 2001 at 22:45 UTC ( #120861=note: print w/ replies, xml ) Need Help??

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 ./ 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)


Comment on Re: Re (2): Array for system() call
Select or Download Code
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


    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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://120861]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2015-12-01 11:29 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (3 votes), past polls