Click here to get back home

discover invisible characters

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
discover invisible characters Ela 06-10-2008
Posted by Ela on June 10, 2008, 3:12 pm
Please log in for more thread options
I've tried to identify the invisible characters leading to unsuccessful
pattern matching. However the screen prints out nothing special like this:

ORF: AAAAMT0002
pattern COG3i start: AAAAMT0002

What should I do to find out the problem? Thanks a lot.



$pattern2 = $aref2->[$cog3i];
$pattern2 =~ s/[\t\n^M]//g;
$pattern1 = $aref1->[$orfi];
$pattern1 =~ s/[\t\n^M]//g;
if ($pattern1 !~ /$pattern2/) {
print "ORF: AAAA$pattern1\n";
print "pattern COG3i start: AAAA$pattern2\n";
<STDIN>;
}




Posted by Ben Bullock on June 10, 2008, 2:43 am
Please log in for more thread options
> I've tried to identify the invisible characters leading to unsuccessful
> pattern matching. However the screen prints out nothing special like this:
>
> ORF: AAAAMT0002
> pattern COG3i start: AAAAMT0002
>
> What should I do to find out the problem? Thanks a lot.

The problem is probably a space character at the end of the string. If
you change the print statement you might see it.

> $pattern2 = $aref2->[$cog3i];
> $pattern2 =~ s/[\t\n^M]//g;

$pattern2 =~ s/\s+//g;

> $pattern1 = $aref1->[$orfi];
> $pattern1 =~ s/[\t\n^M]//g;

$pattern1 =~ s/\s+//g;

> if ($pattern1 !~ /$pattern2/) {
> print "ORF: AAAA$pattern1\n";

print "ORF: '$pattern1'\n";

> print "pattern COG3i start: AAAA$pattern2\n";

print "pattern COG3i start: '$pattern2'\n";

> <STDIN>;

What does that do?


Posted by Ela on June 11, 2008, 12:41 am
Please log in for more thread options

>> I've tried to identify the invisible characters leading to unsuccessful
>> pattern matching. However the screen prints out nothing special like
>> this:
>>
>> ORF: AAAAMT0002
>> pattern COG3i start: AAAAMT0002
>>
>> What should I do to find out the problem? Thanks a lot.
>
> The problem is probably a space character at the end of the string. If
> you change the print statement you might see it.
>
>> $pattern2 = $aref2->[$cog3i];
>> $pattern2 =~ s/[\t\n^M]//g;
>
> $pattern2 =~ s/\s+//g;
>
>> $pattern1 = $aref1->[$orfi];
>> $pattern1 =~ s/[\t\n^M]//g;
>
> $pattern1 =~ s/\s+//g;
>

It's really weird.... I used vim to replace and it reported that replacement
did succeed...
Anyway, thanks a lot!!! It's most frustrated when you cannot see any
characters but the pattern matching keeps failing. Any editor works better
than vim in this case?






Posted by Martijn Lievaart on June 10, 2008, 4:29 pm
Please log in for more thread options
On Tue, 10 Jun 2008 21:41:30 -0700, Ela wrote:

> It's really weird.... I used vim to replace and it reported that
> replacement did succeed...
> Anyway, thanks a lot!!! It's most frustrated when you cannot see any
> characters but the pattern matching keeps failing. Any editor works
> better than vim in this case?

Emacs can be set to highlight trailing spaces. I'm sure vim can do the
same.

M4

Posted by Peter J. Holzer on June 14, 2008, 2:01 am
Please log in for more thread options
> On Tue, 10 Jun 2008 21:41:30 -0700, Ela wrote:
>> It's really weird.... I used vim to replace and it reported that
>> replacement did succeed...
>> Anyway, thanks a lot!!! It's most frustrated when you cannot see any
>> characters but the pattern matching keeps failing. Any editor works
>> better than vim in this case?
>
> Emacs can be set to highlight trailing spaces. I'm sure vim can do the
> same.

:set list

and

:set listchars=tab:»·,trail:·

looks a bit nicer than the default.

A feature that can occassionally get in your way if you are looking for
"hidden characters" is the automatic detection of line endings and
character encodings. If you load a file with a different line ending or
encoding it will usually look "normal", except for a briefly displayed
message in the status line.

        hp

Similar ThreadsPosted
discover invisible characters June 10, 2008, 3:10 pm
sub, discover name of while running? December 8, 2005, 3:05 am
Discover As Beginning Successful Business In Internet. June 18, 2007, 10:29 am
Discover Islam - The Fastest Growing Religion in the World ! July 4, 2008, 2:05 am
Cut the last invisible spaces from the words November 25, 2004, 5:22 pm
Invisible cache for LWP / Mechanize? January 28, 2005, 2:20 am
Invisible variables in Perl debugger February 3, 2005, 6:13 am
Invisible variables in Perl debugger II May 30, 2005, 2:31 am
How to make perl code invisible to the User? April 24, 2006, 11:32 pm
Adding a delimiter inbetween number characters and letter characters January 12, 2005, 9:25 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap