BluGeni has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to get a grasp on splitting strings and arrays with perl but am having a little problem. my first page puts data into a database so it can be called upon later. its going in like this:
$writetot=$busitotal."/".$perstotal; $STH1->execute($writetot,$name)
and is being called by data[1] , data[2] ect.. my goal here is to split $writetot so i have 2 different outcomes and don't have it displaying $busitotal/$perstotal. I need to split it because of the data already in the data base will not change and i need to separate the 2 so i can put $busitotal and $perstotal in 2 dif catagories. any help would be greatly appreciated! Thank you

Replies are listed 'Best First'.
Re: splitting data
by Kenosis (Priest) on May 16, 2012 at 17:19 UTC

    Try the following:

    use Modern::Perl; my $writetot = 'first part/second part'; my ($busitotal, $perstotal) = split '/', $writetot; say "$busitotal -- $perstotal";

    Output:

    first part -- second part

    Hope this helps!