With use strict you get use strict 'refs' which specifically prohibits the symbolic references you are trying to use in the case of 'L0'. You need to either use hard references or insert "no strict 'refs'" before you use a symbolic reference. The prohibition of symbolic references under strict is there for a purpose, so you need a good reason to do the second option. See strict and perlref for details.

use strict 'refs'; my $foo = "bar"; # hard reference my $ref = \$foo; print $$ref; # ok, prints "bar" # symbolic reference $ref = "foo"; print $$ref; # runtime error; ok without strict { no strict 'refs' print $$ref; # works but considered bad }

The symbolic reference generates runtime error in the first instance. We enclose the no strict 'refs' in a bare block to limit its scope to the one line where we want to use a use a sym ref. This is the best way to do this if you absolutely positively can not live without a sym ref. 99+% of the time you can and should avoid sym refs.

Your second error occurs because you are trying to declare a dereference $$lentry. You need to declare the variable $lentry, assign a reference to it, and then dereference it using $$lentry. $$lentry is not something that you declare.

tachyon


In reply to Re: Problems to use strict with dynamic $$variable by tachyon
in thread Problems to use strict with dynamic $$variable by juo

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.