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
|