in reply to Lost Column

This is line is causing it: substr($FirstLine, -1, 1) = $DataLine. As someone already mentioned, you should really just use the regex on the returned value from substr() (Perl is magic like that). Or, you could do $FirstLine .= $DataLine to append one string to the end of another.

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^2: Lost Column
by wrml (Novice) on Aug 18, 2005 at 21:33 UTC
    thanks for your help. I see why this is a better code, but now when I do what Zaxo has suggezted, I get a failure saying:
    substr outside of string at /mnt/ide0/home/wrml/ReturnA/ReturnAReplace +r.pl line 88, <IN> line 8453
    This did not happen before. how can this be happening now? What does it mean that the substring is outside of the string?
      Sounds like the offset is beyond the end of the string being substringed. For example:
      my $woopsie = substr("Short line.",100);
      causes the same error message. Could you show us your revised code?
        Yeah, here it is.
        foreach $file (@infile){ open(IN, '<', "$file") or warn $! and next; open(OUT, '>', $outpath.basename($file)) or warn $! and next; while (<IN>) { substr($_,279) =~ s/$regex/$substitute{$1}/g; print OUT $_; } }
        These lines are huge. Much larger than 279 characters. by about 7000 characters. I can't figure this one out.
        Not a problem. here is the code:
        foreach $file (@infile){ open(IN, '<', "$file") or warn $! and next; open(OUT, '>', $outpath.basename($file)) or warn $! and next; while (<IN>) { substr($_,279) =~ s/$regex/$substitute{$1}/g; print OUT $_; } }
        These lines are very long. much longer than 279... I'm really confused.