in reply to weird perl verion and/or OS problem with newlines
And you tried this same snippet with the exact same data on a Gentoo box and got a seg fault? It's known that 5.8.0 has some minor "issues" with a handful of particular/arcane regex conditions, because its expanded support for unicode has "broken new ground" (so to speak); even though you have no hint of utf8-like data here, maybe trying a different (and more efficient) approach would get you past the roadblock.
As for newline behavior, if your snippet actually works as intended on BSD, there should be no difference on Gentoo that involves just line-termination patterns (unless the data on the Gentoo box differs from the BSD data in this regard -- in which case, try fixing the data first because that would be easy).
Anyway, something like this might be worth a try (assuming the text really has unix-style line termination) -- I haven't tested it:
(update: fixed the ">=" operator in the while condition){ # create a scoping block for slurp-mode reading local $/ = undef; my $str = <>; my $bgnstr = "#:lav\n"; my $bgnlen = length( $bgn ); my $endstr = "#:eof\n"; while ( my $startpos = index( $str, $bgnstr ) >= 0 ) { $startpos += $bgnlen; my $stoppos = index( $str, $endstr, $startpos ); $stoppos = length( $str ) if ( $stoppos < 0 ); my $val = substr( $str, $startpos, $stoppos - $startpos ); print $val; $str = substr( $str, $stoppos ); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: weird perl verion and/or OS problem with newlines
by vinforget (Beadle) on Sep 25, 2003 at 15:20 UTC | |
by tye (Sage) on Sep 25, 2003 at 16:02 UTC |