[24231] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 6423 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 19 15:06:48 2004

Date: Mon, 19 Apr 2004 12:06:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 19 Apr 2004     Volume: 10 Number: 6423

Today's topics:
        regex: matching lines that don't contain a certain word (Frank Skare)
    Re: regex: matching lines that don't contain a certain  <abigail@abigail.nl>
    Re: regex: matching lines that don't contain a certain  <xxala_qumsiehxx@xxyahooxx.com>
    Re: regex: matching lines that don't contain a certain  <jtc@shell.dimensional.com>
    Re: regexes <skuo@mtwhitney.nsc.com>
    Re: regexes <perl@my-header.org>
        Research project is now operational  Apr. 18, 2004 <edgrsprj@ix.netcom.com>
    Re: running multiple versions of perl <glex_nospam@qwest.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 16 Apr 2004 12:21:22 -0700
From: frankskare@yahoo.de (Frank Skare)
Subject: regex: matching lines that don't contain a certain word
Message-Id: <34ad79c5.0404161121.499331d9@posting.google.com>

Hello,
I have a source code file where I would like to
delete all lines that don't contain a certain word.
Is it possible to build a regex that match lines
that don't contain a certain word?

Thanks
Frank


------------------------------

Date: 16 Apr 2004 20:12:45 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: regex: matching lines that don't contain a certain word
Message-Id: <slrnc80fht.egl.abigail@alexandra.abigail.nl>

Frank Skare (frankskare@yahoo.de) wrote on MMMDCCCLXXXI September
MCMXCIII in <URL:news:34ad79c5.0404161121.499331d9@posting.google.com>:
--  Hello,
--  I have a source code file where I would like to
--  delete all lines that don't contain a certain word.
--  Is it possible to build a regex that match lines
--  that don't contain a certain word?


Yes, but why would you in this case? Just do:

    perl -ni -we 'print unless /word/' source_code_file


Abigail
-- 
print 74.117.115.116.32.97.110.111.116.104.101.114.
      32.80.101.114.108.32.72.97.99.107.101.114.10;


------------------------------

Date: Fri, 16 Apr 2004 23:06:07 GMT
From: "Ala Qumsieh" <xxala_qumsiehxx@xxyahooxx.com>
Subject: Re: regex: matching lines that don't contain a certain word
Message-Id: <zFZfc.23405$I%7.17200@newssvr27.news.prodigy.com>

"Abigail" <abigail@abigail.nl> wrote in message
news:slrnc80fht.egl.abigail@alexandra.abigail.nl...
> Frank Skare (frankskare@yahoo.de) wrote on MMMDCCCLXXXI September
> MCMXCIII in <URL:news:34ad79c5.0404161121.499331d9@posting.google.com>:
> --  Hello,
> --  I have a source code file where I would like to
> --  delete all lines that don't contain a certain word.
> --  Is it possible to build a regex that match lines
> --  that don't contain a certain word?
>
>
> Yes, but why would you in this case? Just do:
>
>     perl -ni -we 'print unless /word/' source_code_file

Err, maybe the double negative is throwing me off, but shouldn't that be:

    perl -ni -we 'print if /word/' source_code_file

? Or if you're using a real OS:

    grep word source_code_file > new_source_code_file

--Ala




------------------------------

Date: 16 Apr 2004 17:28:10 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: regex: matching lines that don't contain a certain word
Message-Id: <slrnc80r0a.ilb.jtc@shell.dimensional.com>

In article <zFZfc.23405$I%7.17200@newssvr27.news.prodigy.com>, Ala Qumsieh wrote:
> "Abigail" <abigail@abigail.nl> wrote in message
> news:slrnc80fht.egl.abigail@alexandra.abigail.nl...
>> Frank Skare (frankskare@yahoo.de) wrote on MMMDCCCLXXXI September
>> MCMXCIII in <URL:news:34ad79c5.0404161121.499331d9@posting.google.com>:
>> --  Hello,
>> --  I have a source code file where I would like to
>> --  delete all lines that don't contain a certain word.
>> --  Is it possible to build a regex that match lines
>> --  that don't contain a certain word?
>>
>>
>> Yes, but why would you in this case? Just do:
>>
>>     perl -ni -we 'print unless /word/' source_code_file
> 
> Err, maybe the double negative is throwing me off, but shouldn't that be:
> 
>     perl -ni -we 'print if /word/' source_code_file

Yes, the specs were (perhaps unintentionally) rather sneaky.

If he wants "word" exactly, he should change that to:

perl -ni -we 'print if /\bword\b/;' source_code_file

> 
> ? Or if you're using a real OS:
> 
>     grep word source_code_file > new_source_code_file

and, likewise, to:

grep '\<word\>' source_code_file > new_source_code_file

-- 
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]


------------------------------

Date: Fri, 16 Apr 2004 12:23:09 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: regexes
Message-Id: <Pine.GSO.4.21.0404161218420.24053-100000@mtwhitney.nsc.com>

On Fri, 16 Apr 2004, Matija Papec wrote:

> 
> If you ever come to idea making regexes more challenging, you could always
> try it in php,
> 
> my $ym = 200405;
> my($year, $month) = $ym =~ /^(\d{4})(\d{2})$/;
> 
> is "same" as,
> 
> $ym = 200405;
> preg_match("/^(\d{4})(\d{2})$/", $ym, $tmp);
> list($year, $month) = array_slice($tmp, 1);
> 
> :)
> 



IMO, regular expressions are unwieldy in any language, including Perl.

Here's a contender in Tcl:

% foreach { year month } [ lrange [ regexp -inline -- {^(\d{4})(\d{2})$} "200405" ] 1 end ] { break }

% puts $year
2004

% puts $month
05

-- 
Regards,
Steven



------------------------------

Date: Sat, 17 Apr 2004 23:28:37 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: regexes
Message-Id: <eg7380pnl787cv8ao5u0b12kdj4mmsfn1u@4ax.com>

X-Ftn-To: Steven Kuo 

Steven Kuo <skuo@mtwhitney.nsc.com> wrote:

>> preg_match("/^(\d{4})(\d{2})$/", $ym, $tmp);
>> list($year, $month) = array_slice($tmp, 1);
>> 
>> :)
>
>IMO, regular expressions are unwieldy in any language, including Perl.

It's not only the regex, but the complete path from matching to puting
things in desired places. Perl is very elegant at it, and PHP is far from
elegancy.

>Here's a contender in Tcl:
>
>% foreach { year month } [ lrange [ regexp -inline -- {^(\d{4})(\d{2})$} "200405" ] 1 end ] { break }

OMG. :)



-- 
Matija


------------------------------

Date: Sun, 18 Apr 2004 13:50:12 GMT
From: "edgrsprj" <edgrsprj@ix.netcom.com>
Subject: Research project is now operational  Apr. 18, 2004
Message-Id: <oIvgc.12236$l75.2037@newsread2.news.atl.earthlink.net>

"edgrsprj" <edgrsprj@ix.netcom.com> wrote in message
news:7rWfc.8716$l75.6417@newsread2.news.atl.earthlink.net...
> "edgrsprj" <edgrsprj@ix.netcom.com> wrote in message

April 18, 2004

This research project is now fully operational.  The last significant file
was just recently stored at the Web site:

http://www.freewebz.com/eq-forecasting/312.html  (about 1 million bytes)

That file contains data for earthquakes and earthquake type warning signals
and what are believed to be tornado type warning signals going back to
around the beginning of 1990.  Ones with the code "sub" were submitted by
people living in other parts of the world.  The goal now it to learn how to
use the Perl program to match the warning signals with the earthquakes
responsible for them and also do research on earthquake - earthquake links.
Notices regarding this project will probably be sent to scientists and other
researchers around the world starting tomorrow, Monday, April 19, 2004.




------------------------------

Date: Fri, 16 Apr 2004 10:40:10 -0500
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: running multiple versions of perl
Message-Id: <v7Tfc.252$_R.23420@news.uswest.net>

Mothra wrote:
> "Yoda Pugsley" <here@there.com> wrote in message
> news:Xns94C9A13B64BADheretherecom@65.32.1.6...
> 
>>I'm new to perl and need to write a script for work. After doing some
>>research into writing perl scripts (I'm a .net dev), I found that a lot of
>>the examples I had found did not work. After a lot of head scratching (the
>>UNIX admins are a lot of help too /sarcasm)
> 
> Those are bad admins then - I'm an Admin and I insisted that all our servers
> were upgraded to 5.8.0... but then I'm a Perl coder as well. :o)

Hopefully you have insisted that they upgrade from 5.8.0, since there 
were a lot of issues with that release. :-)


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 6423
***************************************


home help back first fref pref prev next nref lref last post