#!/usr/local/bin/perl -w use strict; $/="\'\n"; #set the IFS while () { chomp; # chomp strips the IFS s/\?\'/\'/g; # fix the "quoted" ' marks my @fields=split /\+/; print "[$_] $fields[$_]\n" for 0..$#fields; } __DATA__ 0010+2+O'Reilly' 023++++234+35+White+++17+' g?'day mate+++' # output [0] 0010 [1] 2 [2] O'Reilly [0] 023 [1] [2] [3] [4] 234 [5] 35 [6] White [7] [8] [9] 17 [0] g'day mate #### $/="\'\n"; while () { chomp; s/\?\'/\'/g; my $i; print "[",$i++,"] $_\n" for split /\+/; }