fork download
  1. #!/usr/bin/perl
  2.  
  3.  
  4. my $text = "red 1 green 3 blue";
  5. my @result1 = split /red|green|blue/, $text;
  6. print join ";", @result1;
  7. print "\n";
  8. my @result2 = split /red|green|blue/, $text, -1;
  9. print join ";", @result2;
  10. print "\n";
  11. my @result3 = grep { /\S/ } split /red|green|blue/, $text;
  12. print join ";", @result3;
Success #stdin #stdout 0s 4840KB
stdin
Standard input is empty
stdout
; 1 ; 3 
; 1 ; 3 ;
 1 ; 3