hi all,
So, I have a large text file that I am trynig to get some data out of. Each line that has the particular type of data I need starts with HISTOGRAM OF, and they all look something like this:
HISTOGRAM OF * gpa * ( 226) GROUPED BY * deprint *
What I need to get out of there is the gpa (or whatever the particular value is in its place). I do so, I have tried this:
#!/usr/local/bin/perl
$evalme = q[
while(<>) {
s/^ //;
if(/^HISTOGRAM OF(\w+)$/) {
print "in loop\n";
}
];
With the simple idea of having it print "in loop" when it matches this. (Obviously, this is just a test scenario. At least, I hope it's obvious.) It's not matching anything, though. Presumably, this is because I am terrible at regular expressions. I have tried countless variations on this theme, to no avail. Could someone please point me in the right direction here? Thanks!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.