Hi!
I have a question, not even sure where to start coding on. I have a file that has a field in brackets that I want to export to another file. For some reason it doesn't pick up the file unless the brackets are removed.
Here's the script that works without brackets:
#$slotnumber=0; $dpdrivloc = "Trinity"; open(DPSLOTFILE, "< c:\\test.txt") or die "Can't open file: $!"; while ( <DPSLOTFILE> ) { if ( /$dpdrivloc:\s*(\d+)/ ) { print "Slot for $dpdrivloc: $1\n"; } } #system("c:\\ipbat.bat"); close DPSLOTFILE;
The file has brackets around "Trinity" and won't read data unless the brackets are removed.
The file works if the file looks like:
The code doesn't work when file is like:Label Location Time NKL0800 MSL6000 Trinity: 7 1800
Label Location Time [NKL0800] [MSL6000 Trinity: 7] 1800
Unfortunately the file that needs to be read is like the second one. What I would like to do is take the fields inside [] and copy the data to a new file for reading. Any ideas (stripping out from [], I can handle the file I/O)???
Edited by BazB fixed formatting
In reply to Remove field inside [ ] brackets by jamen_98
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |