Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

equivalent in perl

Balaji N
Honored Contributor

equivalent in perl

gurus,

what is the equivalent of this in perl

sed '1s/blablabla/bla/' file.txt

basically i want to the reg exp substitution to happen on specific lines and not on all.

tia
-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.
2 REPLIES
Steven E. Protter
Exalted Contributor

Re: equivalent in perl

This is how I did it:

$commandline - "sed /s/tzfat/hebron/g $filename";

system("$commandline");

I know, cheating, cheating ...

This stuff is discussedin O'reilly's Perl Cookbook Chapter 6 Pattern matching.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Balaji N
Honored Contributor

Re: equivalent in perl

perl -pi -e '1 .. s/blablabla/bla' file.txt

thanks SEP for pointing the right resource.

-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.