I've had difficulty peeling data from a flat file. I initially thought I could terminal line grep it, but it urped all over the very long lines and Perl is more flexible anyway if I need to add functions later. The information I'm seeking uses some reserved characters that need to be escaped in grep.
Here's what I'm trying to do:
1. Open a text file with a mucky-thick block of text (almost no line feeds).
2. Search for occurrences of a string that begins with -/ (dash slash) that variably contains between 5 and 20 alphanumeric characters and which ends with ?srt= (question mark srt equals).
Here are examples:
• ...emable-Stuff-10100-PTZ-/1280640AB018292?srt=More2stuff&ha... (find -/1280640AB018292?srt= and grab 1280640AB018292)
• ...wer-Idaptx-SJ10-/35DE4715844?srt=L12_Defa43Dom.. (find -/35DE4715844?srt= and grab35DE4715844)
3. Write the alphanumeric strings to a text file, each occurrence on a new line.
Thanks for your accumulated (and accumulating) wisdom.
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.