gnu@perl has asked for the wisdom of the Perl Monks concerning the following question:
Can someone tell me how I can get just this phrase from the line of text? What I need to do is find m/.*PNAME:.*/ in the string, once it is found I need to add just "PNAME:\w" to a hash. The part after the ":" will vary and I need to know how many occurances of each variation I have.
What I have so far is the right logic, but I end up with the whole line in $_ placed into the hash. I only want the PNAME:\w part.
I know I'm going to feel stupid when someone points this out, but HELP!.
TIA, Chad.
#!/usr/bin/perl -w use strict; my @filelist = < S2002* >; my %PNODES; for (@filelist) { open(FILE,$_); while (<FILE>) { if ($_ =~ m/.*PNODE:.*/) { $PNODES{$_} = 1; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Retrieving specific word from a line of text.
by impossiblerobot (Deacon) on Dec 11, 2002 at 16:48 UTC | |
|
Re: Retrieving specific word from a line of text.
by djantzen (Priest) on Dec 11, 2002 at 16:49 UTC | |
by CountZero (Bishop) on Dec 11, 2002 at 22:46 UTC |