si_lence has asked for the wisdom of the Perl Monks concerning the following question:
this does not work, i.e it prints only the 'processing' lines.use strict; use warnings; my @test = qw(no_proc line_to_proc1 line_to_proc2); for (@test) { print $_ . "\n" && next if /no_proc/; #no processing print "$_ : in proc \n"; #processing }
So I changed the first print line to
This gives the output I want, but also the noteprint ($_ . "\n") && next if /no_proc/;
So I ended up using an if statementprint (...) interpreted as function at ...
That works again without any notes, but still leaves me wondering if and how it could be done with a modifier if.if (/no_proc/){ print $_ . "\n"; next; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: if modifier of a print statement
by davorg (Chancellor) on Jun 30, 2009 at 10:51 UTC | |
by tprocter (Sexton) on Jun 30, 2009 at 11:14 UTC | |
by jwkrahn (Abbot) on Jun 30, 2009 at 15:03 UTC | |
|
Re: if modifier of a print statement
by Marshall (Canon) on Jun 30, 2009 at 11:30 UTC | |
by jwkrahn (Abbot) on Jun 30, 2009 at 12:14 UTC | |
by Marshall (Canon) on Jun 30, 2009 at 12:34 UTC | |
by jwkrahn (Abbot) on Jun 30, 2009 at 13:38 UTC | |
by Marshall (Canon) on Jun 30, 2009 at 15:58 UTC | |
by JavaFan (Canon) on Jul 01, 2009 at 09:58 UTC | |
|
Re: if modifier of a print statement
by jwkrahn (Abbot) on Jun 30, 2009 at 12:21 UTC | |
|
Re: if modifier of a print statement
by Anonymous Monk on Jun 30, 2009 at 11:57 UTC |