[VPM] Symbolic references with use strict in effect.

Adam Parkin pzelnip at telus.net
Sun Jun 4 09:26:11 PDT 2006


First off, sorry Darren I didn't mean to send this message to your 
personal account, but when I hit "reply" to your VPM post Thunderbird 
automatically put your address in the "To" field instead of 
"victoria-pm at pm.org", and I didn't notice this until after I had hit "send".

Darren Duncan wrote:
> One solution is to turn off strict for just that line of code, and 
> have it on for the rest of the file.

Hmm, okay, I like that idea: only having strict off for a block of code,
but on everywhere else.  But wouldn't the "no strict" still apply to the
subroutines that get called?

use strict;

{
     no strict;
     my $nameOfSub = "foo";
     &$nameOfSub ($args);
}

sub foo {
    # in here no strict is still in effect so I could do something like
    $variableWithoutUsingMy = .....;

    # print the wrong thing by mistake
    print "$avriableWithoutUsingMy\n";
}

I could do like Abram suggested and use no strict "subs" rather than no
strict, but still I believe the relaxed strictness will apply to the
called sub (which I don't really want).  I wonder, could I do something
like:

use strict;

my $fnRef;
{
    my $nameOfSub = "foo";
    no strict "subs";
    $fnRef = \&$nameOfSub;
}
&$fnRef ($args);

That is, just turn the strict off long enough to get a real (not
symbolic) reference to the sub, then turn use strict back on before
calling the sub through the reference.  I think I shall try this to see
what happens. =8->

>> This said, there are inherent security risks in doing such symbolic 
>> references like this.  What if someone puts 'system' as the name of 
>> the function to call, and 'rm -rf' as the argument.

Of course, and I am fully aware of that, but given that this is a pet
project to be used by myself and only myself I'm not to worried about
myself being a malicious user. =8-p

Thanks for the suggestions!
-- 
Adam Parkin
E-mail: pzelnip at telus.net
--------------------------
We often spend so much time coping with problems along our path that we 
forget why we are on that path in the first place. The result is that we 
only have a dim, or even inaccurate, view of what's really important to us.

	-- Peter Senge, The Fifth Discipline



More information about the Victoria-pm mailing list