in reply to Read and Create File
use strict; use warnings; while ( $_ = do { local $/ = qq(""\n); <> }) { if (/(\w+\.\w+).*Default_Name:\s\@ST\/(\w+)\/(\w+)$/ms) { print "[$1]\n", "db_part_no=$2\n", "db_part_rev=$3\n\n"; } }
Output with input file from OP
>perl szpt9m.pl 11134376.txt [xyz.txt] db_part_no=ABC1234 db_part_rev=00001 [abc.txt] db_part_no=ABC5678 db_part_rev=00001 [rtq.txt] db_part_no=ABC2345 db_part_rev=00002
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Read and Create File
by AnomalousMonk (Archbishop) on Jun 28, 2021 at 14:30 UTC | |
by BillKSmith (Monsignor) on Jun 28, 2021 at 20:20 UTC | |
by szpt9m (Novice) on Jun 30, 2021 at 16:05 UTC | |
by tybalt89 (Monsignor) on Jun 30, 2021 at 19:16 UTC | |
by hippo (Archbishop) on Jun 30, 2021 at 17:11 UTC | |
by szpt9m (Novice) on Jul 01, 2021 at 07:02 UTC | |
by tybalt89 (Monsignor) on Jul 01, 2021 at 08:07 UTC | |
|
Re^2: Read and Create File
by jwkrahn (Abbot) on Jun 28, 2021 at 20:49 UTC |