
rovf
Veteran
Oct 28, 2011, 7:09 AM
Post #4 of 4
(2212 views)
|
|
Re: [ragha12] Read only one line from text file
[In reply to]
|
Can't Post
|
|
Strangly, my first response, giving a solution to your question, did not show up in the forum :-( Well, Jukari already gave an answer, though I personally consider his one as overly complicated. This would be a simpler version:
use strict; use warnings FATAL => qw(all); open(my $file, 'dmb.txt') || die "Damn it! $!\n"; print(q().(<$file> // qq()); close $file; while(0) { say "This is only because the requirement says to use a while loop"; } As you can see, this solution requires less variables than the one provided by Jukari, plus it has error handling.
|