in reply to a little REGEX help
The following will work with or without line-numbers:
output:use strict; use warnings; while (<DATA>) { next unless m/EUR\/USD/; chomp; my ($currency, $amount, $time) = split /\s*,\s*/; $currency =~ s/\d*\s*//g; print "$currency: $amount at $time\n"; } __DATA__ 1 EUR/USD ,1.35590 ,13:09:31 2 EUR/JPY , 129.872 ,13:09:29 3 GBP/JPY , 138.009 ,13:09:32 4 AUD/JPY , 65.939 ,13:09:30 5 EUR/USD ,1.35592 ,13:09:35 6 EUR/JPY , 129.866 ,13:09:35 7 GBP/JPY , 137.999 ,13:09:35 8 AUD/JPY , 65.938 ,13:09:35 9 EUR/USD ,1.35592 ,13:09:35 10 EUR/JPY , 129.866 ,13:09:35 11 GBP/JPY , 137.999 ,13:09:35 12 AUD/JPY , 65.938 ,13:09:35 13 EUR/USD ,1.35592 ,13:09:35 14 EUR/JPY , 129.866 ,13:09:35 15 GBP/JPY , 137.999 ,13:09:35 16 AUD/JPY , 65.938 ,13:09:35 17 EUR/USD ,1.35592 ,13:09:35 18 EUR/JPY , 129.866 ,13:09:35 19 GBP/JPY , 137.999 ,13:09:35
EUR/USD: 1.35590 at 13:09:31 EUR/USD: 1.35592 at 13:09:35 EUR/USD: 1.35592 at 13:09:35 EUR/USD: 1.35592 at 13:09:35 EUR/USD: 1.35592 at 13:09:35
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|