As others have said, those READ and WRITE constants are actually Perl subroutines. You can't use "READ" the string as if it were READ the subroutine.

However, you can find the subroutine using the string name and then call it. There are two ways to do this. The first is to use string references and the second is to use the package "stash". Here's a short demo:

use strict; sub READ () { 34 } { no strict 'refs'; print &{'READ'}(), "\n"; } { print &{$main::{'READ'}}(), "\n"; }

You "use strict" so you'll probably want to use the second method. Here's the change you need to make to your program:

&{$main::{$folder_ace}}() | &{$main::{$subfolder_ace}}()

Be sure to include those empty parens -- when calling subs using the '&', the prototype is ignored and the current '@_' will always be passed to the sub unless an explicit argument list is given. The empty parens means the sub gets an empty argument list.

WARNING! This technique is not safe to use unless you trust the input -- it can allow people to call any subroutine in your package. I think it's ok to use in the example without any checking, but if you are very concerned about security, check the strings before looking up the subroutine.


In reply to Re: Perms Perms Perms by blssu
in thread Perms Perms Perms by blackadder

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.