Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Congrats on your continuted progress to Sainthood. :)

1) A naked block can be used for various things. One of the more common is to limit the scope of variables. ie:

{ my $tempvar = somefunc(); # do something with $tempvar } # $tempvar no longer exists here.
or it's used to limit the scope of local()
{ local(*INPUT, $/); open (INPUT, $file) || die "can't open $file: $!"; $var = <INPUT>; } # $/ is set back to it's original value here.

2) Without knowing what you were doing with the regex, it is hard to say how it may have been wrong.

3) next goes to the next interation of the loop, not the last one. In effect it skips the rest of the current iteration (although it does execute the continue block if you have one). One common use is for skipping certian lines while reading a file.

while (<FH>) { next if /^#/; # Skip comments # now do something with $_ }
Update: Fix explaination of next

In reply to Re: A few random questions from Learning Perl 3 by Paladin
in thread A few random questions from Learning Perl 3 by sulfericacid

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (2)
    As of 2020-02-22 10:40 GMT
    Find Nodes?
      Voting Booth?
      What numbers are you going to focus on primarily in 2020?

      Results (99 votes). Check out past polls.