editholla has asked for the wisdom of the Perl Monks concerning the following question:
This is my third day using Perl and I have limited coding background as well. I am trying to pull all 5 character strings that begin with "4" and end with a letter from a group of text files in a directory. I have managed to create an array of these text files and print them all but I am struggling to find a way to pull out the data I want (ex. 4099A from text file shown below). I am interested in any help whether it would build upon my current code or start from scratch. It will also be great if there was a way to omit any repeated strings.
Thank You!
Code:Example of a Text File:use strict; use warnings; my $way = "/tester/SPECS/7nm/TestRules/avatar/"; my @rit; opendir( my $rid, $way ); while ( my $entry = readdir $rid ) { next unless -f $way . '/' . $entry; next if $entry eq '.' or $entry eq '..'; push @rit, $entry; } closedir $rid; foreach (@rit) { my $cat = "/tester/SPECS/7nm/TestRules/avatar/$_"; open (WAY , $cat) or die("Can't open $cat"); my @lines = <WAY>; print @lines, "\n";
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!! ! ! GENERIC TEST PLAN (RULES) FOR !!!!!!!!!!!!!!!!!!!!!!! nCaps ! ! CREATED ON 06/15/15 ! ! CHANGES: ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!! !RECIPE NAME LOTTYPE PNP #WAFERS SITEMAP PRIORITY ! ! PS Level ILTPSPR25C080 POR 4099A 25 A300_20B 1 ILTPSPR25C080 SPLIT 4099A 125 A300_20B 1 ! ILTPSPR25N080 POR 4060A 25 A300_20B 1 !ILTPSPR25N080 POR 4060B 25 A300_20B 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pulling 5 Character Strings out of an Array of Text Files
by 1nickt (Canon) on Dec 30, 2015 at 17:49 UTC | |
|
Re: Pulling 5 Character Strings out of an Array of Text Files
by stevieb (Canon) on Dec 30, 2015 at 17:49 UTC | |
by editholla (Initiate) on Jan 05, 2016 at 15:18 UTC |