Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

wog's scratchpad

by wog (Curate)
on Jun 01, 2004 at 20:55 UTC ( #358592=scratchpad: print w/ replies, xml ) Need Help??

wog's home node

for japhy:

=-> cat test.pl my($plaintext,$html); $plaintext = ">> foo"; pipe(READ, WRITE); print "about to open\n"; open WRITE, "| cat"; print WRITE $plaintext; print "\njust wrote\n"; close WRITE; print "\nclosed\n"; { local $/; $html = <READ>; } close READ; print "\njust read\n"; print "\$html: $html\n" =-> perl test.pl about to open just wrote >> foo closed just read $html:


#!/usr/bin/perl -w use strict; BEGIN { package Date::Year1984; use vars qw(@ISA); require Tie::Handle; @ISA = qw(Tie::StdHandle); sub samecase { my($what,$pat) = @_; $what = lc $what; for my $i (0..length($pat)-1) { substr($what,$i,1) = uc substr($what,$i,1) if substr($pat,$i,1) eq uc substr($pat,$i,1); } return $what; } sub filter { s/\b4\b/5/g, s/\b(four)\b/samecase("five",$1)/ieg for @_; } sub WRITE { my @x = @_; filter($x[1]); Tie::StdHandle::WRITE(@x); } tie *STDOUT, 'Date::Year1984', '>&STDOUT'; tie *STDERR, 'Date::Year1984', '>&STDERR'; $SIG{__DIE__} = sub { local @_ = @_; &filter; die(@_); }; $SIG{__WARN__}= sub { local @_ = @_; &filter; warn(@_) }; } # end of BEGIN{} package main; print "2 + 2 = 4.\n"; warn "2 + 2 = 4 not 5!\n"; die "saying two and two makes FOUR! (I love Big Brother!)\n";

No comment.


Search Results
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2016-06-27 05:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (335 votes). Check out past polls.