develooper Front page | perl.perl5.porters | Postings from June 2013

[perl #118667] doc and code mismatch on some space character( classe)s

Thread Previous | Thread Next
From:
James E Keenan via RT
Date:
June 29, 2013 13:18
Subject:
[perl #118667] doc and code mismatch on some space character( classe)s
Message ID:
rt-3.6.HEAD-2552-1372511865-1142.118667-15-0@perl.org
On Fri Jun 28 07:36:04 2013, sdaoden wrote:
> Hello,
> there is something i don't understand.  Thank you.
> 
>   $ perl -e 'print "$^V:";$i="\x{00A0}"'\
>       -e ';if($i=~/[[:space:]]/){print "1"}'\
>       -e ';if($i=~/\s/){print "2"}'\
>       -e ';if($i=~/\p{IsSpace}/){print "3"}'\
>       -e ';print "\n"'
>     :3 <- 5.8.9 (-))
>   v5.10.0:3
>   v5.16.1:3
>   v5.18.0:3
> 

Steffen,

If I copy-and-paste your program into a terminal, I get syntax errors
when I attempt to run it:

#########
$ perl -e 'print "$^V:";$i="\x{00A0}"'\
> -e ';if($i=~/[[:space:]]/){print "1"}'\
> -e ';if($i=~/\s/){print "2"}'\
> -e ';if($i=~/\p{IsSpace}/){print "3"}'\
> -e ';print "\n"'
syntax error at -e line 1, near ""\x{00A0}"-e"
Execution of -e aborted due to compilation errors.
##########

I realize that there is something to be said for compressing a bug
report into a one-liner, but sometimes that comes at the expense of
readability.

Attempting to debug the syntax error, I started with this:

##########
$> perl -e 'print "$^V:";'
$>
##########

... and got no output.  Consulting 'perlvar', I learned that $^V holds
"[T]he revision, version, and subversion of the Perl interpreter,
represented *as a C<version> object*.  [Emphasis added.]  So right off
the bat, there is a problem with this one-liner.  I got better results
when, per perlvar, I did this:

##########
$ ./perl -e ' printf "version is v%vd\n", $^V;'
version is v5.19.2
##########

Could you please re-examine your report for syntax correctness and
readability?

Thank you very much.
Jim Keenan

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=118667

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About