in reply to Declaring and checking content of variables with consecutive names

The extreme dodgy hack way (if you cannot use arrays) would be like this :

for(0..99){ ${"str$_"}=""; }
Yes very hacky I know but it does answer the question.
Please do not use this code example in a live or production environment.
-SJ-

  • Comment on Re: Declaring and checking content of variables with consecutive names
  • Download Code

Replies are listed 'Best First'.
Re^2: Declaring and checking content of variables with consecutive names
by haukex (Archbishop) on Sep 27, 2016 at 08:53 UTC

    This is more of a reply to the OP:

    It's important to note that this code will not work when strict is enabled, and strict should always be turned on - in fact, modern versions of Perl turn it on for you if you say use v5.12; or higher at the top of the script. (See also Use strict and warnings)

    Disabling strict is something that should only be done if you know what you are doing and why. In this case, others have already explained why there are much better ways to do what you want.

    Regards,
    -- Hauke D