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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |