CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions: Re: [cynick] how do I use $1 in a $var for subsitutions: Edit Log



vikas.deep
User

May 19, 2009, 9:31 PM


Views: 9085
Re: [cynick] how do I use $1 in a $var for subsitutions

Check -out the following

Code
#! /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

Code
[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)


Edit Log:
Post edited by vikas.deep (User) on May 19, 2009, 9:32 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives