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

Re: [ID 20010821.002] bug in getpwnam

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
August 21, 2001 09:06
Subject:
Re: [ID 20010821.002] bug in getpwnam
Message ID:
200108211605.RAA10149@gizmo.fdgroup.co.uk
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.


Thread Previous | 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