smaida has asked for the wisdom of the Perl Monks concerning the following question:
I need the script to read in and search the text file for a line "Port $port" where $port is the port number and then print out everyline until the "#-----" line.Port 119 NNTP * Microsoft Ports-Microsoft Exchange supports a News server running at + this port. * RFC977 * RFC1036 #------------------------------------------- Port 120 CFDP (UDP) Coherent File Distribution Protocol (CFDP) * RFC1235 #------------------------------------------- Port 123 NTP (UDP) NTP (Network Time Protocol) * RFC2030 * RFC1129 #--------------------------------------------
sub port_definition { my $port = @_[0]; open(FILE,"ipac_port_defs") || die_nice("Can not open file \"ipac_p +ort_defs\" for reading"); @port_file = <FILE>; close(FILE); foreach $line(@port_file){ if ($line =~ /^Port\s$port/){ $template{port_def} = $line; } } print "Content-type: text/html\n\n"; # Print headers parse("tpl/port_def"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help Matching Sections of a file
by kvale (Monsignor) on Apr 05, 2004 at 00:10 UTC | |
|
Re: Help Matching Sections of a file
by jmcnamara (Monsignor) on Apr 05, 2004 at 00:31 UTC | |
|
Re: Help Matching Sections of a file
by TilRMan (Friar) on Apr 05, 2004 at 02:21 UTC | |
by eXile (Priest) on Apr 05, 2004 at 02:57 UTC | |
by TilRMan (Friar) on Apr 05, 2004 at 09:57 UTC | |
by Elijah (Hermit) on Apr 05, 2004 at 15:17 UTC | |
by TilRMan (Friar) on Apr 05, 2004 at 16:26 UTC | |
|
Re: Help Matching Sections of a file
by BrowserUk (Patriarch) on Apr 05, 2004 at 01:19 UTC | |
|
Re: Help Matching Sections of a file
by Elijah (Hermit) on Apr 05, 2004 at 01:14 UTC | |
|
Re: Help Matching Sections of a file
by Happy-the-monk (Canon) on Apr 05, 2004 at 00:13 UTC |