Help for this page

Select Code to Download


  1. or download this
    opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
    @dots = grep { /^\./ && -f "$some_dir/$_" } readdir(DIR);
    closedir DIR;
    
  2. or download this
      my @array = qw(One Two Five Nine);
      my %check_hash = map {$_ => 1} @array;
    
  3. or download this
      @fields = qw(Name ID Age);
      #assuming $dbh and $q exist, and primary key in $key
      my $statement = 'update my_table '.join(",", map {"set $_ = ?"} @fie
    +lds)." where Key=?";
      my $sth = $dbh->prepare($statement);
      $sth->execute(map({$q->param($_)} @fields), $key);
    
  4. or download this
      @fields = qw(Name ID Age Key);
      #assuming $dbh and $q exist, and primary key name in $key
    ...
      my $statement = 'update my_table '.join(",", map {"set $_ = ?"} grep
    +(!/^$key$/, @fields))." where $key=?";
      my $sth = $dbh->prepare($statement);
      $sth->execute(map({$q->param($_)} @fields));
    
  5. or download this
    $sth->execute(map({$q->param($_} grep(!/^$key$/, @fields)), $q->param(
    +$key));