in reply to Problem with <STDIN>

The problem is about undef $/; delay it until you want to slurp the file
foreach ( grep( /^.*\.xml$/, readdir(DIR) ) ) { print "Pls enter Section level value for $_ : "; chop( $seclev = <STDIN> ); { local $/; open( FIN, "<$_" ) or die("$_ is not opened\n"); .. } }
Boris