[26734] in Perl-Users-Digest
Perl-Users Digest, Issue: 8822 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 3 18:05:52 2006
Date: Tue, 3 Jan 2006 15:05:06 -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 Tue, 3 Jan 2006 Volume: 10 Number: 8822
Today's topics:
calling subroutine via hash <vzeo882n@verizon.net>
Re: calling subroutine via hash <noreply@gunnar.cc>
Re: calling subroutine via hash <matthew.garrish@sympatico.ca>
How to get image size in these conditions ? <.@.>
Re: How to get image size in these conditions ? <glex_no-spam@qwest-spam-no.invalid>
port 80 <steve@statenet.com>
Re: Shebang not working <scarmalt@swconsult.ch>
Re: Shebang not working <scarmalt@swconsult.ch>
Re: Shebang not working axel@white-eagle.invalid.uk
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 03 Jan 2006 20:41:00 GMT
From: "John W. Burns" <vzeo882n@verizon.net>
Subject: calling subroutine via hash
Message-Id: <wjBuf.5660$tJ1.2933@trndny01>
The following code calls only the first subroutine not the second. It seems
to
recoginize both subroutines but executes only the first one. Can
anyone help me figure out how to get the code to call the second subroutine
as
well? Both subroutines when run as standard routines and not part of
a hash work.Thanks
JWB
#!/usr/local/bin/perl
use warnings;
# following example reflects Perl Cookbook 11.4
my $name;
my $key;
my $dispatch;
my $var;
my %dispatch = (
"foo" => sub {
my $x = 3;
my $ans = ($x**2);
print "answer is: $ans \n"; #prints "answer is: 9"
},
"moo" => sub {
my @data = (3,7,15,28);
my $radius;
my $radius_ref = @data;
foreach $radius(@$radius_ref) {
print "my radius is: $radius \n";
my $area = 3.14159 * ( $radius ** 2);
print "and circle area is $area \n";
}
}
);
#Perl PCB 5.2 reference
my $input;
foreach $input("foo", "moo"){ #note:PCB uses chomp($input = <STDIN>) in
lieu of "foreach"
if ( exists ${dispatch}{ $input } ) {
${dispatch} {$input}( );
print "$input is the answer.\n";
}
else {
die "Cannot find the subroutine $input\n";
}
}
------------------------------
Date: Tue, 03 Jan 2006 21:58:08 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: calling subroutine via hash
Message-Id: <4206n6F1aviebU1@individual.net>
John W. Burns wrote:
> The following code calls only the first subroutine not the second. It seems
> to recoginize both subroutines but executes only the first one. Can
> anyone help me figure out how to get the code to call the second subroutine
> as well?
Yes, you can do that by asking Perl for help: enable strictures!!
use strict;
Please see the posting guidelines for this group:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 3 Jan 2006 15:50:16 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: calling subroutine via hash
Message-Id: <6sBuf.1543$H37.232446@news20.bellglobal.com>
"John W. Burns" <vzeo882n@verizon.net> wrote in message
news:wjBuf.5660$tJ1.2933@trndny01...
> The following code calls only the first subroutine not the second. It
> seems
> to
> recoginize both subroutines but executes only the first one. Can
> anyone help me figure out how to get the code to call the second
> subroutine
> as
> well? Both subroutines when run as standard routines and not part of
> a hash work.Thanks
They both run...
>
> #!/usr/local/bin/perl
> use warnings;
> # following example reflects Perl Cookbook 11.4
> my $name;
> my $key;
> my $dispatch;
> my $var;
>
> my %dispatch = (
> "foo" => sub {
> my $x = 3;
> my $ans = ($x**2);
>
> print "answer is: $ans \n"; #prints "answer is: 9"
>
> },
> "moo" => sub {
> my @data = (3,7,15,28);
> my $radius;
> my $radius_ref = @data;
Your problem is here, however. You're assigning the count of @data to the
scalar...
> foreach $radius(@$radius_ref) {
And then trying to call it as an array ref, which it is not Change that
assignment to:
my $radius_ref = \@data;
Or just get rid of this useless assignment altogether and write:
foreach my $radius (@data) {
Matt
------------------------------
Date: Tue, 3 Jan 2006 20:20:34 +0100
From: BlinKol <.@.>
Subject: How to get image size in these conditions ?
Message-Id: <MPG.1e24ecf16b4b812e989729@news.tiscali.fr>
How to get width and height of an image file (GIF or JPEG), knowing my
hosting provider has just the Perl 5.00503 stock modules (i.e. without
things like Image::Info or Image::Size) and doesn't allow any new module
install out of my own cgi-bin directory ?
And, of course, I don't wish to change of provider for this reason only.
------------------------------
Date: Tue, 03 Jan 2006 13:48:53 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: How to get image size in these conditions ?
Message-Id: <FyAuf.16$M23.842@news.uswest.net>
BlinKol wrote:
> How to get width and height of an image file (GIF or JPEG), knowing my
> hosting provider has just the Perl 5.00503 stock modules (i.e. without
> things like Image::Info or Image::Size) and doesn't allow any new module
> install out of my own cgi-bin directory.
Ask your provider what you should do, we have no idea what they have
available.
Possible options are:
+ Install one of them in your own directory, along with the
required libs for the format needed.
+ Look at the source of those modules and implement
what you need from them in your own module.
+ Ask your provider to install needed modules.
+ Use available programs your provider may have installed.
+ Many others...
------------------------------
Date: Tue, 03 Jan 2006 19:28:32 GMT
From: monkeys paw <steve@statenet.com>
Subject: port 80
Message-Id: <AfAuf.677302$_o.227456@attbi_s71>
Is there a quick perl hack to dump all internet traffic to
a flat file? i.e. monitor internet usage
------------------------------
Date: Tue, 03 Jan 2006 20:51:54 +0100
From: Sam CARMALT <scarmalt@swconsult.ch>
Subject: Re: Shebang not working
Message-Id: <icllr1pu8gonatnvgntpil3ecjjh928r5o@4ax.com>
On 03 Jan 2006 02:29:12 GMT, Abigail <abigail@abigail.nl> wrote:
>Sam CARMALT (scarmalt@swconsult.ch) wrote on MMMMDVII September MCMXCIII
>in <URL:news:2hthr156j56j53ioc42hcjuq601qdlac09@4ax.com>:
>[] I'm having trouble launching a Perl script with the shebang operator.
>[] OS is SuSE 9.2 Professional. So far, I haven't had any helpful
>[] insights at comp.os.linux.suse, and hope this isn't too far from Perl
>[] to post here.
>[]
>[] Complete Perl script:
>[]
>[] #! /usr/bin/perl
>[]
>[] print "Hello, World\n";
>[]
>[] This is contained in a file of 3 lines, left-justified, created with
>[] vi. It is saved with a directory entry of
>[]
>[] -rwxrwxrwx 1 root root 44 Dec 31 15:32 hworld.pl
>[]
>[] In the /usr/bin directory, I find the following entry
>[]
>[] -rwxr-wr-w 3 root root 1160321 Oct 2 2004 perl
>[]
>[] which leads me to believe that permissions are OK.
>
>If your permissions read '-rwxr-wr-w' you have a serious problem.
>That shouldn't be possible. My guess is that the permission is
>'-rwxrw-rw-', which is also a serious problem - but one that's
>entirely your fault. It means you have a perl binary that's only
>executable by root, but that's writable by everyone! Can you say
>security hole large enough to drive a truck through?
>
>[] Now, here is how things work:
>[]
>[] #perl hworld.pl
>[] Hello, World
>[] #hworld.pl
>[] bash: hworld.pl: command not found
>[] #./hworld.pl
>[] bash: ./hworld.pl: /usr/bin/perl: bad interpreter: Permission denied
>[] # ./hworld.pl
>[] bash: ./hworld.pl: /usr/bin/perl: bad interpreter: Permission denied
>[] #. hworld
>[] bash: hworld: No such file or directory
>[] #. hworld.pl
>[] bash: print: command not found
>[] #
>
>Yup. Consistent with a permission of '-rwxrw-rw-'.
>
>The permission ought to be '-rwxr-xr-x'.
>
>[] From these I conclude that there is something going wrong with the
>[] shebang line and getting started. Any pointers as to what I need to
>[] change will be appreciated. (Obviously, I need to fix this in order
>[] to use Perl in a CGI environment :)].
>
>Perhaps you should hand in your super user licence, and first learn
>Unix before continueing.
>
>
>Abigail
Just a typo - should have been -rwxr-xr-x.
Problem was that disk was mounted rw instead of acl.
Regards
------------------------------
Date: Tue, 03 Jan 2006 20:58:38 +0100
From: Sam CARMALT <scarmalt@swconsult.ch>
Subject: Re: Shebang not working
Message-Id: <tmllr1tk25vf4eteoief1rt34bo22q246c@4ax.com>
On Tue, 03 Jan 2006 04:58:37 +0100, Mihail <issakov@t-online.de>
wrote:
>Josef Moellers wrote:
>> Mihail wrote:
>>
>>> I can reproduce your problem with DOS-edited file.
>>> The character at the end of the string confuse the
>>> interpreter.
>>
>>
>> No, you most likely can't. The error message in your case is very cryptic:
>> josef@bounty:~> ./test.pl
>> : bad interpreter: No such file or directory
>> josef@bounty:~> perl test.pl
>> Hello, world
>
>Yes, the error is similar, but not exactly the same.
>May be the filesystem is mounted noexec?
>
>BTW, perldoc perlfaq7 has several ideas about the problem.
Not noexec, but remounted with acl,user_xattr instead of rw,auto,user
and now it works fine.
Many thanks,
Sam
------------------------------
Date: Tue, 03 Jan 2006 21:03:40 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Shebang not working
Message-Id: <MEBuf.19626$iz3.18393@text.news.blueyonder.co.uk>
Sam CARMALT <scarmalt@swconsult.ch> wrote:
> I'm having trouble launching a Perl script with the shebang operator.
> OS is SuSE 9.2 Professional. So far, I haven't had any helpful
> insights at comp.os.linux.suse, and hope this isn't too far from Perl
> to post here.
> Complete Perl script:
> #! /usr/bin/perl
> print "Hello, World\n";
> This is contained in a file of 3 lines, left-justified, created with
> vi. It is saved with a directory entry of
> -rwxrwxrwx 1 root root 44 Dec 31 15:32 hworld.pl
> In the /usr/bin directory, I find the following entry
> -rwxr-wr-w 3 root root 1160321 Oct 2 2004 perl
> which leads me to believe that permissions are OK.
No. You are not giving the correct permissions. The
'owners' permission is correct... the group and user
permissions are not correct (in fact impossible) as
the sequence is 'rwx' for all three. And if you
are not logged in as root you would not be able to execute
Perl.
The correct permissions should be '-rwxr-xr-x'.
Axel
------------------------------
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 8822
***************************************