Advertisement
chotoipho

ch7_test5.pl

Dec 18th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.41 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2. use strict;
  3.  
  4. $_ = 'The HAL-9000 requires authorization to continue';
  5. my $search_pattern1 = 'HAL-[\d]+';
  6. print "\$_ = $_\n";
  7. print "\$search_pattern1 = $search_pattern1\n";
  8.  
  9. if (/$search_pattern1/) {
  10.   print "The string mentions some model of HAL computer.\n";
  11. #  print "Matching Character: '$1'\n";
  12.   }
  13. else {
  14.   print "It failed to match!\n";
  15.   print "$!\n";
  16. }
  17.  
  18.  
  19. print "done.\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement