Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jonasbn (1153)

jonasbn
  reversethis-{gro.napc} {ta} {nbsanoj}
http://e-diot.dk/
AOL IM: BJonasN (Add Buddy, Send Message)

Perl Programmer located in Copenhagen, Denmark. Active member of Copenhagen Perl Mongers.

Author of:

  • Business::DK::CPR
  • Business::DK::CVR
  • Business::DK::PO
  • Business::OnlinePayment::CashCow
  • Date::Holidays
  • Date::Holidays::Abstract
  • Date::Holidays::Super
  • Date::Pregnancy
  • Games::Bingo
  • Games::Bingo::Bot
  • Games::Bingo::Print
  • Module::Info::File
  • Module::Template::Setup
  • Test::Timer

and maintainer of:

  • Tie::Tools
  • XML::Conf
  • Workflow

Journal of jonasbn (1153)

Friday August 13, 2004
02:23 PM

Note to self on Tie::File

[ #20399 ]

Do NOT use it on large files when doing multiple replacements of file contents, do copying of content instead.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • > Do NOT use it on large files when doing multiple replacements of file contents, do copying of content instead.

    Given Tie::File's original purpose I'd say that what you describe above sounds almost like a bug. I say 'almost' since you didn't really explain what was the problem...

    • Ok, this is the script:

      #!/usr/bin/perl -w
       
      use strict;
      use Tie::File;
       
      my @array;
      tie @array, 'Tie::File', $ARGV[0] or die "Unable to tie file: $ARGV[0] - $!";
      foreach(@array) {
              print STDERR "Processing: $_\n";
              if (m/^<Seg L=/) {
                      s/"?,\s*$//;
                      s/>"/>/;
                      print STDERR "Processe

      • Firstly, you could redo this

               if (m/^<Seg L=/) {
                        s/"?,\s*$//;
                        s/>"/>/;
                        print STDERR "Processed: $_\n";
               }

        as

               s/^(<Seg L=.+>)"(.+)",\s*$/$1$2/ && print ...

        to replace one m and two s's with one s.

        Secondly, doing at least one STDERR print for eve

        • Thanks for the advice,

          I think I will attemp to time the various versions.

          I will profile the script aswell,

          Again thanks :)