regular expression

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


Date: Fri, 28 May 2004 20:31:32 -0500
To: beginners <beginners@perl.org>

Hi,
   I am trying to remove from file :
        1. all characters but any alphabet and numbers.
        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 out why ?

Thanks,
Mandar

---
open(fp,$file) or die "Cant open $file :$!\n"; 
@cont=<fp>; 
$cnt=@cont;
for(@cont) {
  tr/A-Z/a-z/;
  s/^[a-z0-9]/ /;
  s/\s+/ /g; 
}   
---
-------------------
Mandar Rahurkar
ECE,   UIUC
-------------------