Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^10: perl 5.12 BSD portability (CPAN test result)...print

by perl-diddler (Hermit)
on Mar 20, 2013 at 03:15 UTC ( #1024422=note: print w/replies, xml ) Need Help??


in reply to Re^9: perl 5.12 BSD portability (CPAN test result)...print
in thread perl 5.12 BSD portability (CPAN test result)...print

You mean like this:
perl -e 'use P; my $x=27; P $x; my $y=\*STDOUT; P $y,"through STDOUT=%s", $x' 27 through STDOUT=27
What it can't easily do is, both:
P $x #and P STDOUT $x #without the comma
where $x is not an object. That takes "special parsing"...but if the right prototype element was created to do that.. if not an object, then pass as a scalar), that would work too. I.e. I can get the 2nd case to work, but then the 1st case doesn't.

So is the only reason print has to be an operator is to handle printing to a <FH> w/o the comma, since the first case -- telling the difference between "$X" as a var and $x as a FH is fairly straightforward.

Note -- if you really wanted to print FROM file handle "$x", I'd have to add code for that...but if the file is open for READ/WRITE -- no way to tell.

FWIW, P does print from File handles (but not as the first arg or w/o a format statement). It reads the file handle and prints the contents as part of the output:

# perl -e 'use P; P \*STDOUT, "Input was: %s", \*STDIN; ' my input Input was: <*=my input >

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024422]
help
Chatterbox?
[Tux]: C99 is not supported on HP-UX before 11.31
[Tux]: at least not reliable. And perl itself requires C89 (but probes if it can safely use some C99 features)
Eily takes a peek in the last hour of CB to discover that LanX woke up is boobs with some Queen :P
[Eily]: s/\K\bis\b/h/
[Tux]: you left the space in
[Tux]: and that \K is not required
[Tanktalus]: 11.31 is already 10 years old... you still need to support versions older than that? My condolences :)
[Eily]: meh, got confused. s/(?=\bis\b)/h/ will work better :)
[Eily]: \K keeps the thing on the left, not the right (IE, it's like look behind, not look ahead)

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2017-09-20 16:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (237 votes). Check out past polls.

    Notices?