[ale] perl regex.... again

Geoffrey Myers lists at serioustechnology.com
Tue Mar 1 06:51:29 EST 2011


Michael H. Warfield wrote:
> On Mon, 2011-02-28 at 16:41 -0500, Michael H. Warfield wrote: 
>> On Mon, 2011-02-28 at 16:28 -0500, Geoffrey Myers wrote: 
>>> Pat Regan wrote:
>>>> On Mon, 28 Feb 2011 15:38:37 -0500
>>>> Geoffrey Myers <lists at serioustechnology.com> wrote:
>>>>
>>>>>> Geoffrey,
>>>>>>
>>>>>> if ($line =~ /[^\040-\176]/) {
>>>>>>
>>>>>>    print ("Line contains out of range characters\n");
>>>>>>
>>>>>> }
>>>>>>
>>>>>> keith
>>>>> Does not pick up an string that contains an embedded character
>>>>> outside the range.  Say:
>>>>>
>>>>> This is a bad ^G line.
>>>> His code should print the message for a control-g.  Can you post your
>>>> actual code and some test input that fails?
>>> I cut/pasted his code inside my:
>>>
>>> while(<>) {
>>> }
>>>
>>> the above example is from my test data;
> 
>>> This is a bad ^G line.
> 
>> Silly question but that is a true cntrl-G and not a ^G like what was in
>> your message?
> 
>> Due to a bug in his suggested code, why don't you try a tab.  He forgot
>> to include the HT (Horizontal Tab) character (\011).  Unless there's a
>> problem using octal escapes in bracketed exclusions with perl.  I've
>> seen some things what work outside of a bracket range and won't inside.
>> Try this instead [^ -~] which will do the same thing (and still has the
>> same bug).
> 
> Yeah, strong suspicion you can not do \OOO inside a regex.  From the man
> page:
> 
> man 7 regex
> 
> ==
> ...  all other special characters, including '\', lose their special
> significance within a bracket expression.
> == 

This is most bizarre.  I don't know what I changed, but I starting 
working with this again and the following appears to work:

($_ =~ /[^\040-\176]/) && print "<$_> bad\n";

On the following data:

This is a bad ^G line.
This is a good line.
^G


Lines 1 and 3 are recognized as 'bad', line 2 is not.

More testing....

Thanks folks.

> 
>>>> Pat
>>>> _______________________________________________
>>>> Ale mailing list
>>>> Ale at ale.org
>>>> http://mail.ale.org/mailman/listinfo/ale
>>>> See JOBS, ANNOUNCE and SCHOOLS lists at
>>>> http://mail.ale.org/mailman/listinfo
>> Regards,
>> Mike
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo


-- 
Until later, Geoffrey

"I predict future happiness for America if they can prevent
the government from wasting the labors of the people under
the pretense of taking care of them."
- Thomas Jefferson


More information about the Ale mailing list