Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: How to replace spaces with different chars?

by LanX (Saint)
on Jul 06, 2022 at 15:33 UTC ( [id://11145310]=note: print w/replies, xml ) Need Help??


in reply to How to replace spaces with different chars?

here a partial solution using glob

But I don't know how to escape the "," appropriately ...°

use v5.12; use warnings; use Data::Dump qw/pp dd/; my $globber = join ",", (":", ";", "=", "-"); for my $line (<DATA>) { chomp $line; say "--- $line"; $line =~ s/\s/{$globber}/g; say pp [ glob($line) ]; } __DATA__ /a/b/c/d/e/fi le /a/b/c/d/e/fi l e /a/b/c/d/e/f i l e /a/b/c/d/e/f i l e

output

°) one workaround may be to use a placeholder like "\0" which can't naturally appear and to replace it afterwards.

update

the whole concept is dubious, because this will create far too many combinations. (Besides solving the original issue) it's better to check incrementally from left to right with wildcards, before progressing to the next position.

my @part = </a/b/c/d/e/f{;,:,=,-}i*>;

etc

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://11145310]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found