Ask a Question related to PERL Miscellaneous, Design and Development.
-
Julia deSilva #1
Result from a regex substitute
Hi there all,
I sure this is really obvious but what's the syntax for this please:
my $string1 = "mark had a little dog";
$string1 =~ s/dog/lamb/g; # $string1 is "mary had a little lamb"
But ................
my $string1 = "mark had a little dog";
my $string2 = $string1 =~ s/dog/lamb/g;
This returns
$string2 = 1 (presumably a boolean for substitute done)
whereas I want it to return $string2 = "mary had a little lamb";
Thanks in advance
Julia deSilva Guest
-
Flash as a DRM substitute
I'd like to be able to stream audio to end users, but do not want those users to be able to play back songs outside of the streaming. If I'm using... -
Substitute a color in an EPS
Hi, I must edit an EPS to change the color of the shapes. Since it's an EPS, I cannot edit each shape separately (moreover, it's a vectorized... -
Substitute for mod function
Hi all! I need to find a substitute for the mod function which can be found in vbscript and so on. Example: for i = 0 to 100 if (i mod... -
Using More Than 1 Substitute ?
I have a mess of text in 1 field. 140$042$024$104 etc ... I want to have 1 calc field that fixes all of it with a key. Substitute (text,... -
Need substitute for SSI GLOBAL
Hello, I'm trying to port a website from GoServer to IIS 5.1 and it makes a lot of use of SSI. Under GoServer I could set GLOBAL variables,... -
Tassilo v. Parseval #2
Re: Result from a regex substitute
Also sprach Julia deSilva:
Yes, it returns the number of replacements done. You need to add> I sure this is really obvious but what's the syntax for this please:
>
> my $string1 = "mark had a little dog";
> $string1 =~ s/dog/lamb/g; # $string1 is "mary had a little lamb"
>
>
> But ................
> my $string1 = "mark had a little dog";
> my $string2 = $string1 =~ s/dog/lamb/g;
> This returns
> $string2 = 1 (presumably a boolean for substitute done)
parens:
(my $string2 = $string1) =~ s/dog/lamb/g;
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus}) !JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexi ixesixeseg;y~\n~~dddd;eval
Tassilo v. Parseval Guest
-
Chris #3
Re: Result from a regex substitute
Julia deSilva wrote:
If you want to keep the $string1 to remain as "mark had a little dog"> Hi there all,
>
> I sure this is really obvious but what's the syntax for this please:
>
> my $string1 = "mark had a little dog";
> $string1 =~ s/dog/lamb/g; # $string1 is "mary had a little lamb"
>
>
> But ................
> my $string1 = "mark had a little dog";
> my $string2 = $string1 =~ s/dog/lamb/g;
> This returns
> $string2 = 1 (presumably a boolean for substitute done)
> whereas I want it to return $string2 = "mary had a little lamb";
and have $string2 be the changed string do this:
my string1 = my string2 = "mark had a little dog";
$string2 =~ s/dog/lamb/g;
BTW This substitution won't ever give "mary had a little lamb" it will
give you "mark had a little lamb".
Chris Guest
-
Tad McClellan #4
Re: Result from a regex substitute
Chris <no_thanks@bms.umist.ac.uk> wrote:
^^ ^^> my string1 = my string2 = "mark had a little dog";
Perl variables require a funny character (sigil) before their names.
--
Tad McClellan SGML consulting
[email]tadmc@augustmail.com[/email] Perl programming
Fort Worth, Texas
Tad McClellan Guest
-
John Strauss #5
Re: Result from a regex substitute
On Tue, 29 Jul 2003 12:33:56 +0100
"Julia deSilva" <jds@trumpetweb.co.uk> wrote:(my $string2 = $string1) =~ s/dog/lamb/g;>
> Hi there all,
>
> I sure this is really obvious but what's the syntax for this please:
>
> my $string1 = "mark had a little dog";
> $string1 =~ s/dog/lamb/g; # $string1 is "mary had a little lamb"
>
>
> But ................
> my $string1 = "mark had a little dog";
> my $string2 = $string1 =~ s/dog/lamb/g;
> This returns
> $string2 = 1 (presumably a boolean for substitute done)
> whereas I want it to return $string2 = "mary had a little lamb";
>
> Thanks in advance
>
>
>
unless you really want to change "mark" to "mary":
my %lut=qw/mark mary dog lamb/;
(my $string2 = $string1) =~ s/(mark|dog)/$lut{$1}/g;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drop the .thetenant to get me via mail
John Strauss Guest
-
Julia deSilva #6
Re: Result from a regex substitute
Thanks everyone,
Sorry, I did get my nursery rhyme wrong, and for YOUR information, I live 2> my $string1 = "mark had a little dog";
miles from Kilmersdon, the village where Jack and Jill fell down the hill,
but that's another story.....
Julia deSilva Guest



Reply With Quote

