Help for this page

Select Code to Download


  1. or download this
    $id = 1; # <--- semicolon was missing
    open(MYFILE,"/var/tmp/mylist.dat") or die "Cant open mylist.dat"
    ...
    
    close MYFILE;
    
  2. or download this
          die "Request Id $id already present in file\n" if /$id/;
    
  3. or download this
    while (my $line = <MYFILE>) {
          chomp $line;
          die "Request Id $id already present in file\n" if $line =~ /$id/
    +;
    }
    
  4. or download this
        my @array = split /,/, $_;
        die "Request Id $id already present in file\n" if $array[0] eq $id
    +;