#!/usr/bin/perl sub with_stdin { my $surrogate_input = shift; my $test_sub = shift; local *STDIN; open STDIN, '<', \$surrogate_input; &{$test_sub}; } sub test_sub { print "Arguments: @_\n"; while(<STDIN>) { print "** $_"; } } with_stdin <<'EOS' Once Upon A Time EOS , \&test_sub, qw(arg1 arg2 arg3);
In reply to Re: Testing a subroutine with STDIN
by calin
in thread Testing a subroutine with STDIN
by mulander
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |