scripting - While loop is not working to read file in perl script -
i writing perl script , trying read 2 diff files..
first fileopen $data1, "<", "/tmp/csi_to_prod_111111_20141004_225038/att_application.properties" or die "unable open prod file"; while (<$data1>) { chomp(); foreach $line (<$data1>) { next if ( $line =~ /(^\s*#|^$)/ ); chomp($line); foreach $token (@csitokens) { if ( $line =~ /$token=/ ) { ( $tok, @val ) = split( /=/, $line, 2 ); print "@val\n"; } } } } close($data1) or warn "not able close fil: \n";
second file open $data2, "<", "/opt/app/d1ebl1m5/dv02/cingbt02/j2eeserver/config/amss/application/properties/att_application.properties_try" or die "unable open file: $!"; while (<$data2>) { foreach $line1 (<$data2>) { print "$line1"; } } close($data2) or warn "not able close fil: \n";
the loop first file working fine , displaying output sec loop doesnt display anything..
there many while
, foreach
loops. need 1 of them:
open $data2, "<" , "/opt/app/d1ebl1m5/dv02/cingbt02/j2eeserver/config/amss/application/properties/att_application.properties_try" or die "unable open file: $!"; while( $line1 = <$data2> ) { print "$line1"; } close($data2);
the same applicable first loop. yo have error on die-check after file open
perl scripting while-loop
No comments:
Post a Comment