On Aug 24, 1:12 pm, [EMAIL PROTECTED] (Yoyoyo Yoyoyoyo) wrote:
> Hi all,
>
> I am using the diamond operator to redirect input to my perl script.  I want 
> to copy all of the input on to a single variable using the following 
> subroutine:
>
> sub getfile  # Copies the file redirected to this perl script to the varialbe 
> $x
> {
>   my $x;
>   local $/ = undef;
>   $x = <>;
>   return $x;
>
> }
>
> The problem is that when I try to print what the above subroutine returns, 
> the program kindof hangs.  That is, it doesn't just print the output and then 
> send me back to the command line, instead I have to press Ctrl-c to break out 
> of it, like it is expecting input from the keyboard.  

I'm willing to bet you're calling your script by doing:

$ ./file.pl < text.txt

when you should be doing:

$ ./file.pl text.txt

That is, let <> read from the command line argument, rather than
having it read from STDIN and redirecting the process's STDIN to be
from this file.

Paul Lalli


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to