[Israel.pm] Doing it the perlish way

Yuval Kogman nothingmuch at woobling.org
Thu Jun 8 11:52:58 PDT 2006

On Thu, Jun 08, 2006 at 21:47:35 +0300, Yossi.Itzkovich at ecitele.com wrote:

> I don't think it's more perlish, but anyhow if I don't need the advantages
> of use warnings (such as "no warnings") I think that -w is better.
> ...

It's just my habit =)

> Why  do you prefer 3-arguments open ?

Because sometimes the file name might have funny characters in it,
and I think it's ugly that perl has to parse the file name to figure
out what mode I'm opening it in.

> > chomp for @dict; # trim the newlines
> What for ?

Because it's a list of words, not a list of lines as I see it...
Maybe that's just me

> I agree it's nice, and it's "descriptive writing", but especially in Perl
> the common way is not to close file handles, unless needed.

I optimize for readability no matter how/what I write. I don't like
spending more time than necessary figuring out what it is I wrote 2
years ago, especially if it's a module I have to maintain, but also
if it's a script i don't want to waste too much time on.

> >    my $pat = qr/$_/; # qr is both faster and more informative
> Why is it faster, and why more informative ?

Faster: the pattern is precompiled by perl, not recompiled again for
every word in @dict.

More informative: when stringified, compiled regexes will show the
(?ixsm-:) type flags so you can know exactly what the pattern is 

> >     print STDERR "pat=$pat"; # go to STDERR so that it doesn't wind  up
> in pipes
> I agree.  In this case why not using warn ?

I usually use warn with a new line at the end, but people tend to
not like it, so in fact I lied, and I *would* have used warn ;-)

  Yuval Kogman <nothingmuch at woobling.org>
http://nothingmuch.woobling.org  0xEBD27418

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://perl.org.il/pipermail/perl/attachments/20060608/99c3862c/attachment.pgp 

More information about the Perl mailing list