Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by perl-diddler (Chaplain)
on Mar 14, 2013 at 05:12 UTC ( [id://1023371]=note: print w/replies, xml ) Need Help??


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

Um... so everyone who uses 'print' or 'printf' needed to use IO::Handle? I doubt that is what you mean, is it?

In any case, changing the code from '$fh->print' to 'print $fh' seems to have fixed the problem. Of *course* it makes sense -- it's perl! :-)

That uncovered one last (??*crossing fingers*??) bug where the 'cat' was involved, which was unrelated to the 'rev', which I just supplied in my test directory (in a perl-1-liner script).simulated in a perl 1-liner:

P> more t/rev sub rv{1>=length $_[0]?$_[0]:substr( $_[0],-1).rv(substr $_[0],0,-1)} +$_=<>;chomp; print rv($_);
The 'cat' was for my STDERR test, which I cleaned up (and got rid of using 'cat' in testing...didn't want any Humane Society/PITA complaints). It's a split output, where the first part of the line put out by the 'generic example' code is on STDOUT, and the 2nd part is on STDERR... so I just run it twice for that test:
if ($caseno == 5) { my $null; my $dev; open($null, ">", $dev="/dev/null") or open($null, ">", $dev="NUL:") or die "Cannot open /dev/null nor NUL:"; close ($null); my $resp = get_case($matchp->[0],"2>$dev"); $resp =~ m{$weak_match_expr}; ($rcase,$name, $rstr) = ($1,$2,$3); $resp = get_case($matchp->[0],"2>&1 >$dev"); $resp =~ m{$weak_match_expr}; $rstr = $2; } .... ok($rcase && $caseno == $rcase, "received testcase $caseno"); if (length($re)) {ok($rstr =~ m{$re}, $name)} }
Hopefully "/dev/null" or "NUL" will work (it works on my linux and on Windows strawbelly16.2.)

Tedia, tedia, tedia....;-)

Thanks again for the assists...this is my testing the waters, as it were...
hopefully it will go well...

Replies are listed 'Best First'.
Re^3: perl 5.12 BSD portability (CPAN test result)...print
by ikegami (Patriarch) on Mar 14, 2013 at 23:25 UTC

    Um... so everyone who uses 'print' or 'printf' needed to use IO::Handle? I doubt that is what you mean, is it?

    It's not what I meant. It's not what I said.

    Everyone who uses IO:Handle's print or printf method (e.g. $fh->print("foo");) needs to use use IO::Handle; or similar before 5.14.

    Using the print or printf operator (e.g. print $fh "foo";) does not require the use of use IO::Handle;.

Re^3: perl 5.12 BSD portability (CPAN test result)...print
by chromatic (Archbishop) on Mar 14, 2013 at 06:14 UTC
    Um... so everyone who uses 'print' or 'printf' needed to use IO::Handle?

    Everyone who wanted to use those as methods on filehandles had to use IO::Handle, yes.

      But only in the FH->print format? Why does it work in the print FH mode? Aren't they supposed equivalent?

        The parser knows about print as a keyword. It's been a special case as far back as I can remember (Perl 1?). You can look at it as an indirect method call from the language level, but the parser doesn't need heuristics because the grammar has a specific rule for the print $filehandle case.

        But only in the FH->print format? Why does it work in the print FH mode? Aren't they supposed equivalent?

        No, they're not equivalent. print FH ... is an instance of a the print operator.

        FH->print(...) is a method call. It does whatever FH's class's print method does. If FH is an IO::Handle or IO::File object, its print method calls the print operator.

        sub print { @_ or croak 'usage: $io->print(ARGS)'; my $this = shift; print $this @_; }
Re^3: perl 5.12 BSD portability (CPAN test result)...print
by syphilis (Archbishop) on Mar 14, 2013 at 07:39 UTC
    Hopefully "/dev/null" or "NUL" will work (it works on my linux and on Windows strawbelly16.2.)

    For portability File::Spec->devnull() works well.

    Cheers,
    Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1023371]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-18 09:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found