awk - trim white space from a field / variable

Hi,

Consider the data (FS = |):

1| England |end
2|  New Zealand   |end
3|Australia|end
4|   Some Made Up Country    |end
5| West Indies|end

I want the output to be (i.e. without the leading and trailing white space from $2)

England
New Zealand
Australia
Some Made Up Country
West Indies

any ideas on how its done in awk??

---------- Post updated at 03:25 PM ---------- Previous update was at 03:07 PM ----------

this works

BEGIN {
        FS = "|"
        OFS = "|"
}
{
gsub(/^[ \t]+|[ \t]+$/, "", $2); print $2
}
awk -F"[ \t]*[|][ \t]*" '{print $2}' inputfile

if you don't mind losing the spaces/tabs before and after each pipe...

while IFS='|' read a b a ; do echo $b; done <inputfile

Try like

awk -F'|' '{print $2}' test.txt |sed 's/^[ ^t]*//;s/[ ^]*$//' 
 
$ awk -F\| 'gsub(/^ */,"",$2){print $2}' input.txt
England 
New Zealand   
Australia
Some Made Up Country    
West Indies

use nawk in solaris