On Thu, Mar 06, 2003 at 02:06:12PM -0000, Andy Williams (IMAP HILLWAY) said: > Should give me > @array = qw( FORENAME SURNAME ACCT_NO);
#!/usr/bin/perl -w use strict; use Text::DelimMatch; my $file = join $/, <>; print join "\n", get_tokens($file); sub get_tokens { my $text = shift || ""; my $mc = Text::DelimMatch->new("\\[%","%\\]"); # pre declare my @tokens; # loop through all the matches # Why isn't this a standard method in Text::DelimMatch? # And if it is then why is it badly documented? while (my $match = $mc->match($text)) { # clean up $match =~ s!^\[%(.+)%\]!$1!; # push the match in push @tokens, $match; # and reset $text so that we don't loop infinitely $text = $mc->post_matched() || ""; } return @tokens; }