Professional Web Applications Themes

Need help in File::Stat - PERL Beginners

Hi I wrote this simple script : #!/usr/local/bin/perl use strict ; use warnings ; use File::Stat ; my $filename = "/tmp/cvr.txt" ; my $stat = new File::Stat($filename) or die " No $filename : $! \n"; print " Dev = $stat->dev \n"; print " Inode = $stat->ino \n"; print " Mode = $stat->mode \n"; print " Link = $stat->nlink \n"; print " Uid = $stat->uid \n"; but the output is comming like this ---OUTPUT -- Dev = File::Stat=ARRAY(0x150a20)->dev Inode = File::Stat=ARRAY(0x150a20)->ino Mode = File::Stat=ARRAY(0x150a20)->mode Link = File::Stat=ARRAY(0x150a20)->nlink Uid = File::Stat=ARRAY(0x150a20)->uid what i want is actual values like what is the uid ...

  1. #1

    Default Need help in File::Stat

    Hi

    I wrote this simple script :

    #!/usr/local/bin/perl

    use strict ;
    use warnings ;
    use File::Stat ;

    my $filename = "/tmp/cvr.txt" ;

    my $stat = new File::Stat($filename) or die " No $filename : $! \n";

    print " Dev = $stat->dev \n";
    print " Inode = $stat->ino \n";
    print " Mode = $stat->mode \n";
    print " Link = $stat->nlink \n";
    print " Uid = $stat->uid \n";

    but the output is comming like this
    ---OUTPUT --

    Dev = File::Stat=ARRAY(0x150a20)->dev
    Inode = File::Stat=ARRAY(0x150a20)->ino
    Mode = File::Stat=ARRAY(0x150a20)->mode
    Link = File::Stat=ARRAY(0x150a20)->nlink
    Uid = File::Stat=ARRAY(0x150a20)->uid

    what i want is actual values like what is the uid of the file ? .....
    Thanks in advance :)

    regards
    CVR
    Chandrakant Guest

  2. #2

    Default RE: Need help in File::Stat

    Chandrakant Reddy wrote:
    .... 

    Method calls don't interpolate in double quotes. So you need to write it as:

    print " Dev = ", $stat->dev, "\n";

    Or use this trick,

    print " Dev = {[$stat->dev]}\n";

    (but don't do that :~)
    Bob Guest

  3. #3

    Default Re: Need help in File::Stat

    Chandrakant Reddy wrote: 

    Hello,
     

    Is there a reason that you can't use the built-in stat function or the core
    module File::stat?

     


    #!/usr/local/bin/perl

    use strict;
    use warnings;

    my $filename = '/tmp/cvr.txt';

    my ( $dev, $ino, $mode, $nlink, $uid ) = stat $filename;

    print " Dev = $dev\n";
    print " Inode = $ino\n";
    print " Mode = $mode\n";
    print " Link = $nlink\n";
    print " Uid = $uid\n";

    __END__



    John
    --
    use Perl;
    program
    fulfillment
    John Guest

Similar Threads

  1. Replies: 6
    Last Post: December 6th, 05:12 PM
  2. File::Stat and file flags
    By Manfred in forum Ruby
    Replies: 7
    Last Post: December 2nd, 01:34 PM
  3. stat question
    By David selby in forum Debian
    Replies: 7
    Last Post: August 2nd, 05:10 PM
  4. File.stat.blksize returns nil and not 0 on win2k
    By Pierre Baillet in forum Ruby
    Replies: 2
    Last Post: July 5th, 12:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139