jamen_98 has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Remove field inside [ ] brackets
by delirium (Chaplain) on Mar 22, 2004 at 15:43 UTC | |
by Anonymous Monk on Mar 24, 2004 at 08:50 UTC | |
|
Re: Remove field inside [ ] brackets
by neniro (Priest) on Mar 22, 2004 at 15:58 UTC | |
by Anonymous Monk on Mar 22, 2004 at 17:32 UTC | |
by graff (Chancellor) on Mar 23, 2004 at 03:30 UTC | |
|
Re: Remove field inside [ ] brackets
by xorl (Deacon) on Mar 22, 2004 at 17:38 UTC |