in reply to Re: Regex for splitting a string on a semicolon (conditionally) (use Text::CSV;)
in thread Regex for splitting a string on a semicolon (conditionally)

I'm using it in the larger context of my code to output the data (once broken up into individual references, then into author, year, etc columns) into a .csv file. It has nothing to do with this subroutine--I just copied the beginning of the script verbatum. Sorry for the confusion!
  • Comment on Re^2: Regex for splitting a string on a semicolon (conditionally) (use Text::CSV;)

Replies are listed 'Best First'.
Re^3: Regex for splitting a string on a semicolon (conditionally)
by Anonymous Monk on Feb 12, 2015 at 08:59 UTC
    Ok :) here you go, "Rome: IPGRI" gets seperated from its owner, then its put back
    sub breakup { my $filename = $_[0]; my $text = $_[1]; my @stuff = split /;\s?/, $text; my @parts ; while( @stuff ){ if( $stuff[0] =~ m{ ^ \w+ : \s \w+ $ }xms ){ $parts[-1] .= ";".$stuff[0]; } else { push @parts, $stuff[0]; } shift @stuff; } return \@parts; }