Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Enlil's scratchpad

by Enlil (Parson)
on Jun 01, 2004 at 22:33 UTC ( #358729=scratchpad: print w/ replies, xml ) Need Help??

Unholy Power.
use warnings; use Data::Dumper; my @things_to_sort = ( { author => 'bart', title => 'skateboarding' }, { author => 'lisa', title => 'postmodernism' }, { author => 'marge', title => 'hairstyles' }, { author => 'lisa', title => 'THIS BOOK FIRST' }, { author => 'homer', title => 'donuts' }, { author => 'bart', title => 'coolness' } ); my $author = ''; my @sort = map { $_->[0] } sort { $b->[1] <=> $a->[1] || $a->[0]->{author} cmp $b->[0]->{author} || $a->[0]->{title} cmp $b->[0]->{title} } map { [ $_->[0], $_->[0]->{author} eq $author ? $_->[1] + 2 : $_->[1] ] } map { [ $_, $_->{title} eq 'THIS BOOK FIRST' ? ($author = $_->{author}) && 4 : 0 ] } @things_to_sort; print Dumper \@sort


Why does this issue a warning every time after the first time that TestSub() is run?
#!/usr/bin/perl use strict; use warnings; print TestSub(); print TestSub(); ###################################### sub TestSub { ###################################### open THIS,'>', \my $variable || die $!; print THIS "fooo\n" || die $!; close(THIS) || die $!; return $variable; } #TestSub __END__ fooo Use of uninitialized value in open at ./foo.pl line 18. fooo
Why does this issue a warning after for every time it loops through but the first time:
#!/usr/bin/perl use strict; use warnings; for (1 .. 4 ){ open THIS,'>',\my $variable || die $!; print THIS "$_\n" || die $!; close(THIS) || die $!; print $variable || die $!; }; __END__ 1 Use of uninitialized value in open at ./foo.pl line 6. 2 Use of uninitialized value in open at ./foo.pl line 6. 3 Use of uninitialized value in open at ./foo.pl line 6. 4
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-12-20 04:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls