in reply to Re: Re: Regular Expression Question
in thread What happens with empty $1 in regular expressions? (was: Regular Expression Question)

That much I got(didn't mean to sound like a d**khead). What I don't get is why that is unsafe. Is it because bareword could be confused with a built in function or something like that? Why are undeclared variables unsafe? Same kind of thing?

Excuse my ignorance. I am starting to really get interested in the theories of programming and things like that and I would really like to get a handle on this stuff. I taught myself Perl about a year ago and I've had no one to ask these questions to. They are all sort of flooding out now.

Thanks for your help.

Amel - f.k.a. - kel

  • Comment on Re: Re: Re: Regular Expression Question

Replies are listed 'Best First'.
strict; why these practices are unsafe
by chipmunk (Parson) on Mar 01, 2001 at 01:05 UTC
    I see, I misunderstood your question. My apologies.

    One of the main reasons these practices are unsafe is that they often occur by accident.

    Here are some quick examples of mistakes that will cause errors with strict:

    my $variable = 7; print $varaible; # typo # error from strict 'vars' my $hash = { name => 'value' }; my $key = 'name'; print $key->{'name'} # derefenced wrong variable # error from strict 'refs' sub subroutine { } print subrotine; # typo # errors from strict 'subs'
    Using strict also encourages good coding practices such as controlling the scope of your variables (strict 'vars') and using hard references instead of soft references (strict 'refs').
(tye)Re: Regular Expression Question
by tye (Sage) on Mar 01, 2001 at 00:57 UTC

    In strict.pm I go over why barewords can be a problem. I don't agree with the term "unsafe" here. strict.pm helps Perl find simple mistakes for you.

    Undeclared variables are only a problem in that they prevent Perl from (reliably) telling you when you put a typo in a variable name.

            - tye (but my friends call me "Tye")