<?xml version="1.0" encoding="windows-1252"?>
<node id="358729" title="Enlil's scratchpad" created="2004-06-01 18:33:04" updated="2005-08-12 20:03:54">
<type id="182711">
scratchpad</type>
<author id="169829">
Enlil</author>
<data>
<field name="doctext">
Unholy Power.&lt;br /&gt;
&lt;code&gt;
use warnings;
use Data::Dumper;

my @things_to_sort = (
                   { author =&gt; 'bart', title =&gt; 'skateboarding' },
                   { author =&gt; 'lisa', title =&gt; 'postmodernism' },
                   { author =&gt; 'marge', title =&gt; 'hairstyles' },
                   { author =&gt; 'lisa', title =&gt; 'THIS BOOK FIRST' },
                   { author =&gt; 'homer', title =&gt; 'donuts' },
                   { author =&gt; 'bart', title =&gt; 'coolness' }
                  );

my $author = '';
my @sort = 
  map { $_-&gt;[0] }
  sort { 
    $b-&gt;[1] &lt;=&gt; $a-&gt;[1] 
          ||
    $a-&gt;[0]-&gt;{author} cmp $b-&gt;[0]-&gt;{author}
          ||
    $a-&gt;[0]-&gt;{title} cmp $b-&gt;[0]-&gt;{title}
  } map { 
        [ 
          $_-&gt;[0], 
          $_-&gt;[0]-&gt;{author} eq $author ? $_-&gt;[1] + 2 
                                       : $_-&gt;[1] 
        ] 
      } map { 
            [
              $_, 
              $_-&gt;{title} eq 'THIS BOOK FIRST' 
                          ? ($author = $_-&gt;{author}) &amp;&amp; 4 
                          : 0 
            ] 
            } @things_to_sort;

print Dumper \@sort
&lt;/code&gt;

&lt;p&gt;
&lt;hr&gt;
Why does this issue a warning every time after the first time that TestSub() is run?

&lt;code&gt;
#!/usr/bin/perl
use strict;
use warnings;
print TestSub();
print TestSub();
######################################
sub TestSub {
######################################
  open THIS,'&gt;', \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
&lt;/code&gt;

Why does this issue a warning after for every time it loops through but the first time:
&lt;code&gt;
#!/usr/bin/perl
use strict;
use warnings;

for  (1 .. 4 ){
  open THIS,'&gt;',\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
&lt;/code&gt;</field>
</data>
</node>
