Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^6: What is the meaning of this line in Perl on linux?

by Anonymous Monk
on Mar 28, 2022 at 08:49 UTC ( [id://11142455]=note: print w/replies, xml ) Need Help??


in reply to Re^5: What is the meaning of this line in Perl on linux?
in thread What is the meaning of this line in Perl on linux?

In my post that is for changing the forward slash to backward slash. Now i am asking fo changing the backward slash to forward slash.

Replies are listed 'Best First'.
Re^7: What is the meaning of this line in Perl on linux?
by Corion (Patriarch) on Mar 28, 2022 at 09:02 UTC

    Then you need to swap the part that is searched with the part that is replaced.

    Currently, as haukex already explained, you have:

    # delimiters # | | | # v v v $localdir =~ s/\//\\/g; # ^^ ^^ # | | # search part replacement

    So, if you swap search part and replacement, you get:

    # delimiters # | | | # v v v $localdir =~ s/\\/\//g; # ^^ ^^ # | | # search part replacement

    The above gets much clearer if you use another delimiter instead of s///g, for example, s{}{}g. Then your original line is

    # delimiters # | || | # v vv v $localdir =~ s{/}{\\}g; # ^ ^^ # | | # search part replacement

    With the swap of search part and replacement part, that becomes:

    <c> # delimiters # | || | # v vv v $localdir =~ s{\\}{/}g; # ^^ ^ # | | # search part replacement

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-03-28 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found