Gossamer Forum
Home : General : Perl Programming :

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

Quote Reply
Re: [Paul] Setting specific line in file as variable In reply to
No, I just needed to open it once. Here's my code:

open(DATFILE, "$path/$whatdir.txt") || die("Could not open file!");
@datfile=<DATFILE>;
close(DATFILE);

foreach $newline(@datfile) {
next unless ($newline=~/^$whatfile/);
($ecoursedesc,$ecoursenum,$ecoursename,$ecredits,$eregional,$egradreq)=split(/\|/,$newline);
last;
}



And that appears to do the trick :)



Peter
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 6251 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 6245 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 6257 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