#$slotnumber=0; $dpdrivloc = "Trinity"; open(DPSLOTFILE, "< c:\\test.txt") or die "Can't open file: $!"; while ( ) { if ( /$dpdrivloc:\s*(\d+)/ ) { print "Slot for $dpdrivloc: $1\n"; } } #system("c:\\ipbat.bat"); close DPSLOTFILE; #### Label Location Time NKL0800 MSL6000 Trinity: 7 1800 #### Label Location Time [NKL0800] [MSL6000 Trinity: 7] 1800