Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^3: Replacing string with regexp without using modules

by almut (Canon)
on Aug 06, 2008 at 01:58 UTC ( #702537=note: print w/replies, xml ) Need Help??

in reply to Re^2: Replacing string with regexp without using modules
in thread Replacing string with regexp without using modules

Could it be the hash reference ...?

Yes, in pc88mxer's code, $hash is a hash reference, so it must be dereferenced. In your case, it's a normal hash.  So either don't dereference

$hash{a} = "go"; $string =~ s{\$(\w+)}{$hash{$1}}ge;

or create a reference

$hash->{a} = "go"; $string =~ s{\$(\w+)}{$$hash{$1}}ge;

or even use the normal arrow syntax in both the assignment $hash->{a} = ..., and when you access it $hash->{$1}:

$hash->{a} = "go"; $string =~ s{\$(\w+)}{$hash->{$1}}ge;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://702537]
[ovedpo15]: can't I use just use lib $FindBin::Bin/../ bin" asuming that p2 is in ./bin and p1 is in /config? it says "cant find" altought p2 is
[moritz]: ovedpo15 "use lib" is only for .pm files
[moritz]: if you don't have .pm file, you might to use "require" or "do" with an absolute path
[ovedpo15]: I need to use FindBin thought. does FindBin finds only modules? or it can find perl script also?
[moritz]: maybe you should start looking at the documentation of FindBin?

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2018-03-17 20:47 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (226 votes). Check out past polls.