Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > am a newbie...

Reply
Thread Tools

am a newbie...

 
 
Vinod
Guest
Posts: n/a
 
      09-05-2003
hi!!

I am a beginner with Perl. am rtying to use the repetition feature as
in -

print 'a'x5;

would print 'aaaaa'

I am trying to use it with regular expressions.

I am trying to replace an occurence of 'there' with 'aaaaa' but I dont
want to put it there explicitly.

I am trying something like....

s/there/'a'x5/;

which doesnt work.

Can someone give me some sort of an escape sequence...?

Thank you

Vinod
 
Reply With Quote
 
 
 
 
Sam Holden
Guest
Posts: n/a
 
      09-05-2003
On 4 Sep 2003 21:38:35 -0700, Vinod <(E-Mail Removed)> wrote:
> hi!!
>
> I am trying something like....
>
> s/there/'a'x5/;
>
> which doesnt work.
>
> Can someone give me some sort of an escape sequence...?


s/there/'a'x5/e;

or:

$replace = 'a'x5;
s/there/$replace/;

The replacement is a quoted string, not an expression.

See perldoc perlop for details on what /e does.

--
Sam Holden

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments