in reply to Delete "/" in a string

And .. just in case you need yet another, slightly different way ..
my ($ip,$interface) = qw(192.168.1.1 POS1/0/0); (my $filename = "$ip--$interface.txt")=~tr{/}{}d; # $filename now contains '192.168.1.1--POS100.txt"
The "tr" operator is slightly more efficient than the s//, and serves the purpose well in this case.

The "d" option at the end of the operator "d"elete's the un-substituted character ("/") in this case.

Update: Another advantage of this approach is that it is non-destructive: The content of $interface is not changed - this is not the case with the previous 2 posts first post.

        "You're only given one little spark of madness. You mustn't lose it."         - Robin Williams

Replies are listed 'Best First'.
Re^2: Delete "/" in a string
by Laurent_R (Canon) on Oct 23, 2014 at 06:46 UTC
    The "tr" operator is slightly more efficient than the s//, and serves the purpose well in this case.

    Although it probably does not make a big difference in this case, the tr/// operator can be considerably more efficient than s///.

Re^2: Delete "/" in a string
by AnomalousMonk (Archbishop) on Oct 23, 2014 at 05:32 UTC
    ... advantage ... it is non-destructive ... the previous 2 posts.

    But Loops uses  /r above. (Update: Oops — already noted!)