Hi:
I tried the following --
open(FILE2,">>c:/writeto.txt");
my @text = <FILE2>;
foreach my $a(@text)
{
print(@text);
if ($a !~ /server_lib\.files/)
{
print "not seen server_lib.files";
my $header = "[server_lib.files]";
print FILE2 "\n";
print FILE2 $header;
print FILE2 "\n";
}
else
{
print "seen server_lib.files";
}
}
apparently, i think because the file is open in append mode, i am not able
to read the file whether it contains the string or not. I also noticed that
the print(@text) does not print any contents to the console.
How i can correct this?
Thanks.
On 7/12/06, Chasecreek Systemhouse <[EMAIL PROTECTED]> wrote:
On 7/12/06, Nishi Bhonsle <[EMAIL PROTECTED]> wrote:
> Hi:
>
> I would like to check whether the string [server_bin.files] exists in a
> particular file and if it does, then do not add it again.
> How can I check for this string using perl regex?
Perl Faq 4
print "seen server_bin.files" if /server_bin\.files/;
--
WC (Bill) Jones -- http://youve-reached-the.endoftheinternet.org/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>