fork download
  1. #!/usr/bin/perl
  2. # "Music Live"
  3. my $str = "12 hr 4 min";
  4. if($str =~ m/\s/)
  5. {
  6. print "wrong";
  7. }
  8. else
  9. {
  10. my @str1 = split (/\s+/, $str);
  11.  
  12. print "\n array ".@str1[0];
  13. print "\n array ".@str1[1];
  14. print "\n array ".@str1[2];
  15. print "\n array ".@str1[3];
  16.  
  17. my $count = @str1;
  18. print "\n Count ".$count;
  19.  
  20. print "\n str: ".$str."\n";
  21.  
  22. if ( $str1[1] eq "hr")
  23. {
  24. print "Hour";
  25. #if ($str =~ m/[\d]\s[hr][\d\d][min]\s\([partial]\)?/)
  26. #if ($str =~ m/(\d|\d\d)\s[hr]\s+(\d\d)\s+[min]/)
  27. #if ($str =~ m/(\d|\d\d)\s\w\s(\d|\d\d)\s\w/)
  28. if ($str =~ m/(\d|\d\d)\s[hr]\s(\d|\d\d)\s[min]/)
  29. {
  30. print "\nHour data captured";
  31. }
  32. print "\nAfter IF";
  33.  
  34. }elsif($str1[1] eq "min")
  35. {
  36. print "Minute";
  37. }
  38. }
Success #stdin #stdout 0s 4596KB
stdin
Standard input is empty
stdout
wrong