regular expression (made more clearer)

From: Mandar Rahurkar (rahurkar_at_uiuc.edu)
Date: 05/29/04


Date: Fri, 28 May 2004 20:52:43 -0500
To: James Edward Gray II <james@grayproductions.net>

Hi,
  I am trying to remove from file :
       1. all characters but any alphabet and numbers (i.e., file shd not contain anything
          but "alphabets and numbers" that means NO punctuation etc...
       2. all trailing spaces should be made to one space.
  
  following code doesnt seem to work for objective [1] mentioned above. Can anyone please point whats wrong with the
second line and what changes should I make ?

Thanks,
Mandar

---
open(fp,$file) or die "Cant open $file :$!\n";
@cont=<fp>;
for(@cont) { 
 tr/A-Z/a-z/;             # converts all uppercase to lowercase   
 s/^[a-z0-9]+/ /;         # substitute all non alphabets and numbers by space
 s/\s+/ /g;               # removes trailing spaces
}   
--- 
-------------------
Mandar Rahurkar
ECE,   UIUC
-------------------


Relevant Pages

  • Re: Document Management System / Versioning system
    ... > Gegen der Dummheit kämpfen die Götter selbst vergebens. ... >> So, whats new ?? ...
    (microsoft.public.word.docmanagement)
  • Re: SuSE 9.2 Pro FTP Download...
    ... whats the FTP install version? ... > the pro version, just without support/manuals, or is it the personal ... How do you ask a man to be the last man to die in Iraq? ...
    (alt.os.linux.suse)
  • Re: Why airplanes taxi
    ... come on live a little, push that envelope, you only live once. ... die wondering ... Whats the worst thing that could happen? ...
    (rec.aviation.piloting)
  • Re: weird coincidences?
    ... Put a line monitor on for a week to see whats up. ... Honestly I thinjk its just bad luck and things do die all the time. ...
    (alt.home.repair)