in reply to Text filer and assign
I did write a regex code which is not working for me. Please assist. Thanks
Please show the code you have written, its easier to help that way
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Text filer and assign
by intoperl (Acolyte) on Oct 06, 2015 at 08:22 UTC | |
code snippet is below :
i want the assignment to look like :
| [reply] [d/l] [select] |
by Corion (Patriarch) on Oct 06, 2015 at 08:27 UTC | |
Most likely, you want to use "capturing" (see perlre) to keep the stuff that interests you:
Note that your regular expression does not match the result you want, because your result has the string free in it, while your regular expression will not match that. You should add the string at the appropriate place. While it makes debugging easier, you don't need a temp file:
| [reply] [d/l] [select] |
by Discipulus (Canon) on Oct 06, 2015 at 08:36 UTC | |
I find also YAPE::Regex::Explain useful:
HtH L*
There are no rules, there are no thumbs.. Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS. | [reply] [d/l] |
by johngg (Canon) on Oct 06, 2015 at 13:23 UTC | |
I see that you append to the pv.txt1 file which means more lines to parse every time you run the script; is this actually intended? Unless you want to keep the output of pvscan hanging around you can open a file handle directly on piped commands. Something like:-
You can then read the command output line by line just as if it was a file on disk. I hope this is helpful. Cheers, JohnGG | [reply] [d/l] [select] |