It works great for the first ~4142 lines, then breaks.

What does "breaks" mean exactly? Are you referring to the emission of the warning you mentioned?

error: Use of uninitialized value in concatenation

That's a non-fatal error (warning).

You didn't indicate which line is line 54, but it's gotta be because $h[3] or $h[4] don't contain what you expect them to be. Some line of your input doesn't have any many slashes as you expect.

Because you read the entire file at once (why?!), the line number in the error message (60608) is wrong. Fix your code as follows and you'll get the line number of your input that's incorrect. And you'll use must less memory too!

open(my $in_fh, '<', $load_file) or die("Can't open input file \"$load_file\": $!\n"); while (my $in_qfn = <$in_fh>) { chomp($in_qfn); my ($rel_path) = $in_qfn =~ m{/([^/]+/[^/]+)\z} or do { warn("Line $. is malformatted. Skipping\n"); next; }; my $image = Image::Resize->new($_); my $gd = $image->resize(160, 120); my $out_qfn = "/imagedb/thumb/$rel_path"; open(my $out_fh, ">", $out_qfn) or do { warn("Can't create file \"$out_qfn\": $!. Skipping\n"); next; }; binmode($out_fh); if (!( print($out_fh $gd->jpeg()) and close($out_fh) )) { warn("Error writing file \"$out_qfn\": $!. Skipping\n"); close($out_fh); unlink($out_qfn); next; } }

I added some much-needed I/O error checking.

Update: Fixed extraneous semicolon.


In reply to Re: Reading 60k lines in file by ikegami
in thread Reading 60k lines in file by b_gsmls

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.