Re: perl string substitution



In article <woCdnWOfy9AzqvXYRVnyvw@xxxxxxxxxxxxxx>,
"John" <john1949@xxxxxxxxx> wrote:

Hi

In string substiution can those two patterns be strings, such as

my ($a,$b,$c);
$a="some string"; $b="another string";
$c =~ s/$a/$b/g;

Thanks
John

Yes. You can easily try this for yourself. Start up the perl debugger
with perl -de1. Here is a session I did to test your question:
DB<1> $a = 'this'

DB<2> $b = 'that'

DB<3> $c = 'this is a string'

DB<4> $c =~ s/$a/$b/g

DB<5> print $c
that is a string
DB<6>

Boyd
.



Relevant Pages

  • Debugger aliases do not work
    ... I have tried to use aliases in the Perl debugger. ... I included a debug module I wrote and set an alias for invoking it: ... String found where operator expected at (eval ...
    (comp.lang.perl.misc)
  • Re: perl string substitution
    ... In string substiution can those two patterns be strings, ... Start up the perl debugger ...
    (perl.beginners)
  • Re: perl string substitution
    ... backslah before the $. ... In string substiution can those two patterns be strings, ... Start up the perl debugger ... Boyd ...
    (perl.beginners)
  • Re: Writing a "substring"/"replace substring" function in ksh88
    ... print characters from within a string given a range. ... ?- Optionally matches any one of the given patterns. ... *- Matches zero or more occurrences of the given ... I thought if I wanted to replace character 2 of a 20- ...
    (comp.unix.shell)
  • Re: FindFirstFile, how much faster than FindNextFile?
    ... Next, you say you want an arbitrary substring of the filename, but that's not what your ... But the whole notion that you would hand-code 50 unique patterns is remarkably silly. ... I knew that you got them from FindFirstFile. ... C++ standard library, the string type. ...
    (microsoft.public.vc.mfc)