This has an OS dependency; I've tested on Solaris, XP, and cygwin, and would be curious to hear if it works on others.

use strict;use warnings;close STDERR&&open STDERR,">",\$_; if($-=(map{++$|,warn$!?$!|=$_:$!=$_,$/}66,55,25,67)?$|:$() {@_=map{substr($_,++$-,++$|)}split$/;print((($^O=~/win/i)? join(undef,@_)^'!/ ?':@_)=>"\!",$/)}

Update: Thank you for the replies! Relying on the error codes was a bad idea. Capturing STDERR was my main point of interest, and below is a better (?) attempt:

use strict;use warnings; {close STDERR&&open STDERR,'>',\$_} print,print[split/\0/,uc^'?25HnL ']->[$|]

Replies are listed 'Best First'.
Re: warn("japh!\n"); # ???
by massa (Hermit) on Feb 18, 2009 at 17:11 UTC
    $ perl | od -cb use strict;use warnings;close STDERR&&open STDERR,">",\$_; if($-=(map{++$|,warn$!?$!|=$_:$!=$_,$/}66,55,25,67)?$|:$() {@_=map{substr($_,++$-,++$|)}split$/;print((($^O=~/win/i)? join(undef,@_)^'!/ ?':@_)=>"\!",$/)} 0000000 j c a ! \n 152 040 143 141 041 012 0000006
    []s, HTH, Massa (κς,πμ,πλ)
Re: warn("japh!\n"); # ???
by wazoox (Prior) on Feb 18, 2009 at 14:17 UTC
    I've got
    oule!
    under Linux (slackware 12.1, perl 5.8.8 and Debian Etch, perl 5.8.8)

    edit: on Mac OS X 10.5 and perl 5.8.8 it gives:

    SMP^!
    The updated code works as expected on both, though :)
Re: warn("japh!\n"); # ???
by atemon (Chaplain) on Feb 18, 2009 at 14:56 UTC

    got

    japh !
    on CentOS 5.2, Perl 5.8.8

    --VC