Try this...
#!c:/perl/bin/perl -w
use strict;
my $file = 'old_websites.txt';
my $outfile = 'old_web2.txt';
open(INFO, "$file") or die "$!"; # file open w/error check
open(RESULT, ">$outfile"); # tried "$outfile" as well...
while (<INFO>){
print RESULT $_ unless grep {/_vti_cnf/} $_;
}
close INFO;
close RESULT;
Hope this works for ya..
Patrick
> -----Original Message-----
> From: McCormick, Rob E [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 30, 2001 5:01 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: open file, find lines and print to a second file....
>
>
>
> thanks Dan (and Patrick and Richard)
>
> I did try the:
>
> open(RESULT, ">$outfile") or die "$!"; # it does run, but nothing written
> to file?
>
> I also tried shifting the open to after the while loop:
>
> while (<INFO>) {
> print RESULT;
> }
> open(RESULT, ">$outfile") or die "$!"; # runs, but nothing
> written to file?
>
> My $outfile time stamp is changing, but I don't think data is making it to
> the $outfile.
>
> Rob
> --
>
> > -----Original Message-----
> > From: Dan Brown [SMTP:[EMAIL PROTECTED]]
> > Sent: Monday, April 30, 2001 5:45 PM
> > To: McCormick, Rob E
> > Cc: '[EMAIL PROTECTED]'
> > Subject: Re: open file, find lines and print to a second file....
> >
> > I'm not sure what you mean by your last question (what pattern do you
> > use when the output file...).
> >
> > The error is due to the fact that outside of quotes the > is an operator
> > (greater than). Try
> >
> > open( RESULT, ">$outfile" ) or die "$!";
> >
> > With the single greater than ">" the output file will be created. If it
> > existed before running the script, the contents of this file will be
> > erased.
> >
> > With the double greater than ">>" the output file will be created. If
> > it existed before running the script, the contents of this file will
> > remain and the new information will be appened to the file.
> >
> > Hope this helps.
> >
> > Dan
> >
> >
> > "McCormick, Rob E" wrote:
> > >
> > > gang,
> > >
> > > # problem: open a file
> > > # find lines that meet a condition, put them in an output file
> > >
> > > Could you share some patterns/sample code that you use to accomplish
> > this
> > > task? What pattern do you use when the output file doesn't exist when
> > the
> > > script begins?
> > >
> > > The code below errors with:
> > > C:\WINNT\Profiles\rem27920\Desktop\perl>remove_lines.pl
> > > syntax error at
> C:\WINNT\Profiles\rem\Desktop\perl\remove_lines.pl line
> > 7,
> > > near ", >"
> > > Execution of
> C:\WINNT\Profiles\rem\Desktop\perl\remove_lines.pl aborted
> > due
> > > to compilation
> > > errors.
> > >
> > > #!c:/perl/bin/perl -w
> > > use strict;
> > >
> > > my $file = 'c:/winnt/profiles/rem/desktop/old_websites.txt';
> > > my $outfile = 'c:/winnt/profiles/rem/desktop/old_web2.txt';
> > > open(INFO, "$file") or die "$!"; # file open w/error check
> > > open(RESULT, >$outfile); # tried "$outfile" as well...
> > > my @lines = grep { ! /_vti_cnf/ } <INFO>;
> > > while (<INFO>) {
> > > print RESULT;
> > > }
> > >
> > > #print (@lines, $outfile ); # prints lines to STDOUT, and
> the filename
> > > # print (join "\n", @lines); # print files, one per line
> > >
> > > close INFO;
> > > close RESULT;
> > >
> > > thank you,
> > > Rob
> > > --
> > > Rob McCormick
> > > [EMAIL PROTECTED]
>