What is the use of s { } { }

S

Subra

Hi,

Can any one tell me, whats does the "s { } { }" operator used for in
the below code ?

next unless s{^(\s*\w+\s+$stat_pid\s+(\d+)\s+)\d+\s+.*$pattern$}
{$1};

this is used to search for a existence of the process through ps -ef.

Best Regards,
Subra...
 
D

dilbert1999

Can any one tell me, whats does the "s { } { }" operator used for

see perldoc perlop, section "Regexp Quote-Like Operators", s/PATTERN/
REPLACEMENT/msixpogce
in the below code ?

next unless s{^(\s*\w+\s+$stat_pid\s+(\d+)\s+)\d+\s+.*$pattern$}
{$1};

see perldoc perlre
 
X

xhoster

Subra said:
Hi,

Can any one tell me, whats does the "s { } { }" operator used for in
the below code ?

It is the same thing as the much more common "s///", just with different
delimiters.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
 
J

Jürgen Exner

Subra said:
Can any one tell me, whats does the "s { } { }" operator used for in
the below code ?

next unless s{^(\s*\w+\s+$stat_pid\s+(\d+)\s+)\d+\s+.*$pattern$}
{$1};

It is substitution whatever was matched by the RE
^(\s*\w+\s+$stat_pid\s+(\d+)\s+)\d+\s+.*$pattern$
with the actual text that was matched by
(\s*\w+\s+$stat_pid\s+(\d+)\s+)

In short: it is removing some trailing text.

jue
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top