On Sat, Aug 2, 2008 at 3:12 AM, David Allender <[EMAIL PROTECTED]> wrote:
> Hello all, > > I've been trying multiple different ways, but I am still unable to > have the output that i am looking for. > > What I'm trying to do is change certain text in an html file. How > would i go about doing that successfully? > > what i know is that > you call open such as open(HTML, /path); > and from there use the s/// operator, but I really cant get anything > to change in my files. > > the string I would like to search for would be something like > "value=src1" (without quotes) and i would want to replace it with > something like "/home/user/test/" (without quotes) > > Any help is appreciated. Thanks > > -David > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > http://learn.perl.org/ > > > Hi Try this code fragment (have not run it though) :- #/usr/bin/perl use warnings; use strict; open (HTMLFILE, "</tmp/test.html") or die 'Can't open HTML FILE /tmp/test.html : $!\n\n"; open (HTMLFILE1, ">/tmp/test1.html") or die 'Can't create HTML FILE /tmp/test1.html : $!\n\n"; my $str; while (chomp($str = <HTMLFILE>)) { $str =~ s/value=src/\/home\/usr\/test\//g; print HTMLFILE1 "$str\n"; } close (HTMLFILE1); close (HTMLFILE); Regards, Amit Saxena