トップページphp
988コメント342KB

CGIに依存しないPerlの話題一般

■ このスレッドは過去ログ倉庫に格納されています
0001名無しさん@お腹いっぱい。2001/05/31(木) 21:49ID:bKRSBFew
・コマンドラインからのPerl活用
・モジュール、オブジェクト指向プログラミング
・Perl6や.NET対応など
・各種GUIツールキット(Perl/Tk, Gtk-Perlなど)
・他言語による拡張(Inline::*, XS, Swigなど)

についてマターリと語り合うスレッドです。

#CGI関連の話題は、なるべく専用スレッドで。
0213_gunzip01/09/13 05:59ID:???
#!/usr/bin/perl -w

use Inline C;

our @filesystems = ("/dev/sda1", "/dev/fd0", "/dev/cdrom");

foreach my $fs (@filesystems){
    print "$fs: ", is_mounted($fs) ? "mounted\n" : "not mounted\n";
}

__END__
__C__
#include <mntent.h>

#define TABLE_FILE "/etc/mtab"

int is_mounted(char *fsname)
{
    FILE *fp;
    struct mntent *ent;

    if((fp = setmntent(TABLE_FILE, "r")) == NULL)
        return -1; /* error */

     while((ent = getmntent(fp)) != NULL){
        if( !strcmp(ent->mnt_fsname, fsname) )
             return 1; /* found */
     }

    endmntent(fp);
    return 0; /* not found */
}
0214_gunzip01/09/13 06:03ID:???
#!/usr/bin/perl

use Inline C;

sub is_little_endian2()
{
    return pack("I", 1) eq pack("V", 1);
}

sub is_little_endian3()
{
    return vec(pack("I", 1), 0, 1);
}

__END__
__C__

int is_little_endian1()
{
    union {
        int val;
        char byte[sizeof(int)];
    } u;
    u.val = 1;
    return u.byte[0] == 1;
}
■ このスレッドは過去ログ倉庫に格納されています