
FishMonger
Veteran
/ Moderator
Dec 3, 2012, 7:07 AM
Post #2 of 4
(3475 views)
|
Re: [omega] hash copy only getting 1922 of 1932, no duplicates in read file
[In reply to]
|
Can't Post
|
|
if ($month =~ /\d\d/) { # keep double digit months $just = "$year" . '_' . "$month" . '_' . "$day"; $new_numbers{$just} = "$numbers{$bookmark}"; } else { # change single digit months to include a '0' ($new_month = $month) =~ s/(\d)/0\1/; $work = "$year" . '_' . "$new_month" . '_' . "$day"; $new_numbers{$work} = "$numbers{$bookmark}"; } Ouch, that really hurts my eyes. You need to learn to use sprintf and printf.
$date = sprintf("%d_%02d_%02d", $year, $month, $day); $new_numbers{$date} = $numbers{$bookmark}; Similar improvements could be made in other sections of your code. Also, you should always include these 2 lines (pragmas) in every script.
use strict; use warnings; Doing so will require you to declare your vars, which is done with the 'my' keyword. example: code]@trial1 = split /\s+/, "$_"; should be:
my @trial1 = split /\s+/, $_;
|