Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: replacing equal to operator

by Fletch (Chancellor)
on Jan 28, 2021 at 18:44 UTC ( #11127587=note: print w/replies, xml ) Need Help??


in reply to replacing equal to operator

You're overcomplicating things perhaps . . .

$ perl -E '$_=qq{parameter=TO_DATE('1900-01-01','YYYY-MM-DD')\n};print + qq{Before: $_};s{=(.*)$}{="$1"};print qq{ After: $_}' Before: parameter=TO_DATE(1900-01-01,YYYY-MM-DD) After: parameter="TO_DATE(1900-01-01,YYYY-MM-DD)"

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^2: replacing equal to operator
by hippo (Chancellor) on Jan 28, 2021 at 19:01 UTC

    I came up with the same approach but you don't even need that $ because the dot doesn't match the newline by default.

    use strict; use warnings; use Test::More tests => 1; my $have = qq#parameter=TO_DATE('1900-01-01','YYYY-MM-DD')\n#; my $want = qq#parameter="TO_DATE('1900-01-01','YYYY-MM-DD')"\n#; $have =~ s/=(.*)/="$1"/; is $have, $want;

    🦛

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2021-04-18 18:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?