Gossamer Forum
Home : General : Perl Programming :

Re: [petermcdonald] Setting specific line in file as variable

Quote Reply
Re: [petermcdonald] Setting specific line in file as variable In reply to
A better approach would be:

Code:
my $line;

open DATFILE, "$path/$whatdir.txt" or die "Could not open file: $!";
while (<DATFILE>) {
chomp;
if (/^\Q$goto\E$/) {
$line = $_;
last;
}
next;
}

That is less memory intensive.

Last edited by:

Paul: Sep 2, 2002, 10:57 AM
Subject Author Views Date
Thread Setting specific line in file as variable petermcdonald 6410 Sep 1, 2002, 4:21 PM
Thread Re: [petermcdonald] Setting specific line in file as variable
durp 6282 Sep 1, 2002, 10:08 PM
Thread Re: [durp] Setting specific line in file as variable
petermcdonald 6290 Sep 1, 2002, 10:50 PM
Thread Re: [petermcdonald] Setting specific line in file as variable
petermcdonald 6282 Sep 1, 2002, 11:06 PM
Thread Re: [petermcdonald] Setting specific line in file as variable
Paul 6266 Sep 2, 2002, 2:10 AM
Post Re: [Paul] Setting specific line in file as variable
durp 6260 Sep 2, 2002, 10:31 AM
Thread Re: [Paul] Setting specific line in file as variable
petermcdonald 6250 Sep 2, 2002, 10:34 AM
Thread Re: [petermcdonald] Setting specific line in file as variable
petermcdonald 6274 Sep 2, 2002, 10:37 AM
Post Re: [petermcdonald] Setting specific line in file as variable
Paul 6266 Sep 2, 2002, 10:50 AM
Thread Re: [petermcdonald] Setting specific line in file as variable
Paul 6227 Sep 2, 2002, 10:56 AM
Thread Re: [Paul] Setting specific line in file as variable
petermcdonald 6244 Sep 2, 2002, 11:07 AM
Thread Re: [petermcdonald] Setting specific line in file as variable
Paul 6243 Sep 2, 2002, 11:34 AM
Thread Re: [Paul] Setting specific line in file as variable
petermcdonald 6256 Sep 2, 2002, 11:55 AM
Thread Re: [petermcdonald] Setting specific line in file as variable
Paul 6249 Sep 5, 2002, 4:21 AM
Post Re: [Paul] Setting specific line in file as variable
petermcdonald 6208 Sep 7, 2002, 6:07 PM