fork download
  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. while (<DATA>) {
  7.  
  8. # A - Preceded by the beginning of the line or 1 or more whitespace
  9. # characters
  10. # B - The characters 'C#' or 'C++'
  11. # C - Followed by 1 or more whitespace characters of the end of line.
  12.  
  13. if (/(?:^|\s+)(C#|C\+\+)(?=\s+|$)/) {
  14. # ^^^^^ ^^^^^^^^ ^^^^^
  15. # A B C
  16.  
  17. print "[$1] [$_]\n";
  18. } else {
  19. print "[--] [$_]\n";
  20. }
  21. }
  22.  
  23. __END__
  24. This program is written in C++ We'll delete it after ten days
  25. This program is written in !C++ We'll delete it after ten days
  26. This program is written in C++! We'll delete it after ten days
  27. This program is written in C# We'll delete it after ten days
  28. C# is the language this program is written in.
  29. C# is the language this program is written in.
  30. C++ is the language this program is written in.
  31. This program is written in C#
  32. This program is written in C++
  33. This program is written in C++!
  34.  
Success #stdin #stdout 0s 3740KB
stdin
Standard input is empty
stdout
[C++] [This program is written in C++ We'll delete it after ten days]
[--] [This program is written in !C++ We'll delete it after ten days]
[--] [This program is written in C++! We'll delete it after ten days]
[C#] [This program is written in C# We'll delete it after ten days]
[C#] [C# is the language this program is written in.]
[C#] [ C# is the language this program is written in.]
[C++] [C++ is the language this program is written in.]
[C#] [This program is written in C#]
[C++] [This program is written in C++]
[--] [This program is written in C++!]