develooper Front page | perl.perl5.porters | Postings from August 2008

Re: [PATCH] Add open "|-" and open "-|" to perlopentut

Thread Next
Tom Christiansen
August 26, 2008 11:25
Re: [PATCH] Add open "|-" and open "-|" to perlopentut
Message ID:
>> And so we have a culture--no, strike that--we have *two*
>> cultures, where they are expecting \t, and \n too, to mean a
>> single character.

> By that argument, you should agree with Damian's admonition that
> one should always use the `/m` modifier on patterns, because that
> will make `^` and `$` behave as programmers from other cultures
> expect, even though in Perl they behave differently, and a Perl
> programmer knows how they do behave in Perl.

First off, I confess to failing to deeply understand where Damian is 
coming from there.  Therefore, I shall neither agree nor disagree with 
what I do not understand.  Which means I cannot continue your question.

More specifically, I have myself no acquaintance with any culture where 
/^/ means /^/m.  Perhaps Damian does.  The same applies to /$/ vs /$/m.

So I am quite confortable using ^ in nearly all places, though perhaps 
not in /^[^^]/ :).

However, /$/ is trickier for a different reason altogether, and its trouble
is unimproved by /$/m, or by /\Z/ either.  It's a bit of a shame that as
/./s means /\p{Any}/ (which is what I more often use now, lamentably
unHoffmaning the commonest thing from a wee 1 to a super 7, even 8 chars),
that /$/s never came to mean /\z/.  

Given that I've had to fix this before, as noted in the Changes5.6 log entry:

[  5296] By: gsar                                  on 2000/02/28  00:00:05
        Log: m/.*$/ etc should be m/.*\z/s in many file handling modules; fix
             these insidious errors in File::Basename, File::Find and find2perl
             (from Tom Christiansen)
             TODO: many other modules need to be fixed as well!
     Branch: perl
           ! lib/File/ lib/File/ x2p/find2perl.PL

There is probably something to be learned here, even if I don't quite
understand what Damian's saying.  As noted, I do hate insidious errors.


PS: Don't get me started about use warnings safety on


    eg% perl -WE 'say chr(0xfdd0) =~ /\p{Any}/ || 0'
    Unicode character 0xfdd0 is illegal at -e line 1.

    eg% perl -WE 'say chr(0xfdd0) =~ /\p{Assigned}/ || 0'
    Unicode character 0xfdd0 is illegal at -e line 1.

    eg% perl -WE 'say chr(0xfdd0) =~ /\p{UnAssigned}/ || 0'
    Unicode character 0xfdd0 is illegal at -e line 1.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About