Re: Can't print to file

2005-12-07 Thread David Sudjiman
On Tue, 6 Dec 2005, John W. Krahn wrote: > Because the null filehandle inside the readline operator ( <> ) has special > magic which works together with the @ARGV array and the $^I scalar but does > not work with ordinary filehandles. > > See the "I/O Operators" section of perlop.pod for an explan

Can't print to file

2005-12-06 Thread David Sudjiman
This is my script. === #!/usr/bin/perl # ex9-2b.pl use strict; use warnings; my ($filename) = @ARGV; open FILE, $filename or die "Can't open $filename : $!"; $^I = ".out"; while () { s/Fred/Larry/i; print; } === I executed using: $ perl ex9-2b.pl fred_larry.txt AlLarry Larrydy Larryd

Re: Can't open file.

2005-12-06 Thread David Sudjiman
On Tue, 6 Dec 2005, John W. Krahn wrote: > An array in scalar context returns the number of elements in the array so if > @ARGV contains one file name then $filename will be assigned the number 1. > You want to do either: > > my $filename = shift @ARGV; > > Or: > > my ( $filename ) = @ARGV; I

Can't open file.

2005-12-06 Thread David Sudjiman
Hi All, I try this script: #!/usr/bin/perl use strict; use warnings; my $filename = @ARGV; my $lines; #open FILE, "fred.txt" or die "Can't open foobar.txt : $!"; open FILE, $filename or die "Can't open $filename : $!"; $lines = join '', ; print "$lines\n\n\n\n"; $lines =~ s/^/fred.txt: /mg;

RE: Skip then print

2005-12-05 Thread David Sudjiman
On Mon, 5 Dec 2005, Moon, John wrote: > while ($line = <>) { > next if $. <= 10; > ... > } CMIIW, this one will check (if $.) for each of the line. thx .dave http://www.davidsudjiman.info -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED

Re: Skip then print

2005-12-05 Thread David Sudjiman
On Mon, 5 Dec 2005, Ron McKeever wrote: > Hello, > > I would like to skip the first ten lines of output from tail, then print any > new records matching my array, but I seem to be stuck, below will run but > nothing prints: > tail /var/log/messages is piped to it... > > #!/usr/bin/perl > > my