kirk123 has asked for the wisdom of the Perl Monks concerning the following question:

Hi:

How do you write multiple substitution of the same line:

$line =~ s/(.*)elm(.*)/$concat/ig; $line =~ s/^/\/h\/COE\/Comp\/CDS\/bin\/cdsadmin -c -O \"/g ;

I know in Unix you use the "-e" as in sed "s/sds/sds" -e "s/wrwe/xsd/" -e ....

---kirk
Edit by myocom: Reformatted

Replies are listed 'Best First'.
•Re: Does Perl have something like the "-e " option of sed in unix
by merlyn (Sage) on Aug 16, 2002 at 21:56 UTC
Re: Does Perl have something like the "-e " option of sed in unix
by BrowserUk (Patriarch) on Aug 16, 2002 at 22:08 UTC

    Could be wrong, but I think what your looking for is

    perl -pi -e"s/this/that/" -e"s/something/somethingelse/" infile >outfi +le

    See perlrun for more info...


    What's this about a "crooked mitre"? I'm good at woodwork!
Re: Does Perl have something like the "-e " option of sed in unix
by runrig (Abbot) on Aug 16, 2002 at 22:17 UTC
    I know in Unix you use the "-e" as in sed "s/sds/sds" -e "s/wrwe/xsd/" -e ....

    If you just want to do sed in perl:

    s2p <<EOT s/sds/sds/ s/wrwe/xsd/ EOT
Re: Does Perl have something like the "-e " option of sed in unix
by dpuu (Chaplain) on Aug 16, 2002 at 22:01 UTC
    you could try:
    $a = "12345678\n"; for ($a) {s/1/a/; s/4/b/; s/7/c/} print $a;
    --Dave