am a newbie...

V

Vinod

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
 
S

Sam Holden

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top