On Thu, Jun 4, 2009 at 14:40, Chap Harrison <c...@pobox.com> wrote:
> I'm writing a collection of filters that read from the CygWin / Windows
> system copy buffer (/dev/clipboard) and write to STDOUT.  I can certainly
> write Perl to open this "file" and read from it, but I wondered if there was
> a way to put it into the shebang line.  I don't have any reason to want to
> do this except for the brevity and the learning experience.
>
> I've read perldoc perlrun but find it pretty confusing.  Things I've tried
> unsuccessfully are:
>
> #!/usr/bin/perl /dev/clipboard
> #!/usr/bin/perl < /dev/clipboard
> #!/usr/bin/perl -- /dev/clipboard
>
>
> The body of the script always begins
>
> while (defined (my $line = <>)) {
>        ...etc
> }
snip

I would say the following instead.

@ARGV = ("/dev/clipboard");
while (my $line = <>) {
    ...etc
}

Note, it is not necessary to say while (defined (my $line = <>)) {,
Perl does some magic with readline, readdir, and glob in while loops:

perl -MO=Deparse -e 'while (my $line = <>) { }'

while (defined(my $line = <ARGV>)) {
    do {
        ()
    };
}
-e syntax OK

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to