Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regular Expression Search and parse?



 
markw writes: 

> Well, I think we have discovered a need for a "new" UNIX command line 
> utility. 

I think that what you're proposing is a little bit too specialized to 
merit its own utility.  Of course, this is just my opinion.  I write a 
*lot* of these sorts of things... 

I would have coded this thusly: 

  perl -lne 'print "some pretty formating text $1" if (/Title:*\[ISBN:\s*(\d+)\]/)' file1 file2 ... 

or, if you were using Perl 5.10 (or newer), you could name the 
backreference thusly: 

  perl -lne 'print "some pretty formating text $+{isbn_number}" if (/Title:*\[ISBN:\s*(?<isbn_number>\d+)\]/)' file1 file2 ... 

Kind regards, 

--kevin 
-- 
GnuPG ID: B280F24E              God, I loved that Pontiac. 
alumni.unh.edu!kdc                   -- Tom Waits 


-- 
This message has been scanned for viruses and 
dangerous content by MailScanner, and is 
believed to be clean. 

_______________________________________________ 
Discuss mailing list 
[hidden email] 
http://lists.blu.org/mailman/listinfo/discuss
 


BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org