Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2015-07-04 04:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls