I have a strange behavior I do not really understand.
I want to print out some lines with processing and some other without.
What I did in the first place was something like this:
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
}
this does not work, i.e it prints only the 'processing' lines.
So I changed the first print line to
print ($_ . "\n") && next if /no_proc/;
This gives the output I want, but also the note
print (...) interpreted as function at ...
So I ended up using an if statement
if (/no_proc/){
print $_ . "\n";
next;
}
That works again without any notes, but still leaves me wondering if and how it could be done with a modifier if.
Any insight welcome.
si_lence
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.