Thread lesen aus DATA: Wie resetten?
(7 answers)
Opened by FIFO at 2008-06-08 22:59 Linuxer+2008-06-08 22:09:37-- Danke, seek funktioniert, hatte das bislang nur bei "echten" Filehandles und byteorientiertem Lesen verwendet. Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 #----------------------------------------------------------------------------# sub print_helpscreen { my ($handle, $section) = @_; seek $handle, 0, 0; # zum Anfang des DATA-Bereichs LOOKUP_SECTION: while (my $line = <$handle>) { last LOOKUP_SECTION if $line =~ m{<$section>}i; } ... } #----------------------------------------------------------------------------# @moritz: HERE-docs wollte ich ja gerade vermeiden (s.o.). Die Frage, wie man interpolierbare Strings aus dem Handle liest, ist unabhängig davon. Ich probier mal weiter ... Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? -- Brian Kernighan: "The Elements of Programming Style"
|