OK, I know that this is probably an error on my part, but....
I am working on getting PDF's of our newspaper online. There will be a JPG thumbnail, etc... When trying to get the sections for the day, Push is not doing what I expect.
I am expecting that the "tmp" array will have 1 element per page when this is done. (e.g. GGGHHHHHHJJJ...) Then I can send this out and have the duplicates removed, and I have a listing of my sections.
The problem is that the sections are not getting pushed into the array. When the print statement is uncommented, I see all of the sections printed out, but I can never get them to push onto the stack.
I have tried several different ways of writing this, even putting the substr command into the push. push @tmp, substr($fn, 5, 1); I have also tried making another sub and sending the variables, but the values come over improperly. This makes me pretty sure it's my code, but I really cannot tell where.
Any help would be appreciated.
~Hammy
Here is my input:
R3012G006.PDF R3012G007.PDF R3012G008.PDF R3012H001.PDF R3012H002.PDF R3012H003.PDF R3012H004.PDF R3012H005.PDF R3012H006.PDF R3012J001.PDF R3012J002.PDF R3012J003.PDF R3012J004.PDF R3012J005.PDF R3012J006.PDF R3012J007.PDF R3012J008.PDF R3012J009.PDF R3012J010.PDF R3012J011.PDF R3012J012.PDF R3012J013.PDF R3012J014.PDF R3012J015.PDF R3012J016.PDF R3012J017.PDF R3012J018.PDF R3012J019.PDF R3012J020.PDF R3012J021.PDF R3012J022.PDF R3012J023.PDF R3012J024.PDF R3012J025.PDF R3012J026.PDF R3012J027.PDF R3012J028.PDF R3012J029.PDF R3012J030.PDF R3012J031.PDF R3012J032.PDF
Here is the code.
sub make_sections { my @tmp; for (@_) { my $fn = $_; print "$fn\n"; my $pnum = substr($fn, 6, 3); $pnum =~ s/0//; my $section = substr($fn, 5, 1); #@tmp = add2arr(@tmp, $section); push @tmp, $section; $MAIN::PageInfo{$section}{$pnum} = $_; s/$MAIN::fileExt/$MAIN::imgExt/; $MAIN::PageInfo{$section}{$fn} = $_; #print "Name: $PageInfo{$section}{$pnum} Section: $section P +Num: $pnum Thumb: $PageInfo{$section}{$fn} \n"; } print "Exiting Make Sections.\n"; return @tmp; } sub add2arr { my (@array, $value) = shift; #print "Section: $value"; push @array, $value; return @array; }
In reply to Push can shove it. by HamNRye
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |