Help for this page

Select Code to Download


  1. or download this
    my $string = "abcdefDaveghijkl";
    if ( $string =~ /Dave/ ) {
        print "I found Dave.\n";
    }
    
  2. or download this
    my $string = "1.23.45";
    print "Found a number.\n" if /\d+/;
    
  3. or download this
    my $string = "1.234.567.txt";
    print "Found a good filename.\n" if /\d+\.txt/;
    
  4. or download this
    my $string = "1.234.567.txt";
    print "Match.\n" if /567.txt/;
    
  5. or download this
    /^\d+\.txt/
    
  6. or download this
    my $testname = "     456.txt";
    my $filename;
    if ($filename = $testname=~ /^\s*?(\d+\.txt)\s*?$/ ) {
       print "Found a file named $filename.\n";
    }