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
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
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
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;
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
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