[prev] [thread] [next] [lurker] [Date index for 2006/12/22]
--hwvH6HDNit2nSK4j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Fri, Dec 22, 2006 at 02:43:08AM -0500, Sean Conner wrote:
> It was thus said that the Great David Cantrell once stated:
> > On Sun, Dec 17, 2006 at 09:36:52PM -0800, Aaron J. Grier wrote:
> >=20
> > > this is exactly what I hate about perl. "there's more than one way to
> > > do it" invariably means that some dumbfucks out there will attempt to=
do
> > > it every single way possible in the language. perl apparently prides
> > > itself on this.
> >=20
> > A general purpose language which can't be used in different ways to
> > solve different problems is not fit for purpose. Are you proposing that
> > programming languages should be rigid and unsuitable for a wide range of
> > tasks?
>=20
> Um ... <raises hand> ... I'd like somethimg a bit more consistent.
>=20
> A typical programic idiom I use (when programming in C) is:
>=20
> if (argc =3D=3D 1)
> do_some_process(stdin);
> else
> {
> for (i =3D 1 ; i < argc ; i++)
> {
> input =3D fopen(argv[i],"r");
> do_some_process(input);
> fclose(input);
> }
> }
>=20
> So imagine my surprise when:
>=20
> if (scalar(@ARGV) =3D=3D 1)
> { # the one bit of consistancy I can do without actually
> &do_some_process(STDIN);
> }
> else
> {
> for ($i =3D 1 ; $i < scalar(@ARGV) ; $i++)
> {
> open INPUT,$ARGV[i];
> &do_some_process(INPUT);
> close INPUT;
> }
> }
>=20
> Doesn't work at all. Problem one (remember, I come from a C background
> here), $ARGV[0] *doesn't* contain the program name ($ARGV isn't right sin=
ce
> it's only defined when using <ARGV> apparently---lovely), so okay, I adju=
st
> some numbers and it *still* fails because you can't pass file handles to
> subroutines.
>=20
> Only, it seems like you *can* but only if you use the *obvious* notation
>=20
> open INPUT,$ARGV[i];
> &do_some_processing(*INPUT);
> close INPUT;
>=20
> Never mind the fact that every @#$@#$ variable in Perl is preceeded by a
> '$', '@' or a '%' *except* for filehandles, diretory handles and block
> labels.
>=20
> Yes, C has its quirks too, but at least there I can actually pass any t=
ype
> of variable to a subroutine without having a special notation for a certa=
in
> class of variables.
You know, in Perl, the equivalent of the C snippet would just be:
do_some_process;
while in do_some_process, you'd use the '<>' to read input. Perl has the
snippet build in - if there are no arguments, '<>' will read from the
file(s) given as arguments.
Don't blame Perl for not having to translate your C code.
Abigail
--hwvH6HDNit2nSK4j
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFFi60rBOh7Ggo6rasRApJFAKDBVV4CG8ymp5TGjg8E3a9GBS+q3wCcD5zg
tGuMW/N3EKBpA/ahzXU9myw=
=a5LP
-----END PGP SIGNATURE-----
--hwvH6HDNit2nSK4j--
Generated at 14:01 on 28 Dec 2006 by mariachi 0.52