in reply to Re^2: File Handling problem
in thread File Handling problem

Depending on the exact format of your text file you may be able to reduce the code to something like this ;
#!perl use strict; open FH_SECOND,"<",$ARGV[0] or die $!; my @setting = ('Port Speed','Duplex Setting','Switchport Access Mode', +'Spanning Tree Mode'); my $line1 = <FH_SECOND>; if ($line1 =~ /description xxxxxxxxx/){ while (<FH_SECOND>){ my $msg = 'Gigabit '.shift @setting; if(/speed 1000|duplex full|switchport mode access|spanning-tree po +rtfast/){ print $msg." is OK!!!\n"; } else { print $msg." is WRONG!!!\n"; } } } else { print "The Configuration File $ARGV[0] is NOT the RIGHT FILE \n"; } close(FH_SECOND); # test file #description xxxxxxxxx #speed 1000 #duplex full #switchport mode access #spanning-tree portfast
poj

Replies are listed 'Best First'.
Re^4: File Handling problem
by girish_01 (Initiate) on Mar 19, 2012 at 17:56 UTC
    That seems really charming i am gonna definitely try this approach... Thanks..