Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-07-12 17:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (240 votes), past polls