Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Copy array into input read process?

Received: by 10.66.90.37 with SMTP id bt5mr2853479pab.40.1352353226188;
        Wed, 07 Nov 2012 21:40:26 -0800 (PST)
From: Tuxedo <tux...@mailinator.com>
Newsgroups: comp.lang.perl.misc
Subject: Copy array into input read process?
Date: Thu, 1 Nov 2012 21:43:53 +0100
Organization: albasani.net
Lines: 32
Message-ID: <k6umu9$hd2$1@news.albasani.net>
Mime-Version: 1.0
X-Trace: news.albasani.net vja0QxtnLSlxOmIKUnSHMvCxIEWnDYynYYETwhmBsky6UeaNKt8Y8W3SWrDUJPxauV7DBh2KaKtYPjhPiUSrOMJbXp79iIKAtw9wthH9WlB2tFC4pfYsks3FjRYz+USX
NNTP-Posting-Date: Thu, 1 Nov 2012 20:43:54 +0000 (UTC)
Injection-Info: news.albasani.net; logging-data="CuUJPCBQRC+aB55jfN4UzPASl7ZPffFkYMiSPOa5dedNhFFKMtrJbczLdG4QF8DD+sQmjafzocOmvOrZudNhXfJMJYPVxXWCmHjNxO/enIdj2dMJcP6C+cIFah6aa0PI"; mail-complaints-to="ab...@albasani.net"
Cancel-Lock: sha1:td0SYRGMdiIdwhEi2xmch64IiWQ=
Path: s9ni86401pbb.0!nntp.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.mccarragher.com!news.grnet.gr!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!weretis.net!feeder1.news.weretis.net!news.albasani.net!.POSTED!not-for-mail
Bytes: 2246
X-Received-Bytes: 2354
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8Bit

The below procedure, using lynx, simply dumps the source of a URL when 
calling it with a single argument and prints each line:

open(my $fh, '-|', 
'/usr/bin/lynx','-source','-nonumbers','-cache=0','-nolist', $ARGV[0]) or 
die $!;
while (my $line = <$fh>) {
print $line;
}

Placed in a lynx.pl file, it can be run as
./lynx.pl example.com

Following the '-|' bit some fixed options are passed:
'/usr/bin/lynx','-source','-nonumbers','-cache=0','-nolist'
... and thereafter the URL.

How can this be better done in allowing arguments to be passed like:
./lynx.pl example.com -source -nonumbers -cache=0 -nolist

... then capturing the arguments somehow like follows:
open(my $fh, '-|', '/usr/bin/lynx', @flags $ARGV[0]) or die $!;

In the end it's not much different from running lynx directly but I would 
like some fixed and some optional arguments passed, and I'm not sure how to 
construct and push additional arguments into a list, then copy the final 
array into the file handle reading process between the -| bit and the 
$ARGV[0] to allow for a flexible number of command line options.

Many thanks for any ideas.

Tuxedo