develooper Front page | perl.perl5.porters | Postings from August 2001

[ID 20010821.002] bug in getpwnam

Thread Next
From:
Carsten Grohmann
Date:
August 21, 2001 08:50
Subject:
[ID 20010821.002] bug in getpwnam
Message ID:
3B8266D0.946F3642@dr-baldeweg.de
This is a bug report for perl from carsten.grohmann@dr-baldeweg.de,
generated with the help of perlbug 1.28 running under perl v5.6.0.

-----------------------------------------------------------------

I want to change the owner of a file by using the following command:
  chown (getpwnam ($username))[2], (getgrnam ($groupname))[2], 
$destfile;
and I get an syntax error near )[. After I replace the getpwnam call by
a sub
which uses the same expression, it works fine. The function getgrnam
works in
the same context without problems.  Two smilar functions
one runs the other not - is this ok so?

Thanks 
  Carsten

PS: Please delete the first mail, the emailaddress are wrong.

This example can show your my problem:

#!/usr/bin/perl -w
# you should create this file first
my $destfile="/tmp/test";
my $username="nobody";
my $groupname="nogroup";

sub user_to_uid {  return (getpwnam($_[0]))[2]; }  

$username="nobody";
$groupname="nogroup";
# the follow line runs
chown user_to_uid($username), (getgrnam ($groupname))[2],  $destfile;
# the follow line don't run
#chown (getpwnam ($username))[2], (getgrnam ($groupname))[2], 
$destfile;


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=none
---
Site configuration information for perl v5.6.0:

Configured by root at Fri Jan 19 05:40:28 GMT 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.0, archname=i586-linux
    uname='linux manson 2.4.0 #1 wed aug 2 20:22:26 gmt 2000 i686
unknown '
    config_args='-ds -e -Dprefix=/usr -Di_db -Di_dbm -Di_ndbm -Di_gdbm'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef
usesocks=undef
  Compiler:
    cc='cc', optimize='-O2 -pipe', gccversion=2.95.2 19991024 (release)
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccflags ='-fno-strict-aliasing -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lc -lcrypt
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.6.0:
    /usr/lib/perl5/5.6.0/i586-linux
    /usr/lib/perl5/5.6.0
    /usr/lib/perl5/site_perl/5.6.0/i586-linux
    /usr/lib/perl5/site_perl/5.6.0
    /usr/lib/perl5/site_perl
    .

---
Environment for perl v5.6.0:
    HOME=/root
    LANG (unset)
    LANGUAGE (unset)
    LC_CTYPE=de_DE
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
   
PATH=/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games/bin:/usr/games:/opt/gnome/bin:/opt/kde2/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About