in reply to Regular Expressions Matching with Perl

I would think substr would be a good choice too since you seem to be dealing with fixed length fields/records.
  • Comment on Re: Regular Expressions Matching with Perl

Replies are listed 'Best First'.
Re^2: Regular Expressions Matching with Perl
by ikegami (Patriarch) on Apr 20, 2005 at 17:44 UTC
    Unfortunately, I think substr will fail when the raw size of the file is 10MB of more, when the compressed size of the file is 10MB or more, or when the compression ratio is 100%. (I've seen it round to 100% once.)
      You wouldn't need to run substr on the whole file at one time, you would run it against each line of the file separately like this:
      use strict; use warnings; use Data::Dumper; my @Temp; use constant FileNameStart => 58; while(<DATA>) { chomp(); push(@Temp, substr($_,FileNameStart)); } print(Dumper(@Temp)); __DATA__ 0 Stored 0 0% 04-20-05 08:43 00000000 test 1 2 3.z +ip 704106 DeflatN 83362 89% 04-04-05 19:00 8e76dc22 file1.dat

        I was talking about the size of the file in the archive, not the size of the output.

        For example, add:
        10000000  DeflatN  83362  89%  04-04-05  19:00  8e76dc22   file2.dat
        or
         704106  DeflatN  4      100%  04-04-05  19:00  8e76dc22   file3.dat
        to your __DATA__ and you'll notice an extra space in front of the file name. Now, I'm not sure how his unzip program handles these cases, so substr may actually work.