Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^4: Replacing substrings with links

by choroba (Cardinal)
on Feb 06, 2022 at 17:20 UTC ( [id://11141170]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Replacing substrings with links
in thread Replacing substrings with links

I tested my previous code with
my $h_orig = { '/a/b/c/dt/data/SUSE/tool/0.9.0' => '/a/b/c/dt/tools/SUSE/tool/0.9 +.0', '/nfs/us/tools/SUSE' => '/usr/bin', '/a/b/c' => '/p', '/p/dt' => '/nfs/us'};

Your code gives the same result for the input.

Update: Ordering is important. I have no idea what the expected output of

my $h_orig = { '/a' => '/b/c', '/b/c' => '/a', };
is.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^5: Replacing substrings with links (updated)
by LanX (Saint) on Feb 06, 2022 at 17:23 UTC
    I think the results with this test case really depend on the randomization of the hash.

    (testing with hash order is tricky, I wonder if there is a general solution for that)

    update

    tho /p/dt is not a "absolute path" if /p is a link. 🤷🏽

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2024-03-28 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found