Click here to get back home

question about "requiring" linux/stat.ph

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
question about "requiring" linux/stat.ph szr 02-14-2008
Get Chitika Premium
Posted by szr on February 14, 2008, 4:57 am
Please log in for more thread options
Hello. I am wrapping up a rather large server migration job I was tasked
with. Everything is running wonderfully.

One thing I noticed in a few legacy Perl scripts that had <code>require
"linux/stat.ph";</code> near the top and making use of functions like
S_ISLNK, resulting in this sort of error, which can be easily
reproduced:

$ perl -e 'require "linux/stat.ph"; &S_ISLNK'
Undefined subroutine &main::S_ISLNK called at -e line 1.


It seems the problem is coming from line 7 in
/usr/local/perl5.8.8/lib/site_perl/5.8.8/i686-linux-64int-ld/linux/stat.ph

if(defined( &__KERNEL__) || !defined( &__GLIBC__) ||
((defined(&__GLIBC__) ? &__GLIBC__ : 0) < 2)) {



Here is what the values for those defines are:

$ perl -e 'require
"/usr/local/perl5.8.8/lib/site_perl/5.8.8/i686-linux-64int-ld/linux/stat.ph";
print "[", &__KERNEL__, "]"'
Undefined subroutine &main::__KERNEL__ called at -e line 1.

$ perl -e 'require
"/usr/local/perl5.8.8/lib/site_perl/5.8.8/i686-linux-64int-ld/linux/stat.ph";
print "[", &__GLIBC__, "]"'
[2]


&__KERNEL__ is not defined and &__GLIBC__ is 2



If I comment out line 7 (and it's closing brace) then all the &S_ subs
(ie, S_ISLNK) are found properly, but I don't want to use such a hack, I
would like to fix the problem itself.

Thanks for any help.


-------------------------------
Perl Info Below
-------------------------------

$ perl -v

This is perl, v5.8.8 built for i686-linux-64int-ld
[...]

$ perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=linux, osvers=2.4.20-8, archname=i686-linux-64int-ld
uname='linux srlinux 2.4.20-8 #1 thu mar 13 17:54:28 est 2003 i686
i686 i386 gnulinux '
config_args='-Dprefix=/usr/local/perl5.8.8 -Duse64bitint'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=define use64bitall=undef uselongdouble=define
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags
='-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64
-I/usr/include/gdbm',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -I/usr/local/include
-I/usr/include/gdbm'
ccversion='', gccversion='3.2.2 20030222 (Red Hat Linux 3.2.2-5)',
gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long long', ivsize=8, nvtype='long double', nvsize=12,
Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.3.2.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.3.2'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl):
Compile-time options: PERL_MALLOC_WRAP USE_64_BIT_INT USE_LARGE_FILES
USE_LONG_DOUBLE USE_PERLIO
Built under linux
Compiled at Feb 11 2008 01:12:44
%ENV:
PERL5LIB="/home/SR/perllib:"
@INC:
/home/SR/perllib
/usr/local/perl5.8.8/lib/5.8.8/i686-linux-64int-ld
/usr/local/perl5.8.8/lib/5.8.8
/usr/local/perl5.8.8/lib/site_perl/5.8.8/i686-linux-64int-ld
/usr/local/perl5.8.8/lib/site_perl/5.8.8
/usr/local/perl5.8.8/lib/site_perl
.

--
szr



Posted by John W. Krahn on February 14, 2008, 8:21 am
Please log in for more thread options
szr wrote:
> Hello. I am wrapping up a rather large server migration job I was tasked
> with. Everything is running wonderfully.
>
> One thing I noticed in a few legacy Perl scripts that had <code>require
> "linux/stat.ph";</code> near the top and making use of functions like
> S_ISLNK, resulting in this sort of error, which can be easily
> reproduced:
>
> $ perl -e 'require "linux/stat.ph"; &S_ISLNK'
> Undefined subroutine &main::S_ISLNK called at -e line 1.

Change:

require "linux/stat.ph";

To:

use Fcntl;


perldoc -f stat
[ SNIP ]
You can import symbolic mode constants ("S_IF*") and functions
("S_IS*") from the Fcntl module:



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall

Posted by szr on February 14, 2008, 12:10 pm
Please log in for more thread options
John W. Krahn wrote:
> szr wrote:
>> Hello. I am wrapping up a rather large server migration job I was
>> tasked with. Everything is running wonderfully.
>>
>> One thing I noticed in a few legacy Perl scripts that had
>> <code>require "linux/stat.ph";</code> near the top and making use of
>> functions like S_ISLNK, resulting in this sort of error, which can
>> be easily reproduced:
>>
>> $ perl -e 'require "linux/stat.ph"; &S_ISLNK'
>> Undefined subroutine &main::S_ISLNK called at -e line 1.
>
> Change:
>
> require "linux/stat.ph";
>
> To:
>
> use Fcntl;
>
>
> perldoc -f stat
> [ SNIP ]
> You can import symbolic mode constants ("S_IF*") and functions
> ("S_IS*") from the Fcntl module:
>

Thanks.

use Fcntl ':mode';

did the trick :)


--
szr



Posted by Ben Morrow on February 14, 2008, 6:59 pm
Please log in for more thread options

> Hello. I am wrapping up a rather large server migration job I was tasked
> with. Everything is running wonderfully.
>
> One thing I noticed in a few legacy Perl scripts that had <code>require
> "linux/stat.ph";</code> near the top and making use of functions like
> S_ISLNK, resulting in this sort of error, which can be easily
> reproduced:
>
> $ perl -e 'require "linux/stat.ph"; &S_ISLNK'
> Undefined subroutine &main::S_ISLNK called at -e line 1.

You should be importing these constants from Fcntl with non-ancient
versions of Perl. h2ph can't always cope with the complicated
conditional definitions in Linux' system headers, so sometimes the
generated .ph files are not useable.

perl -MFcntl=:mode -le'print S_ISLNK(S_IFLNK)'

Generally speaking you can just use -l instead, though.

Ben


Posted by szr on February 29, 2008, 3:46 pm
Please log in for more thread options
Ben Morrow wrote:
>> Hello. I am wrapping up a rather large server migration job I was
>> tasked with. Everything is running wonderfully.
>>
>> One thing I noticed in a few legacy Perl scripts that had
>> <code>require "linux/stat.ph";</code> near the top and making use of
>> functions like S_ISLNK, resulting in this sort of error, which can
>> be easily reproduced:
>>
>> $ perl -e 'require "linux/stat.ph"; &S_ISLNK'
>> Undefined subroutine &main::S_ISLNK called at -e line 1.
>
> You should be importing these constants from Fcntl with non-ancient
> versions of Perl. h2ph can't always cope with the complicated
> conditional definitions in Linux' system headers, so sometimes the
> generated .ph files are not useable.
>
> perl -MFcntl=:mode -le'print S_ISLNK(S_IFLNK)'
>
> Generally speaking you can just use -l instead, though.
>
> Ben

Thank you for the information.

-szr



Similar ThreadsPosted
Requiring perl scripts December 14, 2004, 10:50 pm
Requiring Lexical $_ / Obliterating Global $_? September 12, 2008, 12:58 pm
I want to ask you the most important question of your life. The question is: Are you saved? It is not a question of how good you are, nor if you are a church member, but are you saved? Are you sure you will go to Heaven when you die? The reason some peopl May 22, 2005, 10:11 am
I want to ask you the most important question of your life. The question is: Are you saved? It is not a question of how good you are, nor if you are a church member, but are you saved? Are you sure you will go to Heaven when you die? The reason some peopl May 24, 2005, 8:49 am
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you are, April 21, 2005, 1:25 pm
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you are, April 22, 2005, 3:33 pm
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you are, April 24, 2005, 6:50 pm
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you are, May 1, 2005, 11:27 am
MS Perl question -- how to use hacked script to work correctly(was Question on loops and return values or sumpin) December 8, 2004, 12:59 pm
Question September 9, 2004, 11:05 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap