perlfaq nodetype
faq_monk
<P>
$/ must be a string, not a regular expression. Awk has to be better for
something. :-)
<P>
Actually, you could do this if you don't mind reading the whole file into
memory:
<P>
<PRE> undef $/;
@records = split /your_pattern/, <FH>;
</PRE>
<P>
The Net::Telnet module (available from
<FONT SIZE=-1>CPAN)</FONT> has the capability to wait for a pattern in the
input stream, or timeout if it doesn't appear within a certain time.
<P>
<PRE> ## Create a file with three lines.
open FH, ">file";
print FH "The first line\nThe second line\nThe third line\n";
close FH;
</PRE>
<P>
<PRE> ## Get a read/write filehandle to it.
$fh = new FileHandle "+<file";
</PRE>
<P>
<PRE> ## Attach it to a "stream" object.
use Net::Telnet;
$file = new Net::Telnet (-fhopen => $fh);
</PRE>
<P>
<PRE> ## Search for the second line and print out the third.
$file->waitfor('/second line\n/');
print $file->getline;
</PRE>
<P>