> #!/opt/perl/bin/perl -w > use strict; > > #variable > > my @horcm_file; > > > sub readdata{ > open(HORCM, "/etc/horcm10.conf") || die ("File error"); > @horcm_file = <HORCM>; > chomp(@horcm_file); > close(HORCM); > return(@horcm_file); > } > > my @pipo=readdata(); > > foreach (@pipo){ > /HORCM_INST/ or next; > print; > } >
I would not store the whole file into an array unless you really need this. i would suggest this sollution: my $outputflag = 0; open(HORCM, "/etc/horcm10.conf") || die ("File error"); while(<HORCM>){ if(/HORCM_INST/){ $outputflag = 1; # start printing }elsif($_ eq "\n") { #newline $outputflag = 0; # stop printing } print if $outputflag; } close(HORCM); HTH, Martin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/