in reply to Split on whitespace or other criteria

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; while(<DATA>) { chomp; s/-/ -/g; print Dumper [split(/\s+/, $_)]; } __DATA__ 123.45 345.3 234.67 34.56 234.1 123.87 897.34 567.32-100.90
How about adding a blank before the '-'sign.

Replies are listed 'Best First'.
Re^2: Split on whitespace or other criteria
by Anonymous Monk on Jan 30, 2005 at 20:42 UTC
    yes, should hav mention that a blank is required before -ve sign thanks
      @array = grep { $_ !~ /^\s*$/ } split '(\d+(?:\.\d*)*)+|\D+', $line;

      So there is no matter what chars you put between digits.
        the -ve sign is lost on the split?