dirtdog has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks
I'm stuck trying to extract the Trailer count from a file that contains a Header and Trailer within brackets.
I have the following one-liner so far, but it doesn't quite get exactly what i need
perl -ne 'print "$1\n" if /\[(.*?)\]/;' <filename>Sample input looks like this:
[HDR20140110230120] --data content-- [TRL345]
The data content is swift data and is not surrounded by brackets so is not relevant for this example.
My expected result would be 345 in this example. Also, other samples of what the trailer record could be are:
[TRL0] or [TRL25678]It's a variable length count with no leading zeroes.
Any help would be greatly appreciated
thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: extract trailer count one liner
by kennethk (Abbot) on Jan 13, 2014 at 17:38 UTC | |
|
Re: extract trailer count one liner
by hdb (Monsignor) on Jan 13, 2014 at 17:38 UTC | |
|
Re: extract trailer count one liner
by Anonymous Monk on Jan 13, 2014 at 18:15 UTC |