#! /usr/bin/perl
use warnings;
use strict;
use diagnostics;
####
use warnings;
use strict;
my $filename = 'notepad |';
open( my $FH, $filename ) or die "Can't open '$filename': $!\n";
####
use warnings;
use strict;
my $filename = 'notepad |';
open( my $FH, "<", $filename ) or die $!;
####
my $filename = 'notepad |';
unless( -f $filename ) {
die "Error: file '$filename' is not existing\n";
} # unless
####
#! /usr/bin/perl
use warnings;
use strict;
use diagnostics;
print "Enter filename to open (text only):\n\n";
my $infile = ;
chomp $infile;
unless( -f $infile ) {
die "Error: file '$infile' is not existing\n";
}
open( my $INFILE, '<', $infile )
or die "Error: can't open '$infile' for reading: $!\n";
print "Enter filename to SAVE text file as:\n\n";
my $outfile = ;
chomp $outfile;
open( my $OUTFILE, '>', $outfile )
or die "Error: can't open '$outfile' for reading: $!\n";
print qq~Enter string to replace "and" with\n\n~;
my $word = ; chomp $word;
print "\n" x 3;
my $count = 0;
while( <$INFILE> ) {
$count += s/
\band\b
/$word/gix;
print $OUTFILE $_;
} # while
close $INFILE
or die "Error: can't close '$infile' for reading: $!\n";
close $OUTFILE
or die "Error: can't close '$outfile' for writing: $!\n";
print qq~There were $count instances of "and" in '$infile'\n";