[31549] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2808 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 8 14:09:30 2010

Date: Mon, 8 Feb 2010 11:09:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 8 Feb 2010     Volume: 11 Number: 2808

Today's topics:
    Re: A revolt against NYC school closures <marc.girod@gmail.com>
    Re: BEGIN and lexicals <bol@adv.magwien.gv.at>
        can I get a new httpd.conf file <delcofiftyfive@gmail.com>
    Re: can I get a new httpd.conf file <RedGrittyBrick@spamweary.invalid>
    Re: can I get a new httpd.conf file <tadmc@seesig.invalid>
    Re: can I get a new httpd.conf file <delcofiftyfive@gmail.com>
    Re: can I get a new httpd.conf file <jurgenex@hotmail.com>
    Re: Math not working <dmw@coder.cl>
    Re: perl and sendmail speed problem [Net::SMTP & 127.0. <anfi@onet.eu>
        perl and sendmail speed problem <jcharth@gmail.com>
    Re: perl and sendmail speed problem <tadmc@seesig.invalid>
    Re: perl and sendmail speed problem <jcharth@gmail.com>
    Re: perl and sendmail speed problem <rkb@i.frys.com>
    Re: perl and sendmail speed problem <jcharth@gmail.com>
    Re: Perl, ip6 and XML RPC <frederic.perrin@resel.fr>
    Re: Python's Reference And Internal Model Of Computing  <keramida@ceid.upatras.gr>
        shebang and ubuntu <Phred@example.invalid>
    Re: shebang and ubuntu <josef.moellers@ts.fujitsu.com>
    Re: shebang and ubuntu <jurgenex@hotmail.com>
    Re: shebang and ubuntu <Huge@nowhere.much.invalid>
    Re: shebang and ubuntu <cartercc@gmail.com>
    Re: shebang and ubuntu (Seymour J.)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 7 Feb 2010 13:23:19 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: A revolt against NYC school closures
Message-Id: <ba2b0e8c-f0d1-4fbf-a0c8-4f38b22320d5@l19g2000yqb.googlegroups.com>

On Feb 7, 9:34=A0am, arsalan <aijazali2...@gmail.com> wrote:
> A WIDE coalition of New Yorkers made their voices heard in the last
> week of January against New York City Mayor Bloomberg's decision to
> close 19 schools--disproportionately large schools located in
> communities of color.

But... closures *are* supported in perl, aren't they?

Marc


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

Date: Mon, 8 Feb 2010 13:26:05 +0100
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: BEGIN and lexicals
Message-Id: <1265631986.532944@proxy.dienste.wien.at>

"cate" <catebekensail@yahoo.com> schrieb im Newsbeitrag 
news:1373c121-018f-4f0c-9fb6-56e7fed5a4af@p24g2000yqm.googlegroups.com...
>I have a large list of my vars that I would like to get out of the
> way; place them at the end of the script - kinda a class thing.
>
> Is there a way to use BEGIN some how?   Something like this.  I
> suspect you can't, but I'm asking the pros.

You must _declare_ them always before first using them. Once declared,
you can use a BEGIN block to assign initial values before actual use.

use strict;
my ($var1, $var2);

 ...<code using $var1>...
 ...<code using $var2>...

BEGIN {
  $var1 = 'Initvalue for var1';
  $var2 = 'Initivalue for var2';
}
__END__

However, if the number of variables used this way is large, I'd consider
to use a hash:

my %hash;  # Just one declaration!

 ...<code using $hash{var1}>...
 ...<code using $hash{var2}>...

BEGIN {
  $hash{var1} = 'Initvalue for var1';
  $hash{var2} = 'Initvalue for var2';
}

A hash also allows you to assign the particular values in more efficient 
ways.

Regards, Ferry

-- 
Ing. Ferry Bolhar
Magistrat der Stadt Wien - MA 14
A-1010 Wien
E-Mail: ferdinand.bolhar-nordenkampf@wien.gv.at 




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

Date: Mon, 8 Feb 2010 08:33:21 -0800 (PST)
From: Myron <delcofiftyfive@gmail.com>
Subject: can I get a new httpd.conf file
Message-Id: <af9f7664-4317-4230-9652-639c2955ad4e@a5g2000yqi.googlegroups.com>

I have changed mine so many times that I no longer know what I
changed.
How do I get a new, clean one for OpenBSD 4.6 apache.?


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

Date: Mon, 08 Feb 2010 17:34:58 +0000
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: can I get a new httpd.conf file
Message-Id: <4b704b44$0$2483$db0fefd9@news.zen.co.uk>

On 08/02/2010 16:33, Myron wrote:
> I have changed mine so many times that I no longer know what I
> changed.
> How do I get a new, clean one for OpenBSD 4.6 apache.?

comp.lang.perl.misc is the wrong newsgroup for this.

I'd look at comp.unix.bsd.misc, comp.unix.bsd.openbsd.misc and  The 
Apache support forums.

Followup set to c.u.b.o.m.


Personally I always copy httpd.conf to httpd.conf.orig as part of my 
server install procedure.

Sometimes I put configuration files like this into a version control 
system (RCS in my case - it's requirements are minimal).

I know that doesn't help now, but maybe it will in future?


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

Date: Mon, 08 Feb 2010 11:48:41 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: can I get a new httpd.conf file
Message-Id: <slrnhn0jd2.8nh.tadmc@tadbox.sbcglobal.net>

Myron <delcofiftyfive@gmail.com> wrote:
> I have changed mine so many times that I no longer know what I
> changed.
> How do I get a new, clean one for OpenBSD 4.6 apache.?


How does your question relate to the Perl programming language?


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"


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

Date: Mon, 8 Feb 2010 10:30:53 -0800 (PST)
From: Myron <delcofiftyfive@gmail.com>
Subject: Re: can I get a new httpd.conf file
Message-Id: <ac553790-db3c-435a-8876-4555d30bf2d6@u9g2000yqb.googlegroups.com>

On Feb 8, 11:48=A0am, Tad McClellan <ta...@seesig.invalid> wrote:
> Myron <delcofiftyf...@gmail.com> wrote:
> > I have changed mine so many times that I no longer know what I
> > changed.
> > How do I get a new, clean one for OpenBSD 4.6 apache.?
>
> How does your question relate to the Perl programming language?
>
> --
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"

I have just started a home OpenBSD server running Apache and want to
use Perl.
Apache is working, Perl is working, but CGI dosen't.  I suspect file
execution permissions on www.

output of error_log
[Sun Feb  7 21:38:35 2010] [error] [client 192.168.1.1] Premature end
of script headers: /users/delco/test.cgi
Xten.cgi is forbiden but Xten.html shows text, so apperently it is
using the extention to determine to execute.
http://72.206.97.182:81/~delco/xten.cgi =3DYou don't have permission to
access /~delco/xten.cgi on this server
http://72.206.97.182:81/cgi-bin/test.cgi  =3Dinternal error or
misconfiguration
http://72.206.97.182:81/~delco/first.cgi  =3DYou don't have permission
to access /~delco/first.cgi on this server.
http://72.206.97.182:81/cgi-bin/first.pl  =3Dinternal server error
http://72.206.97.182:81/xten.html =3Dshows the text of the script.


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

Date: Mon, 08 Feb 2010 10:40:55 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: can I get a new httpd.conf file
Message-Id: <uhm0n59b80vgitg5kgsaio7l5juornep8i@4ax.com>

Myron <delcofiftyfive@gmail.com> wrote:
[ httpd.conf ]
>I have changed mine so many times that I no longer know what I
>changed.
>How do I get a new, clean one for OpenBSD 4.6 apache.?

Perl doesn't need nor uses httpd.conf at all, why do you think this has
anything to do with Perl? 

I would suggest to ask in a NG that actually deals with web servers.

jue


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

Date: Mon, 08 Feb 2010 01:34:42 -0300
From: Daniel Molina Wegener <dmw@coder.cl>
Subject: Re: Math not working
Message-Id: <cNGdnUefaJL_CfLWnZ2dnUVZ_hJi4p2d@giganews.com>

On Sáb 06 Feb 2010 19:42,
Ben Morrow wrote:

> 
> Quoth dmw@coder.cl:
>> -----BEGIN xxx SIGNED MESSAGE-----
> 
> Please don't do that here.

  Sorry for that...

> 
>>   Well, the error is clear. The /find()/ method returns a Nodelist
>> object, so you are trying to miltiply $books and $pages which are
>> both XML::LibXML::Nodelist objects.
>> 
>>   Try using something like:
>> 
>> $books = int($books->string_value());
> 
> The 'int()' is unnecessary, and unclear (since it implies
> $books->string_value might be a float we wish to truncate to an
> integer),

  Well, I've proposed the integer conversion since the program
is counting the amount of books, and certainly I the program do
not exposes any calculation with that value. So I've assumed that
Faith was requiring an integer value.

  Thanks for your clarification...

> 
> Ben

Best regards,
-- 
Daniel Molina Wegener <dmw [at] coder [dot] cl>
Software Architect, System Programmer & Web Developer
Phone: +1 (510) 629-4267 | Blog: http://coder.cl/


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

Date: Mon, 08 Feb 2010 16:32:11 +0100
From: Andrzej Adam Filip <anfi@onet.eu>
Subject: Re: perl and sendmail speed problem [Net::SMTP & 127.0.0.1:25]
Message-Id: <440i10xjqy-A28@william.huge.strangled.net>

joe <jcharth@gmail.com> wrote:
> Hi I wrote a function that uses
> sendmail -oi -t -f
> to send emails. It is currently taking a long time to send many
> messages. Is there a way to speed this up?. Here is the code of the
> function
>
> sub sendEmail
> {
> [...]
> open(MAIL, "|$sendmail -oi -t -f $rawsender[0]");
> [...]
> }

Have you considered using Net::SMTP to send many messages over single
SMTP session to 127.0.0.1? 
[you may use direct execution of sendmail as "fallback" delivery method]

*Be warned*: sending a few hundredth+ messages "may create noticeable load".
[sendmail daemon by default forks separate process per single message delivery]

-- 
[pl>en Andrew] Andrzej Adam Filip : anfi@onet.eu : Andrzej.Filip@gmail.com
"There is no statute of limitations on stupidity."
  -- Randomly produced by a computer program called Markov3.


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

Date: Mon, 8 Feb 2010 06:13:16 -0800 (PST)
From: joe <jcharth@gmail.com>
Subject: perl and sendmail speed problem
Message-Id: <dddabba0-3fa9-4134-9ba0-44e53f32bc0f@m16g2000yqc.googlegroups.com>

Hi I wrote a function that uses
sendmail -oi -t -f
to send emails. It is currently taking a long time to send many
messages. Is there a way to speed this up?. Here is the code of the
function

sub sendEmail
{
my ($to, $from, $bcc, $subj, $message) = @_;
my $sendmail = '/usr/lib/sendmail';
my $line;
my @rawsender = $from;
open(MAIL, "|$sendmail -oi -t -f $rawsender[0]");

print MAIL "From: $from\n";

print MAIL "To: $to\n";
if (length($bcc) > 0){
print MAIL "Bcc: $bcc \n";
}
$message =~ s/\r/\n/g;


$message =~ s/!\*EMAIL\*!/$to/g;

$message =~ s/\r/\n/g;


my @lines = split("\n", $message);
print MAIL "Subject: $subj\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-Type: text/html;\n";
print MAIL "     charset=\"windows-1252\"\n";

foreach $line (@lines){
print MAIL "$line \n";
}
close(MAIL);
}


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

Date: Mon, 08 Feb 2010 09:21:32 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: perl and sendmail speed problem
Message-Id: <slrnhn0ap5.8ik.tadmc@tadbox.sbcglobal.net>

joe <jcharth@gmail.com> wrote:

> sub sendEmail
> {
> my ($to, $from, $bcc, $subj, $message) = @_;
> my $sendmail = '/usr/lib/sendmail';
> my $line;


You should declare variables in the smallest possible scope.

For this variable, it should be declared in the foreach that
uses it as the loop control variable (below).


> my @rawsender = $from;
> open(MAIL, "|$sendmail -oi -t -f $rawsender[0]");


Why do you copy it to an array?

You should always, yes *always*, check the return value from open().

See also:

    perldoc -q "pipe open"


> $message =~ s/\r/\n/g;

faster and more clear:

    $message =~ tr/\r/\n/;


> my @lines = split("\n", $message);


Here you remove all of the newlines...


> print MAIL "Subject: $subj\n";
> print MAIL "MIME-Version: 1.0\n";
> print MAIL "Content-Type: text/html;\n";
> print MAIL "     charset=\"windows-1252\"\n";
>
> foreach $line (@lines){

    foreach my $line (@lines){

> print MAIL "$line \n";


 ... here you put all of the newlines back.

What is the point of removing newlines only to put them back?

Do you really require a space character at the end of each line?

I don't see where you output a blank line to mark the end of the headers...


> close(MAIL);


You should check the return value from close() here too.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"


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

Date: Mon, 8 Feb 2010 07:33:40 -0800 (PST)
From: joe <jcharth@gmail.com>
Subject: Re: perl and sendmail speed problem
Message-Id: <1bf185c9-d6d0-4dcf-9ac7-f81c2418b56c@a1g2000vbl.googlegroups.com>

Thanks for the tips. Is it possible to run the sub in a separate
thread and have multiple emails sent at the same time? If so how can I
do this? I am sending a few thousand messages so I am concern about
send mail not being able to handle this too.


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

Date: Mon, 8 Feb 2010 08:11:39 -0800 (PST)
From: Ron Bergin <rkb@i.frys.com>
Subject: Re: perl and sendmail speed problem
Message-Id: <5d71407d-004f-4189-afbb-7c34c9c2816b@s25g2000prd.googlegroups.com>

On Feb 8, 7:33=A0am, joe <jcha...@gmail.com> wrote:
> Thanks for the tips. Is it possible to run the sub in a separate
> thread and have multiple emails sent at the same time? If so how can I
> do this? I am sending a few thousand messages so I am concern about
> send mail not being able to handle this too.

I've never used it myself, but you might want to look at using
Mail::Bulkmail

http://search.cpan.org/~jimt/Mail-Bulkmail-3.12/Bulkmail.pm


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

Date: Mon, 8 Feb 2010 10:11:56 -0800 (PST)
From: joe <jcharth@gmail.com>
Subject: Re: perl and sendmail speed problem
Message-Id: <6ab7fae9-70c5-498e-9b7d-970254aa4664@f8g2000yqn.googlegroups.com>

I tested this script with only 10 messages and it worked but I am not
sure if it can handle a few thousands

use Thread qw(:DEFAULT async yield);

$thread = Thread->new(\&sendEmail($_,$in_sender,'',$in_subject,
$in_letter));


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

Date: Mon, 8 Feb 2010 19:14:36 +0100
From: =?UTF-8?B?RnLDqWTDqXJpYw==?= Perrin <frederic.perrin@resel.fr>
Subject: Re: Perl, ip6 and XML RPC
Message-Id: <20100208191436.3237bc96@girafe.home>

Le Vendredi 05 =C3=A0 23:45, Fr=C3=A9d=C3=A9ric Perrin a =C3=A9crit :
> I want to talk to an XML RPC service over ip6 (the server doesn't
> listen over ip4). However, with the three modules I tried so far
> (XML::RPC, RPC::XML, Frontier::RPC::Client), it tries to do the
> request over ip4, even though the hostname I gave only resolve to
> ip6.

A (the?) solution is to =C2=AB use Net::INET6Glue::INET_is_INET6 =C2=BB bef=
ore
use()ing the actual XML RPC module. It worked with all the three
modules I tried.

Question: why isn't this the default, in 2010?

--=20
Fred



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

Date: Sun, 07 Feb 2010 04:33:57 +0100
From: Giorgos Keramidas <keramida@ceid.upatras.gr>
Subject: Re: Python's Reference And Internal Model Of Computing Languages
Message-Id: <877hqplnx6.fsf@kobe.laptop>

On Fri, 05 Feb 2010 14:39:12 -0600, David Thole <dthole@gmail.com> wrote:
> Yeah, I'm relatively new to Usenet so far...maybe 2 weeks old, so I
> have only begun to realize that he's actually a troll.  How to killify
> him is something I'm not sure of yet...but seeing some spam get
> through, plus stuff like this makes me want to check up on how to do
> it.  I also need to figure out how to make my client include previous
> posts, quoted at least somewhat.  heh, using gnus...so I'm sure it's
> possible to get this configured right.

Hi David,

I don't know which one of the two groups you are reading more often,
hence the cross-post.  Please check the difference between 'f' and 'F'
in the Gnus manual.  The later quotes everything, and you get to strip
the bits yourself.

HTH,
Giorgos



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

Date: Mon, 08 Feb 2010 01:55:28 -0700
From: Phred Phungus <Phred@example.invalid>
Subject: shebang and ubuntu
Message-Id: <7ta1s0FibpU1@mid.individual.net>

My perfect sunday began with an Americano, 2 chocolate-glazed donuts, 
and perl.  That may sound very decadent, but that held me food-wise 
until the Super Bowl.

I have a common problem that files tell my that I'm not allowed there. 
If I recall my reading, I was referred to chmod().  I've looked at that 
several times, and it doesn't seem to take, at least as a man page.

Does perl have a way to manipulate these file permissions?

dan@dan-desktop:~/source42$ perl t1.pl
t1.pl out b1.c~ t1.pl~ .. . b1.c
dan@dan-desktop:~/source42$ ./t1.pl
bash: ./t1.pl: Permission denied
dan@dan-desktop:~/source42$ cat t1.pl
#!/usr/bin/perl

opendir(THISDIR, ".") or die "tja $!";
@allfiles = readdir THISDIR;
closedir THISDIR;
print "@allfiles\n";

# perl t1.pl
dan@dan-desktop:~/source42$


-- 
fred


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

Date: Mon, 08 Feb 2010 10:12:48 +0100
From: Josef Moellers <josef.moellers@ts.fujitsu.com>
Subject: Re: shebang and ubuntu
Message-Id: <hkokig$ttm$1@nntp.fujitsu-siemens.com>

Phred Phungus wrote:
> My perfect sunday began with an Americano, 2 chocolate-glazed donuts,
> and perl.  That may sound very decadent, but that held me food-wise
> until the Super Bowl.
> 
> I have a common problem that files tell my that I'm not allowed there.
> If I recall my reading, I was referred to chmod().  I've looked at that
> several times, and it doesn't seem to take, at least as a man page.
> 
> Does perl have a way to manipulate these file permissions?
> 
> dan@dan-desktop:~/source42$ perl t1.pl
> t1.pl out b1.c~ t1.pl~ .. . b1.c
> dan@dan-desktop:~/source42$ ./t1.pl
> bash: ./t1.pl: Permission denied
> dan@dan-desktop:~/source42$ cat t1.pl
> #!/usr/bin/perl
> 
> opendir(THISDIR, ".") or die "tja $!";
> @allfiles = readdir THISDIR;
> closedir THISDIR;
> print "@allfiles\n";
> 
> # perl t1.pl
> dan@dan-desktop:~/source42$

Have you tried
chmod u+x t1.pl

It has nothing to do with perl.

Josef
-- 
These are my personal views and not those of Fujitsu Technology Solutions!
Josef Möllers (Pinguinpfleger bei FTS)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html


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

Date: Mon, 08 Feb 2010 03:41:13 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: shebang and ubuntu
Message-Id: <6etvm5lcufiq79n5g6bajmd4j4umm6vpka@4ax.com>

Phred Phungus <Phred@example.invalid> wrote:
>I have a common problem that files tell my that I'm not allowed there. 
>If I recall my reading, I was referred to chmod().  I've looked at that 
>several times, and it doesn't seem to take, at least as a man page.
>
>Does perl have a way to manipulate these file permissions?
>
>dan@dan-desktop:~/source42$ perl t1.pl

What is "~/source42$"? Is that part of your prompt? That is confusing to
say the least!

>t1.pl out b1.c~ t1.pl~ .. . b1.c
>dan@dan-desktop:~/source42$ ./t1.pl
>bash: ./t1.pl: Permission denied

That error message is a bash error message, it has nothing to do with
Perl. 
There can be more obscure reasons but most likely you didn't set the
file permissions for t1.pl to executable.

>dan@dan-desktop:~/source42$ cat t1.pl
>#!/usr/bin/perl

One of those more obscure reasons could be that /usr/bin/perl itself is
not executable for you and this is being masked by a different perl
being executed in your first command (did you try 'which perl'?).

jue


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

Date: 8 Feb 2010 12:49:11 GMT
From: Huge <Huge@nowhere.much.invalid>
Subject: Re: shebang and ubuntu
Message-Id: <7tafi6Fu3sU1@mid.individual.net>

On 2010-02-08, Jürgen Exner <jurgenex@hotmail.com> wrote:
> Phred Phungus <Phred@example.invalid> wrote:
>>I have a common problem that files tell my that I'm not allowed there. 
>>If I recall my reading, I was referred to chmod().  I've looked at that 
>>several times, and it doesn't seem to take, at least as a man page.
>>
>>Does perl have a way to manipulate these file permissions?
>>
>>dan@dan-desktop:~/source42$ perl t1.pl
>
> What is "~/source42$"? Is that part of your prompt? That is confusing to
> say the least!
>
>>t1.pl out b1.c~ t1.pl~ .. . b1.c
>>dan@dan-desktop:~/source42$ ./t1.pl
>>bash: ./t1.pl: Permission denied
>
> That error message is a bash error message, it has nothing to do with
> Perl. 
> There can be more obscure reasons but most likely you didn't set the
> file permissions for t1.pl to executable.

IOW,

chmod +x ./t1.pl



-- 
                             219361311
       email me, if you must, at huge {at} huge (dot) org <dot> uk]


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

Date: Mon, 8 Feb 2010 06:46:18 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: shebang and ubuntu
Message-Id: <a4a2badd-9fa2-4213-be6f-b933ae432619@g28g2000yqh.googlegroups.com>

On Feb 8, 3:55=A0am, Phred Phungus <Ph...@example.invalid> wrote:
> I have a common problem that files tell my that I'm not allowed there.
> If I recall my reading, I was referred to chmod(). =A0I've looked at that
> several times, and it doesn't seem to take, at least as a man page.

I find chmod very easy and intuitive, but I never use the + or -
syntax, I always use the octal syntax, e.g., 'chomd 755 some.file'

Read is 4, write is 2, and execute is 1, so that 755 meas that owner
has read, write, and execute permissions, and that group and other has
read and execute permissions. 644 means that owner has read and write
permissions and group and other only has read. 700 locks out everyone
except the owner.

CC.


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

Date: Mon, 08 Feb 2010 08:54:28 -0500
From: Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid>
Subject: Re: shebang and ubuntu
Message-Id: <4b701794$2$fuzhry+tra$mr2ice@news.patriot.net>

In <7ta1s0FibpU1@mid.individual.net>, on 02/08/2010
   at 01:55 AM, Phred Phungus <Phred@example.invalid> said:

>Does perl have a way to manipulate these file permissions?

Sure; chmod. But wouldn't it be easier to do it in the shell? From
perlfunc:

Changes the permissions of a list of files.  The first element of the list
must be the numerical mode, which should probably be an octal number, and
which definitely should not a string of octal digits: 0644 is okay, '0644'
is not.  Returns the number of files successfully changed.  See also /oct,
if all you have is a string. 

    $cnt = chmod 0755, 'foo', 'bar';
    chmod 0755, @executables;
    $mode = '0644'; chmod $mode, 'foo';      # !!! sets mode to
                                             # --w----r-T
    $mode = '0644'; chmod oct($mode), 'foo'; # this is better
    $mode = 0644;   chmod $mode, 'foo';      # this is best


You can also import the symbolic S_I* constants from the Fcntl module: 

    use Fcntl ':mode';



    chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, @executables;
    # This is identical to the chmod 0755 of the above example.

-- 
Shmuel (Seymour J.) Metz, SysProg and JOAT  <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to spamtrap@library.lspace.org



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 2808
***************************************


home help back first fref pref prev next nref lref last post