Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

stu42j (6348)

stu42j
  (email not shown publicly)
http://saj.thecommune.net/
Jabber: saj@thecommune.net

Journal of stu42j (6348)

Monday August 27, 2007
01:49 PM

TIMTOWTDI-NAOTAG

[ #34236 ]

There Is More Than One Way To Do It - Not All Of Them Are Good.

Some legacy code that I am working on, frequently uses this "interesting" idiom for getting the first element of an array.

my @array = some_function();
 
my $i = 0;
foreach my $hash (@array) {
  $i++;
  $var = $hash->{somekey};
  last;
}

I am particularly puzzled by the unused $i.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.