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