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

Re^3: Dereferencing in blessed object

by hippo (Bishop)
on Feb 27, 2021 at 22:44 UTC ( [id://11128891]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Dereferencing in blessed object
in thread Dereferencing in blessed object

Use braces:

$db =~ s/_.+?_/_${dbname}_/;

🦛

Replies are listed 'Best First'.
Re^4: Dereferencing in blessed object
by choroba (Cardinal) on Feb 28, 2021 at 22:14 UTC
    Or, use a backslash, because TIMTOWTDI:
    $db =~ s/_.+?_/_$dbname\_/;
    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re^4: Dereferencing in blessed object
by Bod (Parson) on Feb 27, 2021 at 22:51 UTC
    Use braces:

    That was my first thought - but I tried it and it didn't work...
    So...plenty of use of Ctrl+Z and I realised what I did wrong!

    $db =~ s/_.+?_/_{$dbname}_/;

    Not quite the same!
    Thanks hippo

      but I tried it and it didn't work

      Sure it does:

      use strict; use warnings; use Test::More tests => 1; my $db = 'a_foo_b'; my $dbname = 'bar'; $db =~ s/_.+?_/_${dbname}_/; is $db, 'a_bar_b';

      Update: I see from your reply that you had already figured that out. Apologies!


      🦛

        It didn't work for me...because of my typo when I tested it...
        I put the $ inside the braces :(

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-20 14:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found