Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic


by jdporter (Canon)
on Jan 10, 2007 at 20:59 UTC ( #594011=note: print w/replies, xml ) Need Help??

in reply to

my $fh = IO::File->new($MAILBOX) or die "unable to read mailbox '$MAILBOX': $!"; my $mail; { local $/; $mail = <$fh>; }
is probably better written as
my $mail = do { my $fh = IO::File->new($MAILBOX) or die "unable to read mailbox '$MAILBOX': $!"; local $/; <$fh> };
That way, $fh gets automatically closed as soon as you're done reading it, and you declare and assign $mail in one step.

Also, if it was me, I'd probably sort the email addresses when printing them.

A word spoken in Mind will reach its own level, in the objective world, by its own weight

Replies are listed 'Best First'.
by RyuMaou (Deacon) on Jan 10, 2007 at 21:13 UTC
    Yeah, I thought about combining the two scripts, but I could see how having as a stand alone might be useful. Also, though it's not an excuse, I pulled e-mail addresses from data files totalling close to a gig, possibly more, of raw data. It was only after I collected the data that I saw how much extra sorting I was going to need to do.

    Thanks for the cleanup, though. I don't hardly get to do enough PERL these days, so my code is even sloppier than it used to be!
      ...get to do enough PERL these days...

      You mean Perl.

        Well, there goes any hope of being one of the cool kids.
        Yep, I meant Perl.

        Anyway, thanks again for scrubbing my code. Now, if I can only find more time to write more....

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://594011]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2020-05-25 09:34 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (145 votes). Check out past polls.