Help for this page

Select Code to Download


  1. or download this
    my @array = qw/ element1 element2 element3 /;
    
  2. or download this
    my @array = ();
    push @array, 'element1';
    push @array, 'element2';
    push @array, 'element3';
    
  3. or download this
    my $pattern = join '|', @final_array;
    
  4. or download this
    s/pattern1|pattern2|pattern3/replace/g;
    
    # which is equivalent to
    my $patterns = "pattern1|pattern2|pattern3";
    s/$patterns/replace/g;