Thursday - August 12, 2004
a blogging break

I probably won’t be blogging from now until the end of next week. I’ll post an entry or two if I manage to get internet access, but it’s very likely there won’t be any where I’ll be.







handy perl script

If you want to search and replace text among lots of files, Perl can make your life a lot simpler. Here is a script to replace the string ‘old_text’ with ‘new_text’ in any file ending with .txt. The script would have to be run from the same directory as the files which have the text you want replaced.

#!/usr/bin/perl

@files = <*.txt>;

foreach $file ( @files )
{
    system( "perl -p -i -e 's/old_text/new_text/g' $file" );
}

In order to use this code, copy it to a file and save it, then run the following command on the file.

chmod 755 <filename>






# of readers
- home
meta
comics
news links
other links

about me
blog archives
docs
entertainment
experiences
funny lists
humor
intellectual
interests
mefi
music
opinions
photos
web designs
tools
webmaster help

Sign up
Enter your e-mail address to be notified of new posts



Search blog archives

Calendar
August 2004
S M T W T F S
« Jul   Sep »
1234567
891011121314
15161718192021
22232425262728
293031  



Random quote
(View all quotes)
"A turtle makes progress when it sticks its neck out."










Licensed under Creative Commons
(?) Choose theme:  X X X X X X


Loaded in 0.1678 seconds