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

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

Replies are listed 'Best First'.
Re^5: Dereferencing in blessed object
by hippo (Archbishop) on Feb 28, 2021 at 10:45 UTC
    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 :(