DCPM: perltutopen blues....
Matthew Browning
mb at matthewb.org
Fri Jul 4 09:05:50 CDT 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Friday 04 July 2003 14:47, Simon Waters wrote:
> Simon Waters wrote:
> > If I can master perl syntax <sic> I should have a working prototype
> > by tomorrow..
>
> Well it works after a fashion, I have a lot of rough edges to clean
> up.
>
> First is I would like to use; "script file1 file2 file3" or "script
> -" etc etc...
>
Have a look at one of the GetOpt modules. GetOpt::Simple?
> My first attempts failed miserably.... The open is done by
> Chess::PGN::Parse, looks remarkably like that bit in the perltutopen,
> which starts muttering in old english (dweomer indeed) about how
> painful this is.
>
> Can someone explain what to do with "$_" in "while(<>){}" to feed it
> to "new Chess::PGN::Parse", previous I had "new Chess::PGN::Parse
> $pgn" where '$pgn = "1.pgn"' (1.pgn being a file name), and no
> "while" loop.
I had a quick look at the Chess::PGN::Parse module. It seems to take a
filename as its contructor argument. You have a bunch of filenames
that you've got from the command line somehow.
I would address this by putting them in an array, probably, then
iterating over it like:
for( @filesFromCommandLine ) {
my $object = Chess::PGN::Parse->new( $_ );
$object->interesting_chess_related_method();
push @array_of_objects, $object;
}
Let us know if I have misinterpreted the question.
Matthew Browning
- --
http://matthewb.org/public_key.txt
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE/BYm+y5o0lRFL2ooRAommAJ9ctnb3/NXzkmEhmeaCSeHWwGdEkQCfV+Dp
3uifwrvdBC7h2Jh6W9k/HeU=
=zvrh
-----END PGP SIGNATURE-----
More information about the Devoncornwall-pm
mailing list