ravi45722 has asked for the wisdom of the Perl Monks concerning the following question:
I want to replace '$' in the string. I tries s/// in so many ways. But not working properly. Finally I got this one. Is there any other simple ways to do it???
#!/usr/bin/perl use strict; use warnings; my $string = 'i am us$ing moni$ka expressi$on'; my @array = (split /\$/,$string); my $flag = 0; my $line = ""; foreach my $element (@array) { if ($flag == 0) { $line = $element; $flag =1; } else { $line = $line.'\$'.$element; } } print $line;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to replace '$' in strings
by choroba (Cardinal) on Dec 14, 2015 at 09:40 UTC | |
by Discipulus (Canon) on Dec 14, 2015 at 10:22 UTC | |
by Athanasius (Cardinal) on Dec 14, 2015 at 13:18 UTC | |
by soonix (Chancellor) on Dec 15, 2015 at 09:33 UTC | |
|
Re: How to replace '$' in strings
by johngg (Canon) on Dec 14, 2015 at 11:24 UTC |