Richard Gordon wrote: > > See also blue; green; red. > > needs to become: > > See also <A HREF="/cgi-bin/myscript.pl?blue">blue</A>; <A > HREF="/cgi-bin/myscript.pl?green">green</A>; <A > HREF="/cgi-bin/myscript.pl?red">red</A>. > > Finding the references and dealing with the first one within each > group is no problem, but I am not clear about how to handle all of > them before moving on to find the next instance of See also. The > ground rules are that the passages will always start with See also > followed by a space and at least one reference which could have > multiple words. If there are multiple references, they are delimited > with a semi-colon and, in any case, a period terminates the entire > string. The way that the text file is structured, everything will be > on one physical line. > My not so pretty ideas pasted in below. Hope this helps. Geoff --- begin --- #!/usr/bin/perl -w $string = <DATA>; #get rid of the chaff $string =~ s/See also //g; #convert it to an array @lines = split(/\. /,$string); #got through each line in the array #picking out the good bits and printing foreach $line (@lines) { @opts = split(/; /, $line); print "See also "; foreach $opt (@opts) { print "<A HREF=\"cgi-bin/myscript.pl?$opt\">$opt</A>\n"; } } __DATA__ See also red; green; blue.See also white; green; yellow.See also black; purple; orange. --- begin results --- See also <A HREF="cgi-bin/myscript.pl?red">red</A> <A HREF="cgi-bin/myscript.pl?green">green</A> <A HREF="cgi-bin/myscript.pl?blue">blue</A> See also <A HREF="cgi-bin/myscript.pl?white">white</A> <A HREF="cgi-bin/myscript.pl?green">green</A> <A HREF="cgi-bin/myscript.pl?yellow">yellow</A> See also <A HREF="cgi-bin/myscript.pl?black">black</A> <A HREF="cgi-bin/myscript.pl?purple">purple</A> <A HREF="cgi-bin/myscript.pl?orange">orange</A> ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org