Hi fellow Monks,
this one has me baffled...
I have the following code which reads files like http://oss.sgi.com/projects/ogl-sample/registry/APPLE/client_storage.txt
sub read_spec($) { my $filename = shift; local $/; open(my $fh, "<$filename") or die "Can't open filename"; my $content = <$fh>; $content =~ s{\s+$}{}m; # ... }
If you take a look at the file I mentioned above, you'll notice it has this:
Name
APPLE_client_storage
<tab here>
Name Strings
...
Running the above code on this file leaves the tab character in place.
Adding:
$content =~ s{\s+$}{}m; $content =~ s{\t+$}{}m;
has the desired effect. As well as this:
$content =~ s{[ \t]+$}{}m;
Ideas? My understanding of \s is flawled somewhere. After following manpages around, is ended up in isspace(3), which makes me beleive that the code should work as I expect it to.
Marcelo
Update: Fixed formatting...
In reply to \s vs \t by marcelo.magallon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |