Hi Monks, I've been in a position of Linux sysadmin for the past 4 years and with the exception of very (very!) light bash use (I use "use" as opposed to scripting since most of what I write fits on a single (albeit very long) line. Not to say that it isn't useful\) I don't really do any scripting. I figured it was time to learn, so I picked up "Learning Perl - 6th edition" from my local bookstore yesterday and I have to say it's been a delight so far! Question: My version of perl is 5.14.2. I'm reading about the use of private persistent variables using the "state" keyword. The book introduces those with the "use 5.010;" pragma. If I don't declare "use 5.010;", the state variables doesn't work as expected and I get: Can't call method "state" on an undefined value at ./state_var.pl line 7. Code:

#!/home/erikg/bin/perl #use 5.010; &marine; sub marine { my $counter = 0; while ($counter < 10) { state $n = 0; $n += 1; print "\n$n"; $counter++; } }

But as soon as I remove the comment in front of use, it works fine. Although I understand "use strict;" and "use warning;" are ways of turning on/off strict/warning use, I was under the impression "use 5.XXX;" was a way of verifying the Perl interpreter was at least up to that version or better. I guess not... Question: If I have "use 5.010;" at the beginning of my code, does that mean any features in Perl newer than 5.010 will be unavailable? TIA


In reply to Use of "Use 5.XXX" pragma by phatrik

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.