Rob Dixon wrote: > Adriano Allora wrote: >> >> $tex =~ s/^([^|]+).*/$1/o; > > Your regex is correct, but it doesn't do what you said you wanted! You're > substituting the entire string in $tex for just those characters up to > the first > pipe, but there's nothing in $tex - the data has been read into $_. > > If you want to do what you've written, then s/|.*// is a lot easier: it > just removes everything starting at the first pipe.
The | is for alternation so if you want to match a literal | character you have to escape it: s/\|.*//s > If you want to do what you said, and put everything up to the pipe into a > variable (scalar $tex?) then > > /([^|]+)/; > $tex = $1; You should only use the numeric variables if the match was successful otherwise their contents may not be what you expected. if ( /([^|]+)/ ) { $tex = $1; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>