I have a large file of test that cann't be imported into a database but I want to strip all the postcode's out of the file, I have tried below but it strips the whole line out. But I want just the variable i.e postcode in a seperate file.
What format is the post code stored as? ie 5 digits, or combination of letters and digits etc..
And how is each line formatted - comma seperated, space seperated, or...?
StanTheMan
4:48 pm on Jul 18, 2003 (gmt 0)
I have the postcode regex sorted but when I output it, it returns the whole line, rather than just the post code variable.
Storyteller
6:59 pm on Jul 18, 2003 (gmt 0)
With the syntax you're using for regexp operation, variable $username gets assigned either undef or 1, depending on whether regexp matches. I'm not sure this is what you want, is it?
StanTheMan
12:44 pm on Jul 21, 2003 (gmt 0)
No I want to output just the postcode that is being stripped from the code, not the full line.
How would I go about doing this with the code above?
tschild
1:10 pm on Jul 21, 2003 (gmt 0)
try
if ($line =~ m/(regexp_matching_a_postcode)/) {print "$1\n"};
or, if one line may contain more than one postcode,
while ($line =~ m/(regexp_matching_a_postcode)/g) {print "$1\n"};