Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > What is the use of s { } { }

Reply
Thread Tools

What is the use of s { } { }

 
 
Subra
Guest
Posts: n/a
 
      12-04-2007
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...
 
Reply With Quote
 
 
 
 
dilbert1999@gmail.com
Guest
Posts: n/a
 
      12-04-2007
On Dec 4, 3:16 pm, Subra <(E-Mail Removed)> wrote:
> 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
 
Reply With Quote
 
 
 
 
xhoster@gmail.com
Guest
Posts: n/a
 
      12-04-2007
Subra <(E-Mail Removed)> wrote:
> 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.
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      12-04-2007
Subra wrote:
> 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




 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Could not use ''; file already in use. M K ASP .Net 11 04-09-2008 11:35 AM
where to use CPLD & where to use FPGA? kulkarku@math.net VHDL 6 03-06-2006 07:27 AM
How do I know when to use the Viewstate and when to use the posted data? :-) Simon ASP .Net 1 11-09-2004 02:32 AM
Can I use XPath or something to a remote Mac or Linux box and just query an xml file, not using web services and use encyrption? jake ASP .Net 0 07-06-2004 02:16 PM
Cannot use the profile "default" because it is in use, not. please.post@yur.re.ply Firefox 1 07-04-2004 03:41 AM



Advertisments