How to reuse the FS_ wordlist from Win32API::File?

Discussion in 'Perl Misc' started by Dr.Ruud, Apr 1, 2006.

  1. Dr.Ruud

    Dr.Ruud Guest

    #!/usr/bin/perl
    # demo GetVolumeInformation() (hi Tad)
    use strict;
    use warnings;

    use Win32API::File qw ( GetVolumeInformation :FS_ );

    ### Is there a nicer/shorter way to express
    ## @{$Win32API::File::EXPORT_TAGS{FS_}} ?
    #
    my $FS_ref = $Win32API::File::EXPORT_TAGS{FS_};

    my @GetVolumeInformation_P = qw( sRootPath osVolName lVolName
    ouSerialNum
    ouMaxNameLen ouFsFlags osFsType
    lFsType );
    my @GetVolumeInformation = ( 'C:/', undef, undef, undef,
    undef, undef, undef,
    undef );

    GetVolumeInformation( @GetVolumeInformation )
    or die "GetVolumeInformation:\t"
    . $GetVolumeInformation[0]
    . "\n\t $^E\n\t$!";

    for my $i ( 0 .. $#GetVolumeInformation )
    {
    ### The next line starts strange; how to do it nicer?
    ##
    #
    my $v; $v = defined() ? $_ : '' for $GetVolumeInformation[$i];

    # If numeric, then show the hexadecimal representation as well.
    printf "%d\t[%s]\t%s%s\n"
    , $i
    , $GetVolumeInformation_P[$i]
    , $v
    , ($v =~ /\A[0-9]+\z/) ? sprintf("\t[hex %x]", $v) : '';

    # Intermezzo: show the FS_ Flags.
    if (5 == $i)
    {
    local @_;
    eval "push \@_, '$_' if $_ & \$v" for @$FS_ref;
    print "\t@_\n";
    }
    }
    __END__


    See the two questions marked with ###.
    Any comments welcome too.

    (For info about "BUFFER SIZES", see Win32API::Registry.)

    --
    Affijn, Ruud

    "Gewoon is een tijger."
     
    Dr.Ruud, Apr 1, 2006
    #1
    1. Advertising

  2. Dr.Ruud

    Dr.Ruud Guest

    Dr.Ruud schreef:

    > my @GetVolumeInformation_P = qw( sRootPath osVolName lVolName
    > ouSerialNum
    > ouMaxNameLen ouFsFlags osFsType
    > lFsType );
    > my @GetVolumeInformation = ( 'C:/', undef, undef,
    > undef, undef, undef, undef,
    > undef );


    Blegh, make that:

    my @GetVolumeInformation_P =
    qw( sRootPath osVolName lVolName ouSerialNum
    ouMaxNameLen ouFsFlags osFsType lFsType );

    my @GetVolumeInformation =
    ( 'C:/', undef, undef, undef,
    undef, undef, undef, undef );

    (just reformatted)

    --
    Affijn, Ruud

    "Gewoon is een tijger."
     
    Dr.Ruud, Apr 1, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    5
    Views:
    561
    Steve C. Orr [MVP, MCSD]
    May 17, 2005
  2. Hylander

    To reuse or not to reuse....

    Hylander, Feb 26, 2004, in forum: Java
    Replies:
    0
    Views:
    441
    Hylander
    Feb 26, 2004
  3. code reuse and design reuse

    , Feb 7, 2006, in forum: C Programming
    Replies:
    16
    Views:
    1,066
    Malcolm
    Feb 12, 2006
  4. VP

    How to find a word in wordlist

    VP, Nov 1, 2003, in forum: Perl Misc
    Replies:
    9
    Views:
    172
    Brad Baxter
    Nov 3, 2003
  5. TheDigitalroot

    I wanna make wordlist cutter

    TheDigitalroot, Mar 30, 2013, in forum: Python
    Replies:
    5
    Views:
    139
    TheDigitalroot
    Mar 30, 2013
Loading...

Share This Page