Re: More idiomatic

Discussion in 'Perl Misc' started by Rainer Weikusat, Apr 15, 2013.

  1. David Harmon <> writes:

    [...]


    > while (<$fin>) {
    > chomp;
    > if (/Newsgroups: .*,/i) {
    > $crosspost = 1;
    > next;
    > }


    The if (...) { } could be avoided here in favour of something a la

    /Newsgroups: .*,i/ and $crosspost = 1, next;

    [...]

    > if (/^From: /i) {
    > $fromline = $_;
    > $fromline =~ s/<.*>/<...>/;
    > next;
    > }


    For a multiline-group, this could become

    /^From: /i && do {
     
    Rainer Weikusat, Apr 15, 2013
    #1
    1. Advertising

  2. Rainer Weikusat <> writes:
    > David Harmon <> writes:
    >
    > [...]
    >
    >
    >> while (<$fin>) {
    >> chomp;
    >> if (/Newsgroups: .*,/i) {
    >> $crosspost = 1;
    >> next;
    >> }

    >
    > The if (...) { } could be avoided here in favour of something a la
    >
    > /Newsgroups: .*,i/ and $crosspost = 1, next;


    Disclaimer: My opinions are usually not considered 'comme il faut' by
    the people who define themselves as 'the Perl community' and their
    opinions as 'The Perl Way of XYZ'.
     
    Rainer Weikusat, Apr 15, 2013
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Zed A. Shaw
    Replies:
    2
    Views:
    111
    Zed A. Shaw
    Apr 23, 2005
  2. Charles Calvert
    Replies:
    33
    Views:
    374
    w_a_x_man
    Oct 22, 2010
  3. Alan Mead
    Replies:
    4
    Views:
    148
    Alan Mead
    Feb 12, 2005
  4. J. Gleixner

    Re: More idiomatic

    J. Gleixner, Apr 15, 2013, in forum: Perl Misc
    Replies:
    11
    Views:
    283
    Rainer Weikusat
    Apr 16, 2013
  5. Tim McDaniel

    Re: More idiomatic

    Tim McDaniel, Apr 15, 2013, in forum: Perl Misc
    Replies:
    3
    Views:
    179
    Keith Thompson
    Apr 16, 2013
Loading...

Share This Page