[28473] in Perl-Users-Digest
Perl-Users Digest, Issue: 9837 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 12 14:06:06 2006
Date: Thu, 12 Oct 2006 11:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 12 Oct 2006 Volume: 10 Number: 9837
Today's topics:
Are indirect DIRHANDLEs closed automatically? <jl_post@hotmail.com>
Re: CGI.pm v2.91 bug with $q->p()? <evillen@gmail.com>
Re: CGI.pm v2.91 bug with $q->p()? (reading news)
Re: CGI.pm v2.91 bug with $q->p()? (reading news)
Re: CGI.pm v2.91 bug with $q->p()? <evillen@gmail.com>
Finding uneven file permissions with Perl UnixMaestro@gmail.com
Re: Finding uneven file permissions with Perl <mritty@gmail.com>
Re: Finding uneven file permissions with Perl <joe@inwap.com>
Re: Finding uneven file permissions with Perl UnixMaestro@gmail.com
Re: Finding uneven file permissions with Perl <uri@stemsystems.com>
Re: howto detect printables in a string - norwegian cha anno4000@radom.zrz.tu-berlin.de
Re: Input into Net::Netmask yankeeinexile@gmail.com
Re: IO::Prompt with Keymap <dale.gerdemann@googlemail.com>
Re: IO::Prompt with Keymap anno4000@radom.zrz.tu-berlin.de
Re: Net::SSH stuck <glex_no-spam@qwest-spam-no.invalid>
Re: openGL-0.5 perl module problem <glex_no-spam@qwest-spam-no.invalid>
Re: openGL-0.5 perl module problem <glex_no-spam@qwest-spam-no.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 12 Oct 2006 09:23:54 -0700
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Are indirect DIRHANDLEs closed automatically?
Message-Id: <1160670233.983326.207690@i42g2000cwa.googlegroups.com>
Hi,
I've found in the Camel book (where it discusses the open()
function) that you can pass it an indirect filehandle as an undefined
variable, like this:
open(my $fh, ">logfile") or die ...
and Perl will automatically define that variable for you. It goes on
to say that one advantage of this is that the filehandle will be closed
automatically when there are no further references to it (typically
when the variable goes out of scope).
That's nice to know. And "perldoc -f opendir" says that opendir()
can also take a variable (as an indirect dirhandle).
But neither that perldoc nor the Camel book's documentation of
opendir() mention if the indirect DIRHANDLE will be closed
automatically when there are no further references to it.
So my question is: If I write code like this:
opendir(my $dirHandle, '/tmp')
or die "Cannot open '/tmp': $!\n";
will the DIRHANDLE just opened be closed by the end of $dirHandle's
scope (presuming there are no other references to it)? I would think
it does get closed, but I'm unable to find any documentation explicitly
stating that.
Thanks for any input.
-- Jean-Luc
------------------------------
Date: 12 Oct 2006 08:12:38 -0700
From: "evillen@gmail.com" <evillen@gmail.com>
Subject: Re: CGI.pm v2.91 bug with $q->p()?
Message-Id: <1160665958.928412.186120@m73g2000cwd.googlegroups.com>
evillen@gmail.com wrote:
> I am getting a warning for reasons that I can't understand and I
> hesitantly believe may be a bug with CGI.pm v2.91
>
> Synopsis - in certain circumstances if I use the CGI.pm paragraph
> method $q->p() my program will work correctly but I get a version of
> the following warning in my webserver error.log:
>
> filename.cgi: Use of uninitialized value in join or string at (eval 19)
>
> line 15.
>
> If I simply substitute $q->p() with "<br>" I get no warnings. The very
> simple CGI code below demonstrates the problem, simply comment out
> either of the final two "print" commands to see the behaviour.
>
> It is possible that this behaviour relates to a problem with CGI.pm
> v2.91 described here http://tinyurl.com/npta8 although I may be wrong
> ;-)
>
> Thanks for any help
> NJH
>
> Test code - run directly from browser as filename.cgi
> ----------------
>
> #!c:/perl/bin/perl.exe -w
>
> use strict;
> use diagnostics;
> use CGI;
> use CGI::Carp qw(fatalsToBrowser);
>
> my $q = new CGI;
>
> #-------------------------------------------------
> # Print the html header
>
> print $q->header;
> print <<END_HTML;
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
>
> <form method="post" enctype="multipart/form-data"
> action="dev_test.cgi">
> Type something here: <INPUT TYPE=text NAME=foo SIZE=50
> MAXLENGTH=50><INPUT TYPE=submit VALUE="Submit"></P>
> </form>
> END_HTML
>
> #-------------------------------------------------
> #The "print" command below works fine using "<br>"
> #print "You typed: ", $q->param("foo"), "<br>";
>
> #The "print" command below creates the following warning using $q->p()
> #"Use of uninitialized value in join or string at (eval 19) line 15."
> print "You typed: ", $q->param("foo"), $q->p();
Simply changing $q->p(); to $q->p(""); works - so I guess it's a user
problem...
------------------------------
Date: Thu, 12 Oct 2006 15:29:22 GMT
From: "Mumia W. (reading news)" <paduille.4059.mumia.w@earthlink.net>
Subject: Re: CGI.pm v2.91 bug with $q->p()?
Message-Id: <mbtXg.8226$Y24.3730@newsread4.news.pas.earthlink.net>
On 10/12/2006 04:12 AM, evillen@gmail.com wrote:
> I am getting a warning for reasons that I can't understand and I
> hesitantly believe may be a bug with CGI.pm v2.91
>
> Synopsis - in certain circumstances if I use the CGI.pm paragraph
> method $q->p() my program will work correctly but I get a version of
> the following warning in my webserver error.log:
>
> filename.cgi: Use of uninitialized value in join or string at (eval 19)
>
> line 15.
>
> If I simply substitute $q->p() with "<br>" I get no warnings. The very
> simple CGI code below demonstrates the problem, simply comment out
> either of the final two "print" commands to see the behaviour.
>
> It is possible that this behaviour relates to a problem with CGI.pm
> v2.91 described here http://tinyurl.com/npta8 although I may be wrong
> ;-)
>
> Thanks for any help
> NJH
>
> Test code - run directly from browser as filename.cgi
> ----------------
>
> #!c:/perl/bin/perl.exe -w
>
> use strict;
> use diagnostics;
> use CGI;
> use CGI::Carp qw(fatalsToBrowser);
>
> my $q = new CGI;
>
> #-------------------------------------------------
> # Print the html header
>
> print $q->header;
> print <<END_HTML;
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
>
> <form method="post" enctype="multipart/form-data"
> action="dev_test.cgi">
> Type something here: <INPUT TYPE=text NAME=foo SIZE=50
> MAXLENGTH=50><INPUT TYPE=submit VALUE="Submit"></P>
> </form>
> END_HTML
>
> #-------------------------------------------------
> #The "print" command below works fine using "<br>"
> #print "You typed: ", $q->param("foo"), "<br>";
>
> #The "print" command below creates the following warning using $q->p()
> #"Use of uninitialized value in join or string at (eval 19) line 15."
> print "You typed: ", $q->param("foo"), $q->p();
>
I cannot reproduce this behavior with Perl 5.8.4 and CGI.pm $VERSION 3.04 .
Here, calling p() with no parameters produces an empty paragraph tag:
use CGI;
my $q = new CGI;
print $q->p('Want to see an empty paragraph?'), "\n";
print $q->p(), "\n";
OUTPUT:
<p>Want to see an empty paragraph?</p>
<p />
--
Mumia W.
paduille.4059.mumia.w@earthlink.net
This is a temporary e-mail to help me catch some s-p*á/m.
------------------------------
Date: Thu, 12 Oct 2006 16:09:15 GMT
From: "Mumia W. (reading news)" <paduille.4059.mumia.w@earthlink.net>
Subject: Re: CGI.pm v2.91 bug with $q->p()?
Message-Id: <LMtXg.12917$UG4.7004@newsread2.news.pas.earthlink.net>
On 10/12/2006 10:29 AM, Mumia W. (reading news) wrote:
> On 10/12/2006 04:12 AM, evillen@gmail.com wrote:
>> I am getting a warning for reasons that I can't understand and I
>> hesitantly believe may be a bug with CGI.pm v2.91
>>
>> Synopsis - in certain circumstances if I use the CGI.pm paragraph
>> method $q->p() my program will work correctly but I get a version of
>> the following warning in my webserver error.log:
>>
>> filename.cgi: Use of uninitialized value in join or string at (eval 19)
>>
>> line 15.
>>
>> If I simply substitute $q->p() with "<br>" I get no warnings. The very
>> simple CGI code below demonstrates the problem, simply comment out
>> either of the final two "print" commands to see the behaviour.
>>
>> It is possible that this behaviour relates to a problem with CGI.pm
>> v2.91 described here http://tinyurl.com/npta8 although I may be wrong
>> ;-)
>>
>> Thanks for any help
>> NJH
>>
>> Test code - run directly from browser as filename.cgi
>> ----------------
>>
>> #!c:/perl/bin/perl.exe -w
>>
>> use strict;
>> use diagnostics;
>> use CGI;
>> use CGI::Carp qw(fatalsToBrowser);
>>
>> my $q = new CGI;
>>
>> #-------------------------------------------------
>> # Print the html header
>>
>> print $q->header;
>> print <<END_HTML;
>>
>> <?xml version="1.0" encoding="iso-8859-1"?>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>> <html xmlns="http://www.w3.org/1999/xhtml">
>>
>> <form method="post" enctype="multipart/form-data"
>> action="dev_test.cgi">
>> Type something here: <INPUT TYPE=text NAME=foo SIZE=50
>> MAXLENGTH=50><INPUT TYPE=submit VALUE="Submit"></P>
>> </form>
>> END_HTML
>>
>> #-------------------------------------------------
>> #The "print" command below works fine using "<br>"
>> #print "You typed: ", $q->param("foo"), "<br>";
>>
>> #The "print" command below creates the following warning using $q->p()
>> #"Use of uninitialized value in join or string at (eval 19) line 15."
>> print "You typed: ", $q->param("foo"), $q->p();
>>
>
> I cannot reproduce this behavior with Perl 5.8.4 and CGI.pm $VERSION 3.04 .
>
> Here, calling p() with no parameters produces an empty paragraph tag:
>
> use CGI;
> my $q = new CGI;
> print $q->p('Want to see an empty paragraph?'), "\n";
> print $q->p(), "\n";
>
> OUTPUT:
> <p>Want to see an empty paragraph?</p>
> <p />
>
>
Just to be more clear:
#!/usr/bin/perl -w
use strict;
use diagnostics;
use CGI;
my $q = new CGI;
print $q->p('Want to see an empty paragraph?'), "\n";
print $q->p(), "\n";
__END__
The above program does not produce any warnings or errors for me.
--
Mumia W.
paduille.4059.mumia.w@earthlink.net
This is a temporary e-mail to help me catch some s-p*á/m.
------------------------------
Date: 12 Oct 2006 09:10:35 -0700
From: "evillen@gmail.com" <evillen@gmail.com>
Subject: Re: CGI.pm v2.91 bug with $q->p()?
Message-Id: <1160669434.947781.252290@e3g2000cwe.googlegroups.com>
Mumia W. (reading news) wrote:
> On 10/12/2006 04:12 AM, evillen@gmail.com wrote:
> > I am getting a warning for reasons that I can't understand and I
> > hesitantly believe may be a bug with CGI.pm v2.91
> >
> > Synopsis - in certain circumstances if I use the CGI.pm paragraph
> > method $q->p() my program will work correctly but I get a version of
> > the following warning in my webserver error.log:
> >
> > filename.cgi: Use of uninitialized value in join or string at (eval 19)
> >
> > line 15.
> >
> > If I simply substitute $q->p() with "<br>" I get no warnings. The very
> > simple CGI code below demonstrates the problem, simply comment out
> > either of the final two "print" commands to see the behaviour.
> >
> > It is possible that this behaviour relates to a problem with CGI.pm
> > v2.91 described here http://tinyurl.com/npta8 although I may be wrong
> > ;-)
> >
> > Thanks for any help
> > NJH
> >
> > Test code - run directly from browser as filename.cgi
> > ----------------
> >
> > #!c:/perl/bin/perl.exe -w
> >
> > use strict;
> > use diagnostics;
> > use CGI;
> > use CGI::Carp qw(fatalsToBrowser);
> >
> > my $q =3D new CGI;
> >
> > #-------------------------------------------------
> > # Print the html header
> >
> > print $q->header;
> > print <<END_HTML;
> >
> > <?xml version=3D"1.0" encoding=3D"iso-8859-1"?>
> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > <html xmlns=3D"http://www.w3.org/1999/xhtml">
> >
> > <form method=3D"post" enctype=3D"multipart/form-data"
> > action=3D"dev_test.cgi">
> > Type something here: <INPUT TYPE=3Dtext NAME=3Dfoo SIZE=3D50
> > MAXLENGTH=3D50><INPUT TYPE=3Dsubmit VALUE=3D"Submit"></P>
> > </form>
> > END_HTML
> >
> > #-------------------------------------------------
> > #The "print" command below works fine using "<br>"
> > #print "You typed: ", $q->param("foo"), "<br>";
> >
> > #The "print" command below creates the following warning using $q->p()
> > #"Use of uninitialized value in join or string at (eval 19) line 15."
> > print "You typed: ", $q->param("foo"), $q->p();
> >
>
> I cannot reproduce this behavior with Perl 5.8.4 and CGI.pm $VERSION 3.04=
=2E
>
> Here, calling p() with no parameters produces an empty paragraph tag:
>
> use CGI;
> my $q =3D new CGI;
> print $q->p('Want to see an empty paragraph?'), "\n";
> print $q->p(), "\n";
>
> OUTPUT:
> <p>Want to see an empty paragraph?</p>
> <p />
>
>
> --
> Mumia W.
> paduille.4059.mumia.w@earthlink.net
> This is a temporary e-mail to help me catch some s-p*=E1/m.
Hi Mumia
If I use your code as below, I still get the same warning. Like I said
in my earlier mail AFAIK it seems to be specific to v2.91, I guess it's
not a big deal putting an empty string in place.
Thanks
#!c:/perl/bin/perl.exe -w
use strict;
use diagnostics;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $q =3D new CGI;
#-------------------------------------------------
# Print the html header
print $q->header;
print <<END_HTML;
<?xml version=3D"1.0" encoding=3D"iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=3D"http://www.w3.org/1999/xhtml">
END_HTML
print $q->p('Want to see an empty paragraph?'), "\n";
print $q->p(), "\n";
------------------------------
Date: 12 Oct 2006 07:32:55 -0700
From: UnixMaestro@gmail.com
Subject: Finding uneven file permissions with Perl
Message-Id: <1160663575.303197.67410@i3g2000cwc.googlegroups.com>
I'm tyring to use Perl to find uneven file permissions in a specified
directory. Uneven in this connotation means that the second or third
digit is greater than the first digit, e.g. 475 or 470.
I've found that I can use stat to get the mode, but the mode is in
octal. I used a mask to get the mode back to what I'm used to seeing
for file permissions, as shown below:
============================================================
#!/usr/bin/perl -w
use IO::File;
$filename = 'file.test.foo';
$filehandle = new IO::File;
$filehandle->open() or die "Dude, I could not open your file
$filename");
($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime,
$ctime, $blksize, $blocks) = $filehandle->stat;
printf "$filename is set with permissions: %04o\n", $mode & 07777; \n";
============================================================
Output "file.test.foo is set with permissions: 0750"
My question then is two fold. First, what do I need to do in order to
loop through a file system from the command line (e.g. ./perl.script
/usr)? Second, what algorithm do I need to use in order to compare the
second and third digits with the first (assuming I am using 750)?
Thanks in advance.
------------------------------
Date: 12 Oct 2006 08:58:55 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Finding uneven file permissions with Perl
Message-Id: <1160668735.229965.246010@c28g2000cwb.googlegroups.com>
UnixMaestro@gmail.com wrote:
> I'm tyring to use Perl to find uneven file permissions in a specified
> directory. Uneven in this connotation means that the second or third
> digit is greater than the first digit, e.g. 475 or 470.
>
> I've found that I can use stat to get the mode, but the mode is in
> octal. I used a mask to get the mode back to what I'm used to seeing
> for file permissions, as shown below:
> ============================================================
> #!/usr/bin/perl -w
Always
use strict;
in your scripts, and replace -w with:
use warnings;
> use IO::File;
No need for this module in any relatively recent version of perl
> $filename = 'file.test.foo';
>
> $filehandle = new IO::File;
> $filehandle->open() or die "Dude, I could not open your file
> $filename");
No reason to open the file just to call stat() on it, but also, if you
are opening a file, you should include the reason for the error - the
$! variable.
Fare more important than any of that, though, is that there's no way
the code above works at all. You did not associate the name of the file
with the filehandle at any point.
Please post REAL sample code.
>
> ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime,
> $ctime, $blksize, $blocks) = $filehandle->stat;
Do not bother using more variables than you need:
my $mode = (stat $filename)[2];
> printf "$filename is set with permissions: %04o\n", $mode & 07777; \n";
> ============================================================
>
> Output "file.test.foo is set with permissions: 0750"
>
> My question then is two fold. First, what do I need to do in order to
> loop through a file system from the command line (e.g. ./perl.script
> /usr)?
Generally the File::Find module is what you want for recursing:
use File::Find;
sub wanted {
# here, $_ is the current name of the file,
# $File::Find::name is the full path to the file, and
# $File::Find::dir is the directory of the current file.
# do whatever you want to do to the current file, using the above
three variables.
}
#assuming you're passing the dirs to search on the command line, as
above:
find(\&wanted, @ARGV);
> Second, what algorithm do I need to use in order to compare the
> second and third digits with the first (assuming I am using 750)?
You want to separate out the digits? Well, there's a few ways I can
think of to do it. The one that makes the most sense to me is just to
use the modulus and division operators, just as though you were
comparing digits in a decimal number:
my $user = ($mode / 8**2) % 8;
my $group = ($mode / 8) % 8;
my $other = $mode % 8;
Another way would be of course to just use split:
my ($user, $group, $other) = (split //, $mode)[-3, -2, -1];
Or even a regexp:
my ($user, $group, $other) = ($mode =~ /(\d)(\d)(\d)$/);
Paul Lalli
------------------------------
Date: Thu, 12 Oct 2006 09:42:59 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Finding uneven file permissions with Perl
Message-Id: <W9-dnXsPJfxX7bPYnZ2dnUVZ_oGdnZ2d@comcast.com>
Paul Lalli wrote:
> my $user = ($mode / 8**2) % 8;
> my $group = ($mode / 8) % 8;
> my $other = $mode % 8;
Another way of getting the same results by using different
operators is:
my($user,$group,$other) = (($mode&0700)>>16, ($mode&070)>>8), $mode&07);
> Another way would be of course to just use split:
>
> my ($user, $group, $other) = (split //, $mode)[-3, -2, -1];
>
> Or even a regexp:
>
> my ($user, $group, $other) = ($mode =~ /(\d)(\d)(\d)$/);
$mode is not octal. It is usually displayed as octal, but
it comes as an integer that has to be explicitly converted to
a string of octal digits.
Both of those string-based solutions require doing this first:
$mode = sprintf '%03o',$mode;
-Joe
------------------------------
Date: 12 Oct 2006 09:57:09 -0700
From: UnixMaestro@gmail.com
Subject: Re: Finding uneven file permissions with Perl
Message-Id: <1160672229.052666.203660@c28g2000cwb.googlegroups.com>
Paul,
thanks for the help, it is greatly appreciated.
as a test, I used:
#!/usr/bin/perl -w
use File::Find;
no warnings File::Find;
find(\&getFiles, @ARGV);
sub getFiles {
my $mode = (stat $File::Find::name)[2];
my $user = ($mode / 8**2) % 8;
my $group = ($mode / 8) % 8;
my $other = $mode % 8;
printf "$File::Find::name has permissions of:" . $user . $group .
$other . "\n";
}
I'll tinker with the uneven file permissions later on tonight, but so
far, this works.
I started jotting down file permissions I should not see and ended up
with 18 so far that I don't want to see (not including SUID, SGID or
the sticky bit). I'm thinking that my first assessment of comparing
the digits to be nebulous. It might be better spent looking for
patterns I don't want to see, like [4-7][1-3][0-7]. If you have any
recommendations that would make this faster (besides not doing it) I
would like to hear them.
Paul Lalli wrote:
> UnixMaestro@gmail.com wrote:
> > I'm tyring to use Perl to find uneven file permissions in a specified
> > directory. Uneven in this connotation means that the second or third
> > digit is greater than the first digit, e.g. 475 or 470.
> >
> > I've found that I can use stat to get the mode, but the mode is in
> > octal. I used a mask to get the mode back to what I'm used to seeing
> > for file permissions, as shown below:
> > ============================================================
> > #!/usr/bin/perl -w
>
> Always
> use strict;
> in your scripts, and replace -w with:
> use warnings;
>
> > use IO::File;
>
> No need for this module in any relatively recent version of perl
>
> > $filename = 'file.test.foo';
> >
> > $filehandle = new IO::File;
> > $filehandle->open() or die "Dude, I could not open your file
> > $filename");
>
> No reason to open the file just to call stat() on it, but also, if you
> are opening a file, you should include the reason for the error - the
> $! variable.
>
> Fare more important than any of that, though, is that there's no way
> the code above works at all. You did not associate the name of the file
> with the filehandle at any point.
>
> Please post REAL sample code.
>
> >
> > ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime,
> > $ctime, $blksize, $blocks) = $filehandle->stat;
>
> Do not bother using more variables than you need:
>
> my $mode = (stat $filename)[2];
>
> > printf "$filename is set with permissions: %04o\n", $mode & 07777; \n";
> > ============================================================
> >
> > Output "file.test.foo is set with permissions: 0750"
> >
> > My question then is two fold. First, what do I need to do in order to
> > loop through a file system from the command line (e.g. ./perl.script
> > /usr)?
>
> Generally the File::Find module is what you want for recursing:
>
> use File::Find;
> sub wanted {
> # here, $_ is the current name of the file,
> # $File::Find::name is the full path to the file, and
> # $File::Find::dir is the directory of the current file.
> # do whatever you want to do to the current file, using the above
> three variables.
> }
> #assuming you're passing the dirs to search on the command line, as
> above:
> find(\&wanted, @ARGV);
>
> > Second, what algorithm do I need to use in order to compare the
> > second and third digits with the first (assuming I am using 750)?
>
> You want to separate out the digits? Well, there's a few ways I can
> think of to do it. The one that makes the most sense to me is just to
> use the modulus and division operators, just as though you were
> comparing digits in a decimal number:
>
> my $user = ($mode / 8**2) % 8;
> my $group = ($mode / 8) % 8;
> my $other = $mode % 8;
>
> Another way would be of course to just use split:
>
> my ($user, $group, $other) = (split //, $mode)[-3, -2, -1];
>
> Or even a regexp:
>
> my ($user, $group, $other) = ($mode =~ /(\d)(\d)(\d)$/);
>
>
> Paul Lalli
------------------------------
Date: Thu, 12 Oct 2006 13:44:34 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Finding uneven file permissions with Perl
Message-Id: <x7slhtsa2l.fsf@mail.sysarch.com>
>>>>> "JS" == Joe Smith <joe@inwap.com> writes:
JS> my($user,$group,$other) = (($mode&0700)>>16, ($mode&070)>>8), $mode&07);
^^ ^
those are bit shift integers and a bit (sic) too large methinks. try 6
and 3 (here is where octal knowledge helps :).
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 12 Oct 2006 16:25:14 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: howto detect printables in a string - norwegian characterset
Message-Id: <4p78jaFhhdmbU2@news.dfncis.de>
Jürgen Exner <jurgenex@hotmail.com> wrote in comp.lang.perl.misc:
> anno4000@radom.zrz.tu-berlin.de wrote:
> > RanLi <gladpike@hotmail.com> wrote in comp.lang.perl.misc:
> >> i have a problem. I need to detect printables in a string.
> >> using perl and regular expressions.
> >> problem is that I could have norwegian characters in this string, and
>
> > The meaning of "\w" is "all characters that can appear in a Perl
> > identifier". That excludes special national characters and includes
> > "_". That's not what you want.
>
> Could you please provide some reference?
> I'm asking because this behaviour would be contrary to the documentation
> where it is clearly stated:
>
> If "use locale" is in effect, the
> list of alphabetic characters generated by "\w" is taken from the
> current locale.
I was wrong then. Thanks for the correction and sorry about the
misinformation.
>
> > Define the characters you want to allow in an explicit character
> > class:
> >
> > /^[a-zæøåA-ZÆØÅ]+$/
> >
> > If you have a locale that supports your characters,
> >
> > use locale;
> > /^[[:alpha:]]+$/
>
> Why do you suggest [:alpha:] when the OP is explicitely asking for printable
> characters? Wouldn't [:print:] be better?
He(?) said "printable" and used "/w". I assumed he actually meant
"characters that appear in the words of the language".
Anno
------------------------------
Date: 12 Oct 2006 09:48:53 -0500
From: yankeeinexile@gmail.com
Subject: Re: Input into Net::Netmask
Message-Id: <87ejtdbne2.fsf@gmail.com>
Tad McClellan <tadmc@augustmail.com> writes:
> Mumia W. (reading news) <paduille.4059.mumia.w@earthlink.net> wrote:
> > On 10/11/2006 06:08 PM, mdeggers@gmail.com wrote:
>
> >> @blocks = ('10.10.10.0/24','10.10.20.0/24');
>
> >> for ($i = 0; $i < 3; $i++ )
> >
> > Your "@blocks" array contains two elements, but you process four.
> ^^^^
>
> Three, m'lord.
>
Five is *RIGHT OUT*
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer software consists of only two components: ones and
zeros, in roughly equal proportions. All that is required is to
sort them into the correct order.
------------------------------
Date: 12 Oct 2006 06:49:57 -0700
From: "Dale" <dale.gerdemann@googlemail.com>
Subject: Re: IO::Prompt with Keymap
Message-Id: <1160660997.882205.285490@b28g2000cwb.googlegroups.com>
anno4000@radom.zrz.tu-berlin.de wrot
> Apply a special key map to what? It should be trivial to make it
> print a Cyrillic prompt, but if you expect the user to type Latin
> and see Cyrillic, I doubt if there is such a provision.
Thanks Anno, and I'm sorry if I wan't entirely clear. Of course, the
way you describe it here, it sounds a little silly. But see what the
docs for IO::Promt say about echoing.
-e -echo <str> What to echo for each char typed
This allows only a fixed string to be echoed for each typed character.
Not exactly very flexible. I'm simply asking if there's a more flexible
Prompt module somewhere that would allow the echoed character to be
dependent on the character typed.
> You could try to make IO::Prompt use a modified version of
> Term::Readkey and do the translation there.
Okay. But how do I tell a module that it's got to read my own modified
version of some other module? If I have to edit Term::Readkey anyway, I
might as well just stick in my keymapping stuff directly.
Dale
------------------------------
Date: 12 Oct 2006 16:18:19 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: IO::Prompt with Keymap
Message-Id: <4p786bFhhdmbU1@news.dfncis.de>
Dale <dale.gerdemann@googlemail.com> wrote in comp.lang.perl.misc:
>
> anno4000@radom.zrz.tu-berlin.de wrot
>
> > Apply a special key map to what? It should be trivial to make it
> > print a Cyrillic prompt, but if you expect the user to type Latin
> > and see Cyrillic, I doubt if there is such a provision.
>
> Thanks Anno, and I'm sorry if I wan't entirely clear. Of course, the
> way you describe it here, it sounds a little silly. But see what the
> docs for IO::Promt say about echoing.
>
> -e -echo <str> What to echo for each char typed
>
> This allows only a fixed string to be echoed for each typed character.
> Not exactly very flexible. I'm simply asking if there's a more flexible
> Prompt module somewhere that would allow the echoed character to be
> dependent on the character typed.
It's for password prompting.
> > You could try to make IO::Prompt use a modified version of
> > Term::Readkey and do the translation there.
>
> Okay. But how do I tell a module that it's got to read my own modified
> version of some other module?
Use your own Perl library, say /my/lib. Put the modified module
in /my/lib/Term/Readkey.pm. Put "use lib '/my/lib';" before the
relevant other "user" statements in your program. Done.
There are many variants and alternatives to this approach.
> If I have to edit Term::Readkey anyway, I
> might as well just stick in my keymapping stuff directly.
Since IO::Prompt already has the -echo mechanism in place it may be
simpler (or not) to extend that. The appended patch shows sketchily
how it can be done. (Newsreaders will probably break it.) With it
applied to IO::Prompt, you can also specify -echo as a subref which
will be called with each character and whose return value is echoed.
Anno
--- /usr/local/lib/perl5/site_perl/5.8.7/IO/Prompt.pm 2006-02-17 05:59:21.000000000 +0100
+++ lib/IO/Prompt.pm 2006-10-12 17:51:41.000000000 +0200
@@ -341,7 +341,7 @@
}
else {
print {$OUT} $_ and select undef, undef, undef, rand $speed
- for map { defined $echo ? $echo : _visualize($_) } split "";
+ for map { defined $echo ? $echo : _visualize(_echo( $echo, $_)) } split "";
}
}
return scalar @_;
@@ -432,7 +432,7 @@
print {$OUT} (
defined $echo
&& $flags->{-menu} ? $echo
- : defined $echo ? $echo x length($flags->{-default})
+ : defined $echo ? _echo( $echo, $next) x length($flags->{-default})
: '['.$flags->{-default}.']'
);
print {$OUT} $nlstr;
@@ -443,7 +443,7 @@
$newlines .= $nlstr;
}
else {
- print {$OUT}(defined $echo ? $echo : $next);
+ print {$OUT}(defined $echo ? _echo( $echo, $next) : $next);
}
}
else {
@@ -604,6 +604,11 @@
return $res;
}
+sub _echo {
+ my ( $echo, $char) = @_;
+ ref $echo ? $echo->( $char) : $echo;
+}
+
package IO::Prompt::ReturnVal;
use overload
------------------------------
Date: Thu, 12 Oct 2006 11:13:44 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Net::SSH stuck
Message-Id: <452e6950$0$597$815e3792@news.qwest.net>
EZP wrote:
> Hi all,
> I'm running the script below in windows command line and the script is
> stuck.
> (I need to run the unix task from the windows command line.)
>
>
> #!/usr/bin/perl
> use strict; use warnings;
> use Net::SSH qw (ssh issh sshopen2 sshopen3);
There's no need to import issh, sshopen2, or sshopen3, unless you're
going to use them and you do that so you can simply make a call to
"ssh_cmd" instead of Net::SSH::ssh_cmd. Not that it'll hurt anything,
but it's redundant to do both.
>
>
> print Net::SSH::ssh_cmd( {
> host => 'host.name',
> command => 'ls',
Using a full path name to the command is a safer approach.
> } );
>
>
> please help, thanks in advance.
Make sure you SSH at least once to the host.
Usually, when SSH'ing to a host for the first time, you get
a "Are you sure you want to continue connecting (yes/no)?" prompt,
possibly that's what it's waiting for.
If you can SSH from the command line, wrap your call in an eval, and
print any errors.
eval {
my $data = Net:SSH::ssh_cmd( ... );
print "data=$data\n";
};
print "ssh_cmd failed: $@\n" if @$;
------------------------------
Date: Thu, 12 Oct 2006 11:23:47 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: openGL-0.5 perl module problem
Message-Id: <452e6baa$0$10308$815e3792@news.qwest.net>
thedwig@gmail.com wrote:
> hi.
>
> %tar -xvf OpenGL-0.5.tar.gz
> %cd OpenGL-0.5
> %perl Makefile.PL
>
> and then i met messages.....
>
> Note (probably harmless): No library found for -lGLUT
> Note (probably harmless): No library found for -lGLX
> Note (probably harmless): No library found for -lMesaGLU
> Note (probably harmless): No library found for -lMesaGLUT
> Note (probably harmless): No library found for -lMesaGLX
> Note (probably harmless): No library found for -lXIE
>
>
> how can i solve this problem? help...
Install OpenGL first. The module provides an interface to the libraries
for OpenGL. http://www.opengl.org/ ???
If you have installed it, then possibly the libraries are not in the
directories that the Makefile expects, in which case you'll need to
include the directory(ies).
------------------------------
Date: Thu, 12 Oct 2006 11:34:44 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: openGL-0.5 perl module problem
Message-Id: <452e6e3c$0$10311$815e3792@news.qwest.net>
J. Gleixner wrote:
> thedwig@gmail.com wrote:
>> hi.
>>
>> %tar -xvf OpenGL-0.5.tar.gz
>> %cd OpenGL-0.5
>> %perl Makefile.PL
>>
>> and then i met messages.....
>>
>> Note (probably harmless): No library found for -lGLUT
>> Note (probably harmless): No library found for -lGLX
>> Note (probably harmless): No library found for -lMesaGLU
>> Note (probably harmless): No library found for -lMesaGLUT
>> Note (probably harmless): No library found for -lMesaGLX
>> Note (probably harmless): No library found for -lXIE
>>
>>
>> how can i solve this problem? help...
>
> Install OpenGL first. The module provides an interface to the libraries
> for OpenGL. http://www.opengl.org/ ???
I meant install the libraries (GLUT, GLX, etc.) that you want to use.
------------------------------
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:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#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 V10 Issue 9837
***************************************