in reply to Help with regex
G'day rocketperl,
You need to be more precise about what you want: your text says 'extract all the alpha numeric characters after "Query="'; your code says 'extract all non-whitespace characters after "Query= "'. In the code below, I've guessed the code is correct.
Here's the basic code you need to achieve what you want:
{ local $/ = 'Query= '; while (<$filehandle>) { print "$1\t$2" if / \A (\S+) .*? ^ > (\S+) /msx; } }
I suggest you read the open documentation for a better way to open your files (i.e. 3-argument form with a lexical filehandle). You should also check that your I/O has worked: either hand-craft messages as shown in the open documentation or, and this is my general preference, let Perl do this for you by using the autodie pragma.
My test code, test data and output is in the spoiler:
-- Ken
|
|---|