Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^2: Is it possible to write to STDIN ?

by exilepanda (Friar)
on Jul 21, 2014 at 15:18 UTC ( [id://1094523]=note: print w/replies, xml ) Need Help??

in reply to Re: Is it possible to write to STDIN ?
in thread Is it possible to write to STDIN ?

Hey, this one is interesting and seem very likely what I am looking for... but please have a look for what I am planning to do, and could you advise can I do this inside the code rather than pipe it from the shell?
$ENV{REQUEST_METHOD} = "POST"; open F, "testplan.txt" or die $!; while ( chomp ( my $data = <F> ) ) { ### DO ANYTHING TO MAKE $data BECOME STDIN ### # the main() script that reads and handle the form # print final result # next test plan data } close F;

Replies are listed 'Best First'.
Re^3: Is it possible to write to STDIN ?
by DrHyde (Prior) on Jul 23, 2014 at 10:31 UTC
    You could close STDIN and re-open it as a normal filehandle:
    close(STDIN); open(STDIN, 'foo'); print $_ foreach(<STDIN>);
    The documentation for 'open' shows how to save and restore filehandles, and some other dirty tricks you can play.

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-07-25 01:04 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.