Mailing List ArchiveSupport open source code!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: REGEXP in perl questiion
- To: tlug@example.com
- Subject: Re: REGEXP in perl questiion
- From: Matt Doughty <mdoughty@example.com>
- Date: Wed, 23 May 2001 18:08:27 +0900
- Content-Disposition: inline
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=us-ascii
- In-Reply-To: <F91J6pkNzPZrIkyPzGN0001064b@example.com>; from jean_christian@example.com on Wed, May 23, 2001 at 08:44:31AM -0000
- References: <F91J6pkNzPZrIkyPzGN0001064b@example.com>
- Reply-To: tlug@example.com
- Resent-From: tlug@example.com
- Resent-Message-ID: <c-3vLB.A.8x.S43C7@example.com>
- Resent-Sender: tlug-request@example.com
- User-Agent: Mutt/1.2.4i-jp0
On Wed, May 23, 2001 at 08:44:31AM -0000, Jean-Christian Imbeault wrote: > Ok, I admint it's lazy but could someone give me a regular expression in > Perl that would do the following? (I've tried for the last hour but I'm not > very good at regular expressions it seems). > > I have strings like the following: > > Subject: Cron <root@example.com> /root/AdminScripts/NSH.sh > Subject: Cron <root@example.com> /usr/bin/rsync -avzr --delete > /home/httpd/html/top40/* 10.0.1.53:/home/httpd/html/ > > I want to extract the name of the program that cron started, without the > switches if any. > > I've tried this but it's greedy and doesn't extarct *just* the prog name but > also the switches ... I tought the " .*?" would cause lazy expansion but > it's not working as I had hoped. > > if ( $_ =~ /^Subject: /) { > if ($_ =~ "Cron") { > $CRON_EMAIL = 1; #after some thought it occured to me this is better done with split #because the format is regular: #strip leading spaces s/^\s*//; #first split breaks it up based on whitespace #the second based on /'s $PROGNAME = (split(/\//, (split(/\s+/))[3]))[-1]; > print "The program called by cron was $PROGNAME\n"; > } > } > > _________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > ----------------------------------------------------------------------- > Next Technical Meeting: Sat, May 12 13:30- > Next Nomikai Meeting: Fri, June (TBA) 19:30- Tengu Tokyo Eki Mae > ----------------------------------------------------------------------- > more info: http://www.tlug.gr.jp Sponsor: Global Online Japan
- References:
- REGEXP in perl questiion
- From: "Jean-Christian Imbeault" <jean_christian@example.com>
Home | Main Index | Thread Index
- Prev by Date: Re: 'atd' suddenly failing to start
- Next by Date: Re: Doh!
- Prev by thread: Re: REGEXP in perl questiion
- Next by thread: Re: REGEXP in perl questiion
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links