Dr.Ruud wrote:
John W. Krahn:
my @llist = do {
open my $fh, '<', $lfile or die "Unable to open '$lfile': $!";
<$fh>;
};
Again, especially for biggish files, this is a better way:
my @llist;
{ open my $fh, '<', $lfile
or die "'$lfile': $!";
@llist = <$fh>;
}
Rand
John W. Krahn wrote:
my @llist = do {
open my $fh, '<', $lfile or die "Unable to open '$lfile': $!";
<$fh>;
};
Again, especially for biggish files, this is a better way:
my @llist;
{ open my $fh, '<', $lfile
or die "'$lfile': $!";
@llist = <$fh>;
}
Randall's idea
On Sun, Jan 4, 2009 at 7:42 PM, John W. Krahn wrote:
>>> You should include the $! variable in the die string so that you know why
>>> the
>>> open failed. I suggest
>>>
>>> my @llist;
>>> {
>>>open my $fh, '<', $lfile or die "Unable to open '$lfile': $!";
>>>@llist = <$fh>;
>>> }
>>
>>
John Refior wrote:
Rob Dixon wrote:
David Newman wrote:
# get files
open(DAT, $lfile) or die("unable to open");
my @Llist = ;
close(DAT);
You should include the $! variable in the die string so that you know why the
open failed. I suggest
my @llist;
{
open my $fh, '<', $lfile or d
On Sun, Jan 4, 2009 at 11:45 AM, Bob goolsby wrote:
> Not 'wrong headed', just a compiler compiler optimization. By putting
> the declarations before the usage, you reduced the number of complete
> passes through the source by one and made the parsing code easier.
> This is an artifact from the t
>> # get files
>> open(DAT, $lfile) or die("unable to open");
>>
>> my @Llist = ;
>>
>> close(DAT);
>
> You should include the $! variable in the die string so that you know why the
> open failed. I suggest
>
> my @llist;
> {
>open my $fh, '<', $lfile or die "Unable to open '$lfile': $!";
>
Not 'wrong headed', just a compiler compiler optimization. By putting
the declarations before the usage, you reduced the number of complete
passes through the source by one and made the parsing code easier.
This is an artifact from the time when Machine-Time was expensive and
Programmer-Time was (
On Sat Jan 03 2009 @ 11:00, John W. Krahn wrote:
>>> David Newman wrote:
>> I always found it "cleaner", and have heard others say it's preferable,
>> to declare all variables at the top of the program (although admittedly
>> I didn't do that even in this short script).
>
> It is always better to l
David Newman wrote:
On 1/2/09 5:22 PM, Rob Dixon wrote:
David Newman wrote:
my $lfile = $ARGV[0];
my $rfile = $ARGV[1];
It would also be nice to make sure that there are in fact two parameters
die "The parameters must be the the two files for comparison"
unless @ARGV == 2;
my
On Sat Jan 03 2009 @ 9:21, David Newman wrote:
> On 1/2/09 5:22 PM, Rob Dixon wrote:
> >> #!/usr/bin/perl -w
> >>
> >> use strict;
> >
> > You should also use the warnings pragma instead of the command-line switch.
> >
> > use warnings;
>
> OK. Why is this better?
My understanding is that th
On 1/2/09 5:22 PM, Rob Dixon wrote:
> David Newman wrote:
>> Greetings. I have a working script (pasted below) that uses
>> List::Compare to find common lines in two files.
>>
>> Now I am again looking to compare two files but this time exclude any
>> lines in file 1 that appear in file 2. I don't
Rob Dixon wrote:
David Newman wrote:
foreach my $union (@union) {
print "$union";
}
You shouldn't put $union in quotes, and the loop is better written as
print for @union;
print @union;
Should work just as well.
John
--
Those people who think they know everything are a grea
David Newman wrote:
>
> Greetings. I have a working script (pasted below) that uses
> List::Compare to find common lines in two files.
>
> Now I am again looking to compare two files but this time exclude any
> lines in file 1 that appear in file 2. I don't see anything in the
> List::Compare docu
Greetings. I have a working script (pasted below) that uses
List::Compare to find common lines in two files.
Now I am again looking to compare two files but this time exclude any
lines in file 1 that appear in file 2. I don't see anything in the
List::Compare documentation on how to do this.
Than
14 matches
Mail list logo