Re: Find string ending with %



[ message rearranged in chronological order. Please do not top-post ]


Timothy Johnson wrote:
>> From: Keenan, Greg John (Greg)** CTR ** [mailto:gjkeenan@xxxxxxxxxx]
>>
>> <snip>
>>
>> my @oput2 = /\b([0-9]+)%/;
>>
>> <snip>
>
> Just for starters, a regular expression should use the =~ operator, not
> the = operator.
>
> You might have seen some examples like this:
>
> while(<INFILE>){
> if($_ =~ /mybigregularexpression/){
> Do something...
> }
> }
>
> Check out 'perldoc perlre'.

The OP's example isn't using the =~ operator because it is implied that:

my @oput2 = /\b([0-9]+)%/;

Is short for:

my @oput2 = $_ =~ /\b([0-9]+)%/;


Also the binding operators (=~ and !~) aren't used by regular
expressions. Regular expressions are the stuff between the match
operator delimiters (//) and in fact the binding operators can be used
with the tr/// operator which doesn't use regular expressions at all.



John
--
use Perl;
program
fulfillment
.