J
Jay
Hello,
just getting grips with Perl and RE, but need your help.
I am trying to open a file, print its contents to a textbox, but
extract certain bits of information before outputing them to the
textbox. LAter I want to save the contents back to the same file with
the bits added back to the file. All this done without the user even
realising. The bits I want to take out (and put back) are always
located at the beginning and end of each file.
This is what I have come up with so far:
# places a specified file into the textarea to be edited
sub get_file
{
open(FILE, "< $selected_file") or die "Cannot open file\n";
while ()($thisrow = <FILE>))
{
$thisrow =~ s/\<\/textarea\>/\<\*textarea\>/;
if ($thisrow !~ m/<^TMPL_INCLUDE/)
# "<TMPL_INCLUDE" is the string to be removed
{
print $thisrow;
}
}
close FILE;
This obviously doesn't work and I was wondering if any of you guys
could shed some light to the darkness that I am experiencing.
Thanks so much!!
just getting grips with Perl and RE, but need your help.
I am trying to open a file, print its contents to a textbox, but
extract certain bits of information before outputing them to the
textbox. LAter I want to save the contents back to the same file with
the bits added back to the file. All this done without the user even
realising. The bits I want to take out (and put back) are always
located at the beginning and end of each file.
This is what I have come up with so far:
# places a specified file into the textarea to be edited
sub get_file
{
open(FILE, "< $selected_file") or die "Cannot open file\n";
while ()($thisrow = <FILE>))
{
$thisrow =~ s/\<\/textarea\>/\<\*textarea\>/;
if ($thisrow !~ m/<^TMPL_INCLUDE/)
# "<TMPL_INCLUDE" is the string to be removed
{
print $thisrow;
}
}
close FILE;
This obviously doesn't work and I was wondering if any of you guys
could shed some light to the darkness that I am experiencing.
Thanks so much!!