Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: What are multiple $_[0] =~ operations doing?

by ambs (Pilgrim)
on Apr 01, 2005 at 09:39 UTC ( #444126=note: print w/replies, xml ) Need Help??


in reply to What are multiple $_[0] =~ operations doing?

$_[0] is the first argument to the function. The binding operator (=~) followed by s/// performs substitutions. The ge at the end says to do the subtitutions how many time it cans ("g") and that the subtitution value should be evaluated ("e").

So, you are substituting "%HTTP_HOST%" by the result of calling the "handleEnvVariable" function.

If you don't like it that way, you can always:

$_[0] =~ s/%(HTTP_HOST|REMOTE_ADDR|REMOTE_PORT|REMOTE_USER)%/handleEnv +Variable($1)/ge;
or (but be careful, it can not work in case there are other variables)
$_[0] =~ s/%([A-Z_]+)%/handleEnvVariable($1)/ge;

Alberto Simões

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://444126]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2020-10-29 14:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (271 votes). Check out past polls.

    Notices?