Hi,
I'm new to perl and haven't yet figured out how to rewrite an existing file. I have a text book that came with dozens of example scripts all pointing to /usr/bin/perl.
The path on our unix machine is /opt/local/bin/perl/bin.
I would like to create a script that changes the path, posted in the beginning of each script, from the existing path to the correct path (rewriting to the same/new filename). The alternative (ugh!?) is editting each one till I can find that chapter - unlikely!
I created a command
s/#!\/usr\/bin\/perl/\/#!\/opt\/local\/perl\/bin\/perl/
that will perform the substitution (looks just like sed).
I have also been able to read/echo multiple perl (*.pl) files passed from the command line but am unclear on how to edit and rewrite each line ($ln) and file. These files, as they were supplied, reside in multiple subdirectories (e.g., ch01, ch02,...). I would like the change to traverse these 'ch'apter subdirectories if possible.
Thanks for listening... [sig][/sig]
I'm new to perl and haven't yet figured out how to rewrite an existing file. I have a text book that came with dozens of example scripts all pointing to /usr/bin/perl.
The path on our unix machine is /opt/local/bin/perl/bin.
I would like to create a script that changes the path, posted in the beginning of each script, from the existing path to the correct path (rewriting to the same/new filename). The alternative (ugh!?) is editting each one till I can find that chapter - unlikely!
I created a command
s/#!\/usr\/bin\/perl/\/#!\/opt\/local\/perl\/bin\/perl/
that will perform the substitution (looks just like sed).
I have also been able to read/echo multiple perl (*.pl) files passed from the command line but am unclear on how to edit and rewrite each line ($ln) and file. These files, as they were supplied, reside in multiple subdirectories (e.g., ch01, ch02,...). I would like the change to traverse these 'ch'apter subdirectories if possible.
Thanks for listening... [sig][/sig]