49 users online (1 members and 48 guests)  


  Results 1 to 2 of 2

Related

  1. allow french characters using javascript    Forum: Javascript Forum
    Replies: 0
  2. How to match a time string    Forum: CGI Perl Forum
    Replies: 2
  3. How many characters in a confirm/alert box?    Forum: Javascript Forum
    Replies: 1
  4. SELECT MATCH ... AGAINST problem    Forum: PHP Forum
    Replies: 0
  5. How to unescape characters    Forum: CGI Perl Forum
    Replies: 1
  1. #1
    perlid's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    1

    how to match the characters in file ?

    I'm trying to check the file permission field. So, i wanns know reg exp for this.

    Code:
    $cmd = "ls -l > file";
    system($cmd);
    open (fd, "file"); 
    @lines = <fd>;
    foreach $line(@lines)
    {
    regexp
    }
    Please help
    Last edited by vinyl-junkie; 04-25-2007 at 07:23 AM. Reason: Added code tags

  2. #2
    raghbs's Avatar
    New User

    Status
    Offline
    Join Date
    May 2007
    Posts
    1

    Re: how to match the characters in file ?

    Code:
    my $dir=".";
    opendir(D,$dir);
    my @files=readdir(D);
    closedir (D);
    foreach my $file (@files){
      $file=~ s/^\.+$//s;
      if($file ne ''){
        my $mode=(stat($file))[2];
        my $own=(($mode & 448) >> 6);
        my $grp=(($mode & 56) >> 3);
        my $oth=($mode & 7);
        
    # permission is in the form 755
        print "$file\t$own\t$grp\t$oth\n";
        
      }
    }
    Last edited by vinyl-junkie; 05-15-2007 at 06:09 AM. Reason: Added code tags



Tags for this Thread