
vikas.deep
User
May 19, 2009, 9:31 PM
Views: 4089
|
|
Re: [cynick] how do I use $1 in a $var for subsitutions
|
|
|
Check -out the following
#! /usr/bin/perl -w use strict; my $d = "hello 123 world 456!"; my $b = "hello"; my $c = "bye"; $d =~ s/^hello 123 (world 456)/$c $1 123/; print "$d\n"; The out put is
[root@localhost Documents]# perl prog.pl bye world 456 123! -For all my suggestions " I am sure someone else can do it in a better or elegant manner!"
(This post was edited by vikas.deep on May 19, 2009, 9:32 PM)
|