[ID 20010821.002] bug in getpwnam

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

0
carsten
8/21/2001 1:49:04 PM
perl.perl5.porters 47902 articles. 1 followers. Follow

3 Replies
167 Views

Similar Articles

[PageSpeed] 21

Carsten Grohmann <carsten.grohmann@dr-baldeweg.de> wrote:

> 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 )[.

Your problem is that Perl is interpreting the '(' following the chown
as the start of a call to the function chown(). You can fix this
by either giving a real pair of parantheses for the function call,
or by starting the first argument with something other than '(', eg

chown( (getpwnam ($username))[2], (getgrnam ($groupname))[2], $destfile);
or
chown +(getpwnam ($username))[2], (getgrnam ($groupname))[2], $destfile;

Dave M.

0
davem
8/21/2001 4:05:52 PM
 This is not a bug...this is an application of the if it looks like a
function it is a function thingy...if you add an extra set of parens around
the entire chown expression that doesn't work I would imagine it will start
working.

ex.
chown (getpwnam ($username))[2], (getgrnam($groupname))[2], $destfile;
doesn't work because the only argument passed to chown is
(getpwnam($username))...if you wrote it like
chown ( (getpwnam($username))[2], (getgrnam($groupname))[2], $destfile);
it should work.

Note that in the version that does work, you don't have those extra parens.

-----Original Message-----
From: Carsten Grohmann
To: perl5-porters@perl.org
Cc: perlbug@rfi.net
Sent: 8/21/2001 8:49 AM
Subject: [ID 20010821.002] bug in getpwnam

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/bi
n
    PERL_BADLANG (unset)
    SHELL=/bin/bash
0
Tanton
8/21/2001 4:06:13 PM
Carsten Grohmann <carsten.grohmann@dr-baldeweg.de> wrote at Tue, 21 Aug
2001 15:49:04 +0200:

> 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 )[.

Because "chown (..." parses as a function name followed by the opening
parenthesis for this function call.

This is correct:
  chown( (getpwnam($username))[2], (getgrnam($groupname))[2], $destfile
);

Both [ID 20010821.003] and [ID 20010821.002] can be closed.

Cheers,
-Wolfgang
0
Wolfgang
8/23/2001 6:34:30 AM
Reply:

Similar Artilces:

[ID 20010821.003] bug in getpwnam
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 th...

[ID 19991117.002] a bug in perl5 under Linux
I find this problem when I use perl5 compiled under Linux. % perl -v This is perl, version 5.005_03 built for i386-linux % perl print 8473018401 % 524288 , "\n" 524287 The correct answer should be 33. Guoheng Wei _.-. Sr. Component Design Eng. '( ^{_} ( Intel Corp. `~\`-----'\ 512-314-0053 )_)---)_) >I find this problem when I use perl5 compiled under Linux. >% perl -v >This is perl, version 5.005_03 built for i386-linux >% perl >print 8473018401 ...

[ID 19991216.002] do-while bug
I did a quick search of the PerlBug Database, but I didn't find anything that seems related. I found a bug, or at least unexpected operation, from the last operator inside a do-while loop. % perl -v This is perl, version 5.005_03 built for i386-linux Copyright 1987-1999, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5.0 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using `man perl' or `perldoc perl'. If y...

[ID 19991210.002] installation bug
Hi! I am trying to install perl on a sparc 10 with Solaris 2.6 I use " sh Configure -Dcc=gcc -des " It repeats the following infinitely current working directory /kumudu/lan/app/pkg/prl/perl5.005_03 /bin/sh Makefile.SH Extracting Makefile (with variable substitutions) make depend MAKEDEPEND= sh ./makedepend MAKE=make Please help me to sort this out. Thanks KUMUDU ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com Kumudu Suriyaarachchi writes: > > Hi! > I am trying to install perl on a...

[ID 20000918.002] bug in bugtron
This is a bug report for perl from michael@etla.org, generated with the help of perlbug 1.20 running under perl 5.00404. ----------------------------------------------------------------- [Please enter your report here] The perl bugtron contains a bug at the following url: http://bugs.perl.org/admin/perlbug.cgi?req=bid&bid=19990805.004&bid=19990807.006&bid=19990809.001&bid=19990809.007&bid=19990809.008&bid=19990810.001&bid=19990811.004&bid=19990818.003&bid=19990820.001&bid=19990820.003&bid=19990820.006&bid=19990820.008&bid=19990...

[ID 20000719.002] Require Bug?
I have been trying to add Perl CGI to my web site. I'm running: Mandrake Linux with Perl 5.005_03 When using the perl command require to include a file, the variables assigned in an array do not always become available to the file using the require. Just keep clicking on reload or refresh in your browser and watch the values change. I used: Netscape 4.72 and Explorer 4.0 an example is at http://www.mhiconn.net/perl/requiretest/requiretest.pl and the files used are at: http://www.mhiconn.net/perl/requiretest/ Please Help...thanks Bruce Chidester ___________...

[Fwd: Bug ID 20010311.002]
Mathew, No Probs. Just mail to p5p with the bugid in the subject, and it will be tracked. I've forwarded this one for you. Ciao Richard -------- Original Message -------- Subject: Bug ID 20010311.002 Date: Mon, 12 Mar 2001 22:10:01 -0500 From: "Matthew O. Persico" <persicom@acedsl.com> To: richard@rfi.net I couldn't figure out how to post a folowup on the perlbug site. Sorry for the personal mail. I uninstalled the VC++5.0 SP3 compiler and re-installed just the base, no service pack. There were no problems with compilation. Seems like...

[ID 20011203.002] Bug Report
--Boundary_(ID_o5KxOHjeze4zagdNwe5gxg) Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_TgNKl9JjPO2vSYjIsmKSGg)" --Boundary_(ID_TgNKl9JjPO2vSYjIsmKSGg) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT This is a bug report for perl from jeremie.banier@swift.com, generated with the help of perlbug 1.26 running under perl 5.00503. ----------------------------------------------------------------- [Please enter your report here] As I try to compile a very simple test program, I get a Parsing Exception. Here's the code causi...

Problem with webservice method Bug.comment for "ids" set as bug ids
Hi, I need to access Bugzilla (Version of Bugzilla used bugzilla 4.0rc) webservice interface from a Java application. I have written a webservice client with Apache XML RPC. To fetch a comment for bug, I am using the following code : Map paramMap = new HashMap(); paramMap.put("ids", comments); //where comments is String[] of bug ids ArrayList<Object> paramBug = new ArrayList<Object>(); paramBug.add(paramMap); HashMap result = (HashMap) rpcClient.execute("Bug.comments", paramBug); Web service call returns an empty HashMap, with no comments....

[ID 20001130.002] a new test bug
message body with perl mentioned category=core should keep 'xxxyz@here.and.gone.today' as Message-Id remap to perl5-porters@perl.org subject should get [ID ...] with an ack=no somewhere ?-) X-Header: should be maintained etc. --- sig ...

[ID 20020407.002] Bug (?) and patch for DProf
This is a bug report for perl from tom@thecap.org, generated with the help of perlbug 1.33 running under perl v5.6.1. ----------------------------------------------------------------- I tried running the following script: #!/usr/bin/perl use strict; use LWP::UserAgent; use HTTP::Request; my $ua = LWP::UserAgent->new(); my $req = HTTP::Request->new('GET', 'http://www.google.com/'); my $res = $ua->simple_request( $req ); print "Response is: '".substr($res->as_string(),0,100)."'\n"; print "Context is: "; ...

[ID 20000908.002] perlipc documentation bug.
--------------FA9A6CC6103CC5B938D66EC3 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I test the examples in perlipc.pod with client server and found a bug in multi-threaded version. Here are perl-V.res and perlipc.pod.patch attached files. Best regards. --------------FA9A6CC6103CC5B938D66EC3 Content-Type: text/plain; charset=us-ascii; name="perl-V.res" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="perl-V.res" Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration: Platform: ...

[ID 19991005.002] bug with die under linux
Hi, It looks there's a bug with die under linux. It can be evidenced with the following code: ============================================================================= #!/usr/bin/perl # save STDERR and redirect to /dev/null open OLDSTDERR, ">&STDERR" or die "STDERR dup failed: $!"; close STDERR; open STDERR, ">/dev/null" or die "STDERR redirect failed: $!"; # restore previous state close STDERR; open STDERR, ">&OLDSTDERR" or die "STDERR restoration failed: $!"; close OLDSTDERR; pri...

[ID 20001115.002] possible refcount bug
This is a bug report for perl from anno4000@lublin.zrz.tu-berlin.de, generated with the help of perlbug 1.28 running under perl v5.6.0. ----------------------------------------------------------------- [Please enter your report here] The code below demonstrates that under certain circumstances an object (a hashref) can turn up n destruction with components missing (undefined) that were defined before. This happens when a reference to the object is stored in a package variable. In the code example, the object that turns up damaged during destruction is of class Obj in variab...

Web resources about - [ID 20010821.002] bug in getpwnam - perl.perl5.porters

Ex-Central African ruler's party backs presidential candidate
By Crispin Dembassa-Kette BANGUI (Reuters) - The political party of Central Africa's ousted leader threw its support on Tuesday behind former ...

Here's the Irish island where they filmed the most gorgeous scene from the new Star Wars
While the "Star Wars" movies take place in a galaxy far, far away, they use real locations on earth to fill in for other planets. One of the ...

Watch SpaceX's Falcon 9 rocket return to Earth after launching satellites to space
SpaceX signaled a new phase of the private sector space race on Monday evening, when it launched a payload of satellites to space and successfully ...

Tim Cook: Apple will not budge on encryption
With many U.S. lawmakers calling for an end to encryption, Tim Cook has decided to reiterate Apple’s stance on the matter. Apple’s CEO believes ...

New York City detective among six US troops killed in Afghanistan
Reuters New York City detective among six US troops killed in Afghanistan Reuters NEW YORK A New York City police detective volunteering for ...

Xbox Store Countdown Brings ‘Biggest Sale Ever’ For Xbox One And 360
Microsoft kicked off the Xbox Store Countdown sale on Tuesday, which it dubs the “biggest sale ever.” Deals for Xbox One and Xbox 360 games will ...

FDA overturns 30-year ban on blood donations by gay men
Reuters FDA overturns 30-year ban on blood donations by gay men Reuters The United States government on Monday overturned its 30-year ban ...

Apple adds iPhones to Lightning to USB Camera Adapter compatibility list, photo import works under iOS ...
Two weeks after quietly updating the Lightning to SD Card Camera Reader to USB 3.0 and adding iPhone support to the formerly iPad-only accessory, ...

Freddie Gray Trial: Porter’s Re-Trial Set for June 13
Absent immunity Porter can decline to testify in the other Freddie Gray trials

Vegas hit-run suspect Lakeisha Holloway was lauded for turning life around
CNN Vegas hit-run suspect Lakeisha Holloway was lauded for turning life around CNN (CNN) Before police said she intentionally drove onto a ...

Resources last updated: 12/22/2015 4:22:05 PM