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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.