what is perl's no op operator?

D

Dan Jacobson

In the shell, I can do echo $a; : echo $b; echo $c
to turn off b with minimal disturbance to the one-liner.
In perl, one can't get away with just adding a ": ":
print $a; if(0){print $b}; print $c; #best I know
Is there a way less disruptive to this one-liner?
 
E

Eric J. Roode

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In the shell, I can do echo $a; : echo $b; echo $c
to turn off b with minimal disturbance to the one-liner.
In perl, one can't get away with just adding a ": ":
print $a; if(0){print $b}; print $c; #best I know
Is there a way less disruptive to this one-liner?

Mmmm, probably prepend "0 and".

- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPyTwNGPeouIeTNHoEQLTbQCfdBi/vXv2NxmuDrJDq8bN+qiLNSsAnibC
5ha2eBcmTuhjIYoG+SJZoUe+
=w024
-----END PGP SIGNATURE-----
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
Eric J. Roode
Mmmm, probably prepend "0 and".

Wrong precedence.

0 and 1 or print "got here\n";

0 and 1 while print "got here\n";

Hope this helps,
Ilya

P.S. There is no comment-part-of-line construct in Perl.
 
P

pkent

Dan Jacobson said:
In the shell, I can do echo $a; : echo $b; echo $c
to turn off b with minimal disturbance to the one-liner.
In perl, one can't get away with just adding a ": ":
print $a; if(0){print $b}; print $c; #best I know
Is there a way less disruptive to this one-liner?

You can also use 'if' as a 'statement modifier', which is where it goes
at the end of the statement, like:

print $foo if 0;

P
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top