[comp.lang.perl] Changing back slashes to forward slashes

merlyn@iwarp.intel.com (Randal Schwartz) (08/17/90)

In article <1990Aug16.194644.14376@athena.mit.edu>, ramon@skye (Ramon F Herrera) writes:
| 
| I have a question for those {sed, grep, awk, tr} wizards out there.
| I'd like to change all the occurrences in a file of a line like this:
| 
| #include "dira\dirb\incl.h"
| 
| to 
| 
| #include "dira/dirb/incl.h"
| 
| but only for the lines that begin with "#include".

perl -pi~ -e 's#\\#/#g if /^#include/' file1.c file2.c file3.c ...

Pretty darn simple with Perl.  Even leaves you a backup.

Just another Perl hacker,
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/