that worked.

Now I wanted to replace any white space with a single space.

I used this command

perl -pi.bak -w -e "s/\s+/ /g" map.bat

That worked correctly but it removed all of my new lines.

Why should I use tr instead?

> -----Original Message-----
> From: Bob Showalter [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, January 10, 2003 11:53 AM
> To: 'Paul Kraus'; Perl
> Subject: RE: one liner replace / with \
> 
> 
> Paul Kraus wrote:
> > I want to replace all forward slashes with back slashes is a file. 
> > Using a one liner I tried
> > 
> > perl -I -i.bak -w -e 's!/!\\!g' map.bat
> 
> 1) You don't need -I
> 
> 2) You do need -p
> 
> 3) You probably need to use double-quotes instead of single, 
> due to Windows shell brain damage.
> 
> 4) tr/// is an alternate to s///g you might consider:
> 
>    perl -pi.bak -e "tr./.\\." map.bat
> 
> > 
> > I get this error
> > useless use of a constant in void context at -e line 1.
> 
> I think this is because Windows is passing the single quotes 
> along to Perl, so it sees a single-quoted literal instead of 
> a substitution operator.
> 
> > 
> > this is on a windows xp machine.
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to