while (<$fh>) { next if 1 .. 1; print "$_\n"; }

means

while (<$fh>) { next if $.==1 .. $.==1; print "$_\n"; }

so to do the same with a loop which counts over something other than $., you have specify it explicitly.

for (1,2,3,4,5) { next if $_==1 .. $_==1; print "$_\n"; }

what do they mean by "constant expression?"

Short: Anything that Perl converts to a constant at compile-time.

>perl -MO=Concise -e"print( 4 + 1 * 2 )" 6 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v ->3 5 <@> print vK ->6 3 <0> pushmark s ->4 4 <$> const[IV 6] s ->5 <--- 4+1*2 -e syntax OK >perl -MO=Concise -e"print( 4 + $x * 2 )" a <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v ->3 9 <@> print vK ->a 3 <0> pushmark s ->4 8 <2> add[t3] sK/2 ->9 \ 4 <$> const[IV 4] s ->5 | 7 <2> multiply[t2] sK/2 ->8 | <--- 4+$x*2 - <1> ex-rv2sv sK/1 ->6 | 5 <#> gvsv[*x] s ->6 | 6 <$> const[IV 2] s ->7 /

Long: A constant expression is known to Perl to always return the same result. It includes constants (including those created by constant), most operators operating on constants, some builtin functions, and functions with the () prototype whose body consist entirely of a constant expression (as per Constant Functions in perlsub).

Given

sub PI() { 4 * atan2(1, 1) } use constant SOMENUM => rand(4);

Example of constant expressions:

4 5+6*7 4 * atan2(1, 1) PI SOMENUM

In reply to Re^3: When doesn't the flip-flop operator work in all scalar contexts? by ikegami
in thread Why doesn't the flip-flop operator work in all scalar contexts? by siracusa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.