[24491] in Perl-Users-Digest
Perl-Users Digest, Issue: 6671 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 9 14:05:55 2004
Date: Wed, 9 Jun 2004 11:05:07 -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 Wed, 9 Jun 2004 Volume: 10 Number: 6671
Today's topics:
Re: Contructing a dir. tree <richard@zync.co.uk>
Exit status from 'die' <bernie@rev.net>
Re: Help me with threads issue ! (Kevin Collins)
Re: Magic var for Current "Index" in array within loop? <nobull@mail.com>
Re: Meet the flocker <someone@somewhere.com>
Re: Meet the flocker <usenet@morrow.me.uk>
Re: Net::SMTP fails connection in CGI (Kevin Collins)
Re: New to Perl: Need help with a script <nobull@mail.com>
Re: Newbie <scobloke2@infotop.co.uk>
PERL C++/ CONTRACT/ IMMEDIATE <tgugger@buckeye-express.com>
Re: Perl cgi on Windows 2003 Server fails (Kevin Collins)
Re: sub returning nothing <MyFirstnameHere.News1@gustra.org>
Re: sub returning nothing <tassilo.parseval@rwth-aachen.de>
Re: sub returning nothing <nobull@mail.com>
Re: Text GUI with Perl (Kevin Collins)
Re: Text GUI with Perl <usenet@morrow.me.uk>
Re: Upgrading from 5.6.0 to latest version on SuSE 7.3 <no_replies@fake_email_address.invalid>
use of POSIX::_exit (Oliver)
Variable hash names? <dkoleary@olearycomputers.com>
Re: Variable hash names? <nobull@mail.com>
Re: Variable hash names? <dkoleary@olearycomputers.com>
Re: Variable hash names? <dkoleary@olearycomputers.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 09 Jun 2004 17:50:59 +0100
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: Contructing a dir. tree
Message-Id: <ca7f5l$kak$1@news.freedom2surf.net>
In article <e7774537.0406081707.4ffd52ea@posting.google.com>, "Prabh"
<Prab_kar@hotmail.com> wrote:
Hi
Have you considered recursion? Something like this (pseudocode-ish):
recurse_file('foo')
sub recurse_file {
filespec = arg1
if filespec is a directory
recurse_file(filespec)
else
do something with an ordinary file
fi
}
You could either print out stuff at each level or build a nested data
structure depending on your needs.
More detail about your problem would help ... such as
1) where do you get your $input from
2) does it not make more sense to test the filesystem to see whether
things are directories or files, rather than just looking at the position
in a string based on an arbitrary path separator
3) are you interested in anything else in those directories
4) where does the "some text about ..." text come from
HTH
Rich
------------------------------
Date: Wed, 09 Jun 2004 13:27:55 -0400
From: Bernard Cosell <bernie@rev.net>
Subject: Exit status from 'die'
Message-Id: <uehec05f1a4hlooe922o4qmmnvgg4lkt1o@4ax.com>
I'm trying to use a __DIE__ handler to manage the 'departure' of my
program and I've noticed a bit of an oddity I'm not sure about to try
to get the exit status to be correct.
Given this scrap of code:
sub Report
{ print $_[0];
exit $! ;
}
$SIG{__DIE__} = \&Report ;
die "Error\n" ;
When I run it, I get:
$ perl dtest.pl
Error
$ echo $?
0
Clearly, $! didn't have the hoped-for value. If I #-out the '$SIG',
so that die really does "die", then I get what I expected:
$ perl dtest.pl
Error
$ echo $?
255
So I'm not sure what to do. If I try a different way to suppress the
die-generated error message:
$SIG{__DIE__}...
close STDERR ;
Then I get a different result still:
$ perl dtest.pl
Error
$ echo $?
9
*SO* How can I write a 'die' handler that will:
1) swallow the error message [so it will _not_ be printed to
stderr] AND
2) exit with the proper/expected exit status
[on (1), an explicit 'exit' in the handler and closing STDERR are the
only ways I've managed to find, so far, to *NOT* have die go and print
the error message to STDERR... if there's a cleaner/less ugly way I'd
love to hear about it!]
Thanks!
/Bernie\
------------------------------
Date: Wed, 09 Jun 2004 15:46:36 GMT
From: spamtotrash@toomuchfiction.com (Kevin Collins)
Subject: Re: Help me with threads issue !
Message-Id: <slrnccec6s.f8v.spamtotrash@doom.unix-guy.com>
In article <1dc70d61.0406082241.90150da@posting.google.com>, Charlie wrote:
> Hi Folks,
> I need some help from you about the thread issue I have.
> What I want to do is to simulate multi users to access one web server.
> I want to simulate as many as 200 users to assess that web server to
> check the performance from both the web server and the backend DB.
>
> The ways that I emploment it are: 1). to have the apache(version
> 1.3.31) installed on the Linux platform. 2) I am using the perl
> 5.8.4, along with some perl modules, such as Mechanize, threads to
> create the test scripts. And I put the test scripts under the dir of
> (Apache)/cgi-bin/.
> In that way, I can enter the user number from the browser from
> anywhere and can do the rest of work by just clicking one button.
>
> Following is part of my main function:
> "package LoadTest;
> ...
> use threads;
> use threads::shared;
>
> my ($Input_value, %Inputs, $total);
> my $CGIobj = new CGI;
> %Inputs = $CGIobj->Vars;
>
> my @threads;
> for ( 1..$Inputs{UserNumber} ) {
> my $thread;
> $thread = new threads(\&Case1, \%Inputs);
> push(@threads, $thread);
> }
> $_-> join foreach(@threads);
>
> }
>
> sub Case1 {
> ....
> }
> "
> As you can see, I am trying to create a certain amount of
> threads(users) to invoke the same function,"Case1".
>
> During the runtime, that program runs perfectly fine if there are 20
> users, but when I give more users, such as 50, or even 100, something
> is going wrong.
> For example, once I submit 100 users, on that linux platform, I can
> see the amount threads keeps growing untill it reaches that number.
> Then before the sub-function calls are finished, all the threads are
> exit at once, without any indications, as if they are being killed
>
> Can someone tell me what might be the problem, all maybe you can give
> me a better way to work around this. I need to do the simulations of
> as many as 200 users.
>
> Thanks a lot for the help !!!
Just a guess, but you may be hitting a system kernel parameter limiting the max
threads per process.
Kevin
------------------------------
Date: 09 Jun 2004 18:13:25 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Magic var for Current "Index" in array within loop?
Message-Id: <u98yewodsa.fsf@wcl-l.bham.ac.uk>
"Lord0" <lawrence.tierney@bipsolutions.com> writes:
> > This question has been asked twice in .misc and once in .moderated in
> > the last week^H^H^H^H fourtnight.
> >
> > Invisible Array Loop Counter?
> > Basic newbie questions
> > On "for (@foo)"
> >
>
> Oops sorry, I must admit I didn't think to look. That won't happen
> again..........
I forgot congratuate Lawrence on getting the best subject line of the
4. Good subject lines and search engines are the secret to effective
Usenet. Lawrence may have forgotten to use a search engine himself
but at least he's done his bit to help the next person who does.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 09 Jun 2004 16:44:59 GMT
From: "Bigus" <someone@somewhere.com>
Subject: Re: Meet the flocker
Message-Id: <fc60fb14a5217dd1e44ddbd95831f9b8@news.teranews.com>
<ctcgag@hotmail.com> wrote in message
news:20040608133134.541$5R@newsreader.com...
> "Bigus" <someone@somewhere.com> wrote:
> > Hi
> >
> > I am attempting to flock for the very first time - after some surfing
> > around, the following 2 methods sound like the most viable/robust I can
> > find:
> >
> > ==== METHOD 1 ====
> > use strict;
> > use warnings;
> >
> > my $file = "flocktest.txt";
> > open FH, "+<$file" or die "Cannot open $file: $!";
> > flock FH, 2; # lock file
>
> flock can return false. You should check the results. Use an "or die $!"
> if nothing more appropriate springs to mind.
> Also, you should probably import and use LOCK_EX rather than hard-coding
2.
>
> >
> > Are there any issues with these methods I should be aware of? Which one
> > of these, or other, methods would you be inclined to choose / think is
> > better?
>
> The first one.
>
> > So far, I'm leaning towards the 2nd one since method 1 uses the seek &
> > truncate functions which I have not used before. However, only having to
> > open a file once in read/write mode does sound less "messy" somehow.
>
> I often take something like the second route out of laziness to learn
> seek. But that's not something I'm proud of. Since you've gone to the
> trouble of making the first example, you may as well use it. :)
>
>
> > One other general thing - if another instance of the above scripts tried
> > to access the file while it was locked would it wait until it's free or
> > would I have to include a retry loop in the script?
>
> It would wait at the flock until it became free. (Unless of course one
> version uses method 1, and another version uses method 2, then they would
> gladly stomp on each other.)
thanks for the advice. I've been reading up on seek etc and it doesn't seem
too bad :-)
Bigus
------------------------------
Date: Wed, 9 Jun 2004 18:04:56 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Meet the flocker
Message-Id: <ca7jg8$e3l$1@wisteria.csv.warwick.ac.uk>
Quoth "Bigus" <someone@somewhere.com>:
> I am attempting to flock for the very first time - after some surfing
> around, the following 2 methods sound like the most viable/robust I can
> find:
>
> ==== METHOD 1 ====
> use strict;
> use warnings;
use Fcntl qw/:flock :seek/;
> my $file = "flocktest.txt";
> open FH, "+<$file" or die "Cannot open $file: $!";
> flock FH, 2; # lock file
...or die...;
Always use the constants in Fcntl.pm for the flags to flock and seek.
Hardcoding numbers is both unclear and unportable.
> seek FH, 0, 0; # back to beginning of file
No need, you're already there.
> my @lines = <FH>; # get current content
> ### do stuff to content ###
> seek FH, 0, 0; # back to beginning of file
> truncate FH, 0; # empty file
> print FH @lines; # print new content to file
> close FH;
>
>
> ==== METHOD 2 ====
> use strict;
> use warnings;
>
> my $file = 'flocktest.txt';
> my $lockfile = $file.".lock"; # create dummy file to lock
> open(LOCK, ">$lockfile") or die "Can't open $lockfile($!)";
> flock(LOCK, 2); # lock file
This is slightly pointless: about the only reason for creating a
separate lockfile but then using flock on it is when the resource you're
locking is not a regular file, so you can't flock it directly.
A more important consideration can be when the file might be accessed
over the network (NFS, AFS etc.) by several machines at once; in this
case flock(2) won't work and you should simply use the *existence* of a
lockfile as the lock:
sysopen my $LOCK, O_RDWR | O_CREAT | O_EXCL, 0600
or die "can't open lockfile: $!";
On some NFS systems (NFSv2? I think it's fixed in NFSv3) O_EXCL isn't
implemented, so you have to use this instead:
use Sys::Hostname;
# NFSv2-safe file locking
# taken from open(2)
# returns the name of the lockfile for success, false for failure
# will *not* retry on failure
# to unlock, unlink the returned file
sub nfssafe_flock {
my $file = shift;
my $lockfile = "$file.lock";
my $uniqfile = "$lock." . hostname . ".$$";
open my $UNIQ, '>', $uniq
or die "can't create uniq file $uniq: $!";
if (
# link sometimes randomly fails on NFS systems, even when the
# link was created
not link $uniqfile, $lockfile or
(stat $UNIQ)[3] == 2
) {
unlink $uniqfile;
return $lockfile;
}
return;
}
If you need network-safe locking you could also investigate fcntl-based
locks, but they are lost when you fork so may be harder to deal with.
Note that both these methods have the disadvantage that you *must* be
sure to unlock by unlinking the lockfile, unlike a flock lock which the
system will remove when you close the file. This means you probably also
want to test how old the lockfile is, and delete it if it is much older
than the time a process should hold the lock for.
I presume that you understand all these locks are advisory, so if you
have two processes locking the same file with different methods there
you have no protection at all?
> open(FH, $file) or die "Can't open $file ($!)";
> my @lines = <FH>; # get current content
> close FH;
> ### do stuff to content ###
> open(FH, ">$file") or die "Can't open $file ($!)";
> print FH @lines; # print new content to file
> close FH;
> close LOCK;
>
> ==== END SAMPLE CODE =====
>
> Are there any issues with these methods I should be aware of? Which one of
> these, or other, methods would you be inclined to choose / think is better?
The former, unless it won't work for any of the reasons above.
> So far, I'm leaning towards the 2nd one since method 1 uses the seek &
> truncate functions which I have not used before.
You seem to have figured out how they work, though :)
> One other general thing - if another instance of the above scripts tried to
> access the file while it was locked would it wait until it's free or would I
> have to include a retry loop in the script?
With either of your methods (locking be calling flock), the script will
block at the flock call until it can make the lock. If you want to
timeout you will have to set an alarm, or pass the LOCK_NB flag to flock
and retry/timeout yourself.
The two methods I showed (locking based on the existence only of a file)
will *not* block, and you would have to retry yourself.
Ben
--
"The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching."
-Assyrian stone tablet, c.2800 BC ben@morrow.me.uk
------------------------------
Date: Wed, 09 Jun 2004 15:32:40 GMT
From: spamtotrash@toomuchfiction.com (Kevin Collins)
Subject: Re: Net::SMTP fails connection in CGI
Message-Id: <slrnccebco.f8v.spamtotrash@doom.unix-guy.com>
In article <Uesxc.32750$sS2.968058@news20.bellglobal.com>, Matt Garrish wrote:
>
> "CMCLab" <jfp24@cornell.edu> wrote in message
> news:MPG.1b2ff4f3ac81a087989681@newsstand.cit.cornell.edu...
>> Hello,
>> I'm running an IIS server on Windows 2000 with ActiveState Perl
>> 5.8. I need an automated e-mailer that attaches a PDF file. To do so,
>> I'm using MIME::Lite; I need to use Net::SMTP in turn to interface with
>> the SMTP server. Whenever I try to instantiate the Net::SMTP object
>> through the CGI interface, the following error occurs:
>>
>> "Failed to connect to mail server: Unknown error"
>>
>> When I run the script from the command line interface, it makes the
>> connection fine, and sends the e-mail without problems. However in the
>> CGI interface, it fails. This is suggestive of a permissions problem,
>> but I'm unclear about which permissions I would have to change if this
>> was indeed the case.
>>
>
> CGI processes on IIS run as the IUSR. Check that you allow anonymous access
That is not always true. You can confugure IIS to run as different IDs and it
still depends on the type of authentication being done. If NTLM auth is in
effect, CGI processes run as the authenticated use and NOT the web server
(anonymous) user.
This has burned me more than once because I am used to Apache and Unix/Linux...
> to the smtp server (in the snap-in control). If not, enable it and the
> problem should go away. It would also be a good idea to only allow messages
> to be sent from the local machine once you do, though.
>
> Matt
Kevin
------------------------------
Date: 09 Jun 2004 18:08:36 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: New to Perl: Need help with a script
Message-Id: <u9d648oe0b.fsf@wcl-l.bham.ac.uk>
Jeff 'japhy' Pinyan <pinyaj@rpi.edu> writes:
> Also, and some others might think me hyper-sensitive for saying this,
Or indeed wrong :-)
> but you should really local()ize $_ whenever you assign to it
> explicitly or use it when reading from a filehandle, because you can
> end up clobbering its value from somewhere else.
The above is commonly given mis-advice.
You should not local()ize $_ using local($_) because you still can end
up clobbering something else if $_ happens to be an alias to an
element of a tied agregate. (This is arguably a bug in Perl.)
Whenever you need to localize $_ then you should do so by saying
local(*_) or for(my $dummy) {}.
If you choose to use local(*_) you need to make sure you've get
everything you want out of the rest of *_ (e.g. @_) first.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 9 Jun 2004 16:37:52 +0000 (UTC)
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Newbie
Message-Id: <ca7ed0$ihb$1@sparta.btinternet.com>
Sree wrote:
> Hi all,
> I am new to this perl scripting language.Please help me in starting
> this.(by giving some URLs and some good books name).
Take your SUV to a bookstore, hand over your credit card, say "Give me
all your O'Reilly books now!" and wait patiently.
> If you can tell me
> how strong this language is, it would be appreciated.
Approximately 42, on the Adams scale.
------------------------------
Date: Wed, 9 Jun 2004 13:59:22 -0400
From: "Tom Gugger" <tgugger@buckeye-express.com>
Subject: PERL C++/ CONTRACT/ IMMEDIATE
Message-Id: <40c75065$1_2@news.athenanews.com>
OMNI GROUP
tgugger@buckeye-express.com
419-380-8853
C++/ PERL/ CONTRACT/ SEATTLE
MULTIPLE HIRES-IMMEDIATE HIRES
Senior Software Developers:
Senior Software developers will code 50-80% of the time with the
remainder of the time spent designing, analyzing, reviewing other's
code, and in some cases, mentoring others. Candidates need to:
- Have 5-10 years of software development expertise with relevant
experience building large scale, complex systems with C++ and Perl in a
UNIX and/or Linux environment(s). Experience must be recent.
- Demonstrate a firm grasp of computer concepts. In the interviewing
process, they'll be asked about data structures, asked what a virtual
function is, and other questions that will demonstrate their knowledge
and depth of computer concepts.
- Demonstrate design sense. In the interviewing process, they'll be
asked when and how they did pieces of design.
- Scale. Candidates will be asked not only how they would do something
in the programming language, but also how they might write computer
algorithms that are efficient with high volume, etc.
If qualified and interested, answer the eight questions below. Email
Answers WITH a resume to tgugger@buckeye-express.com.
1.. C++ experience-----------------------------yrs
2.. PERL experience---------------------------yrs
3.. Unix experience-----------------------------yrs
4.. Linux experience----------------------------yrs
5.. Development experience-----------------yrs
6.. Availability-------------------------------------
7.. Citizenship------------------------------------
8.. Rate (1099)----------------------------------pr hr
1099=You pay all your expenses. (Travel,motel,food)
------------------------------
Date: Wed, 09 Jun 2004 15:54:51 GMT
From: spamtotrash@toomuchfiction.com (Kevin Collins)
Subject: Re: Perl cgi on Windows 2003 Server fails
Message-Id: <slrnccecmb.f8v.spamtotrash@doom.unix-guy.com>
In article <79b0e251.0406090128.2536cc08@posting.google.com>, Hallvard ?strem
wrote:
> My well tested Perl CGI scripts will not run on my web server after
> moving it from Windows NT 4.0 to a brand new Windows 2003 Server. The
> web server software is FirstClass Server 7.1 from Open Text Corp.
> (http://www.opentext.com/products/firstclass/), and the web server
> setup is identical with the setup on NT, which should be OK. Perl
> version on Windows 2003 Server is 5.806. Here are some of my
> observations:
>
> 1. Scripts are running OK from the command prompt on the server, and
> the Perl installation looks OK. I've been through the more classical
> Perl for win32 pitfalls checks.
>
> 2. Client browser returns this message:
> ---
> 1.1 200 OK Server: FirstClass/7.1 Content-type: text/html Don't know
> how to run /cgi-bin/example.pl
> ---
> (Example.pl is a simple "Hello World" demo which runs OK from the
> prompt -- and normally on any web server with CGI-capabillity.)
>
> 3. Compiled CGI scripts, e.g. EXE-files, runs OK on the server.
>
> 4. Checked out the system PATH environment variable, and it points at
> C:\Perl\bin like it should.
>
> 5. Web server service is set up with the Local System user account,
> and should have the proper access rights.
>
> 6. I've installed an Apache test server in order to rule out the
> possibility that the problem somehow could be related to my FirstClass
> Server setup. The symptoms were almost identical, allthough Apache
> returned an not specified "Internal Server Error" message. Compiled
> CGI ran OK on Apache as well.
>
> In other words, there must be something in the Windows 2003 Server
> setup that I've missed? It seems like FirstClass Server can't find the
> Perl interpreter, even though the system PATH is OK. I've been through
> loads of FAQs and documentation, but haven't come across a solution so
> far. So I'll appreciate a helping hand on this.
>
> Regards,
> Hallvard Østrem
I would suspect that the ".pl" file extension is not set system-wide, or you
possibly need to define a "handler" (Apache term) for .pl files.
Kevin
------------------------------
Date: Wed, 09 Jun 2004 18:08:05 +0200
From: Gunnar Strand <MyFirstnameHere.News1@gustra.org>
Subject: Re: sub returning nothing
Message-Id: <ca7cl3$7bc$1@hudsucker.umdac.umu.se>
Anno Siegel wrote:
> Brian McCauley <nobull@mail.com> wrote in comp.lang.perl.misc:
>
>>Gunnar Strand <MyFirstnameHere.News1@gustra.org> writes:
>>
>>
>>>Brian McCauley wrote:
>>>
>>>>Gunnar Strand <MyFirstnameHere.News1@gustra.org> writes:
>>>
>>>[...]
>>>
>>>>>sub myvoid {
>>>>>}
>>>>
>>>>That is not a subroutine returning nothing.
>>>>That is an empty function.
>>>>In a list context an empty function retunrns its arguments.
>>>
>>>It returns an empty list in a list context according to perlmod,
>>>and perl -e 'sub a{};print a(1, 2, 3)' prints nothing.
>>
>>You are right, it does in 5.8. I was unaware that it has changed.
>
>
> It doesn't for me in 5.8.1, that is, it prints "123". (I'll check
> 5.8.3 later). I cannot imagine that an incompatible change like this
> would be made. Could some shell deviltry be obscuring the output?
>
I am using v5.8.4 built for i386-linux-thread-multi, so it
sounds like it have changed very recently.
>>>>How ever I wouldn't consider this to be defined bevaviour. I
>>>>would be inclined to consider the behaviour of an empty function
>>>>wrt what it returns to be undefined.
>>
>>Which, of course, is now bourne out to be very good advice wrt 5.6
>>because the behaviour in 5.8 is indeed different.
>>
>>You say the new behaviour is documented in perlmod? I think you meant
>>perlsub. :-)
>
>
> I can't find the *old* (and, I suspect, still current) behavior described
> in the corresponding version of perldoc, and I was never aware of it
> until now. (Speak of not knowing about fundamental language details...)
> It could be taken as a consequence of the "last expression evaluated"
> rule, though the argument list is nowhere visibly evaluated in the sub.
Brian's correct, it's in the perlsub page (mental lapse on
my part :-).
Regards,
/Gunnar
------------------------------
Date: Wed, 9 Jun 2004 18:28:38 +0200
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: sub returning nothing
Message-Id: <2ios5oFpmfgoU1@uni-berlin.de>
Also sprach Gunnar Strand:
> Anno Siegel wrote:
>> Brian McCauley <nobull@mail.com> wrote in comp.lang.perl.misc:
>>
>>>Gunnar Strand <MyFirstnameHere.News1@gustra.org> writes:
>>>>It returns an empty list in a list context according to perlmod,
>>>>and perl -e 'sub a{};print a(1, 2, 3)' prints nothing.
>>>
>>>You are right, it does in 5.8. I was unaware that it has changed.
>>
>>
>> It doesn't for me in 5.8.1, that is, it prints "123". (I'll check
>> 5.8.3 later). I cannot imagine that an incompatible change like this
>> would be made. Could some shell deviltry be obscuring the output?
>>
>
> I am using v5.8.4 built for i386-linux-thread-multi, so it
> sounds like it have changed very recently.
This appears to have been changed in 5.8.2. 5.8.1 is the last release
where empty functions return their arguments for me.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 09 Jun 2004 18:06:35 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: sub returning nothing
Message-Id: <u9fz94oe3o.fsf@wcl-l.bham.ac.uk>
"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> writes:
> Also sprach Gunnar Strand:
>
> > Anno Siegel wrote:
> >> Brian McCauley <nobull@mail.com> wrote in comp.lang.perl.misc:
> >>
> >>>Gunnar Strand <MyFirstnameHere.News1@gustra.org> writes:
>
> >>>>It returns an empty list in a list context according to perlmod,
> >>>>and perl -e 'sub a{};print a(1, 2, 3)' prints nothing.
> >>>
> >>>You are right, it does in 5.8. I was unaware that it has changed.
> >>
> >> It doesn't for me in 5.8.1, that is, it prints "123". (I'll check
> >> 5.8.3 later). I cannot imagine that an incompatible change like this
> >> would be made.
I don't think any sane person would claim that the old behaviour was
defined so I don't really see that compatability is an issue.
> > I am using v5.8.4 built for i386-linux-thread-multi, so it
> > sounds like it have changed very recently.
>
> This appears to have been changed in 5.8.2. 5.8.1 is the last release
> where empty functions return their arguments for me.
But, strangely, 5.8.2 is not the first (even) release where empty
functions don't return their arguments. They didn't in 5.8.0 either.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 09 Jun 2004 15:26:11 GMT
From: spamtotrash@toomuchfiction.com (Kevin Collins)
Subject: Re: Text GUI with Perl
Message-Id: <slrncceb0j.f8v.spamtotrash@doom.unix-guy.com>
In article <beb38f7.0406082301.69f3fa41@posting.google.com>, Thorsten
Gottschalk wrote:
> iqrity@web.de (Thorsten Gottschalk) wrote in message
> news:<beb38f7.0406080559.31f4c402@posting.google.com>...
[snip top post]
Please don't top post...
>> Hi all,
>>
>> I search a module for doing easy text dialogs with perl.
>> I tried to find something in CPAN, but I only find curses or something similar.
>> But curses is to complex for that I want to do.
>> I only need very basic dialoges like that tool dialog under Linux can provide.
>> Is there an interface or module for that?
>>
>> Remeber I need no colors, no mouse, only text.
>>
>> Thanks.
>>
>> Bye
>> Thorsten
[relocated top post]
> Thanks Kevin, this is also my question?
> I know TK. But so far I understand TK, this is a full window widget
> with support of graphic and mouse.
> And this is NOT what I need.
> I only need a rudimentary text menu or grafik, because the script will be
> executed over serial terminal or ssh/telnet. So no X windows support.
> Please give me any help.
I quick CPAN search for "prompt" turned up the module Term::Prompt, which may
have some promise for you. The URL is:
http://search.cpan.org/~persicom/Term-Prompt-1.01/lib/Term/Prompt.pm
Additionally, I browsed the the search results for "term" and found
Term::Interact here:
http://search.cpan.org/~prl/Term-Interact-0.44/Interact.pm
Hope these help...
Kevin
------------------------------
Date: Wed, 9 Jun 2004 17:30:57 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Text GUI with Perl
Message-Id: <ca7hgh$cjl$1@wisteria.csv.warwick.ac.uk>
Quoth iqrity@web.de (Thorsten Gottschalk):
> Hi all,
>
> I search a module for doing easy text dialogs with perl.
> I tried to find something in CPAN, but I only find curses or something similar.
> But curses is to complex for that I want to do.
> I only need very basic dialoges like that tool dialog under Linux can provide.
> Is there an interface or module for that?
>
> Remeber I need no colors, no mouse, only text.
UI::Dialog is an interface to the many variants of 'dialog' that are
available, including [xkg]dialog as well as the original console-based
program.
Curses::UI is a module built on top of Curses which lets you create
simple dialogs.
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: Wed, 9 Jun 2004 11:41:00 -0400
From: "Robert Oschler" <no_replies@fake_email_address.invalid>
Subject: Re: Upgrading from 5.6.0 to latest version on SuSE 7.3 box
Message-Id: <l9Gxc.12$cP5.8@bignews6.bellsouth.net>
"David Efflandt" <efflandt@xnet.com> wrote in message
news:slrncccq1a.o3t.efflandt@typhoon.xnet.com...
>
> You might want to upgrade your SuSE, 7.3 is getting rather old and not
> sure how long it will be supported for security updates, etc. YaST2 in
> newer versions is much quicker doing system updates.
>
> I just ftp installed the 64-bit version of SuSE 9.1 on a new PC. It came
> with Perl v5.8.3 (in my case built for x86_64-linux-thread-multi). My
> other SuSE 8.2 Pro box has v5.8.0 built for i586-linux-thread-multi.
>
> --
> David Efflandt - All spam ignored http://www.de-srv.com/
David,
Yeah sigh. I don't mind doing fresh installs of an O/S, but upgrades give
me the chills. I guess its time.
Thanks,
--
Robert
------------------------------
Date: 9 Jun 2004 09:45:21 -0700
From: spacehopper_man@yahoo.com (Oliver)
Subject: use of POSIX::_exit
Message-Id: <5818fca8.0406090845.6e8d5aa2@posting.google.com>
hi - I have a problem where children I spawn via fork will not exit -
see thread 'killing my children'
I have found that this only occurs when my child executes this code:
my $smtp = Net::SMTP->new('mail', Timeout => 60) || die $!;
$smtp->mail($from) or die "net_smtp mail from failed";
$smtp->to($to) or die "net_smtp rcpt to failed";
$smtp->data($data) or die "net_smtp data failed";
$smtp->quit() or die "net_smtp quit failed";
undef($smtp);
exit 0;
I can solve my problem be replacing 'exit 0' with 'POSIX::_exit'
can anyone advise as to whether this is dangerous/horrible ?
any ideas why this is required also appreciate.
I have used Devel::Symdump to look at the symbol table, and see that
there is stuff to do with Net::SMTP hanging around - not sure if that
is to be expected or not....
------------------------------
Date: Wed, 09 Jun 2004 16:38:14 GMT
From: Doug O'Leary <dkoleary@olearycomputers.com>
Subject: Variable hash names?
Message-Id: <W1Hxc.224$n%5.116@fe07.usenetserver.com>
Hey, all;
This seems like something that should be possible.
I have a config file that I'd like to read in as follows:
[INVALID_TGT_GROUPS]
adm
bin
sys
sysadmin
[VALID_HD_USERS]
blfarrel
dekojis
jclemens
[INVALID_HD_USERS]
dkoleary
jarodrigue
trzator
What I'd like at the end is hashes as follows:
%INVALID_TGT_GROUPS ( 'adm' => 1, 'bin' => 1 ...)
%VALID_HD_USERS ( 'blfarrel' => 1, 'dekojis' => 1...)
%INVALID_HD_USERS ( 'dkoleary' => 1, 'jarodrigue' => 1 ...)
Here's the function that I'm wrote to read it in. Hopefully, this
is obvious to someone, but unfortunately, not to me.
sub read_config
{ my $config = shift;
my (%INVALID_TGT_GROUPS, %VALID_HD_USERS, %INVALID_HD_USERS);
open (In, "< $config") || die "Can't read $config - ($!)";
my $hash;
while (<In>)
{ next if (/^#/ || /^$/);
chomp;
### Turn off strict refs so I can build hash tables easily.
no strict 'refs';
if (/\[\s*(\w+)\s*\]/)
{ $hash = $1;
next;
}
print "Setting $hash -> $_\n";
${%{$hash}}{$_} = 1;
}
print "Dumping\n";
foreach my $user (sort keys %INVALID_TGT_GROUPS)
{ print "$user\n"; }
print "End dumping\n";
}
If I turn off strict reference checking via the "no strict 'refs' as
listed above, the script runs, but doesn't set the hash as follows:
$ ./hdpw
Setting INVALID_TGT_GROUPS -> adm
Setting INVALID_TGT_GROUPS -> bin
Setting INVALID_TGT_GROUPS -> sys
Setting INVALID_TGT_GROUPS -> uucp
Setting INVALID_TGT_GROUPS -> mail
Setting INVALID_TGT_GROUPS -> tty
Setting INVALID_TGT_GROUPS -> lp
Setting INVALID_TGT_GROUPS -> nuucp
Setting INVALID_TGT_GROUPS -> daemon
Setting INVALID_TGT_GROUPS -> sysadmin
Setting VALID_HD_USERS -> blfarrel
Setting VALID_HD_USERS -> dekojis
Setting VALID_HD_USERS -> jclemens
Setting INVALID_HD_USERS -> dkoleary
Setting INVALID_HD_USERS -> jarodrigue
Setting INVALID_HD_USERS -> trzator
Dumping
End dumping
If I comment out the "no strict refs" line, I get an error as follows:
Setting INVALID_TGT_GROUPS -> adm
Can't use string ("INVALID_TGT_GROUPS") as a HASH ref while "strict refs"
in use at ./hdpw line 37, <In> line 10.
Like I said, this seems like something that should be possible. Can someone
point me in the right direction?
Thanks.
Doug
--
--------
Senior UNIX Admin
O'Leary Computer Enterprises
dkoleary@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume: http://www.olearycomputers.com/resume.html
------------------------------
Date: 09 Jun 2004 18:00:39 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Variable hash names?
Message-Id: <u9k6ygoedk.fsf@wcl-l.bham.ac.uk>
Doug O'Leary <dkoleary@olearycomputers.com> writes:
> Subject: Variable hash names?
Before I even read your post I am guessing this is FAQ "How can I use
a variable as a variable name?".
> This seems like something that should be possible.
>
> I have a config file that I'd like to read in as follows:
>
> [INVALID_TGT_GROUPS]
> adm
> bin
> sys
> sysadmin
>
> [VALID_HD_USERS]
> blfarrel
> dekojis
> jclemens
>
> [INVALID_HD_USERS]
> dkoleary
> jarodrigue
> trzator
>
> What I'd like at the end is hashes as follows:
>
> %INVALID_TGT_GROUPS ( 'adm' => 1, 'bin' => 1 ...)
> %VALID_HD_USERS ( 'blfarrel' => 1, 'dekojis' => 1...)
> %INVALID_HD_USERS ( 'dkoleary' => 1, 'jarodrigue' => 1 ...)
Yep, I guessed right.
> Here's the function that I'm wrote to read it in. Hopefully, this
> is obvious to someone, but unfortunately, not to me.
>
> sub read_config
> { my $config = shift;
> my (%INVALID_TGT_GROUPS, %VALID_HD_USERS, %INVALID_HD_USERS);
You cannot use symrefs to access lexically scoped variables.
> open (In, "< $config") || die "Can't read $config - ($!)";
> my $hash;
>
> while (<In>)
> { next if (/^#/ || /^$/);
> chomp;
> ### Turn off strict refs so I can build hash tables easily.
Rather than removing the safety guard why not figure a way to do the
job without sticking your hands into fast moving machinary?
> no strict 'refs';
> if (/\[\s*(\w+)\s*\]/)
> { $hash = $1;
> next;
> }
> print "Setting $hash -> $_\n";
> ${%{$hash}}{$_} = 1;
> }
The syntax you use to dereference the symbolic hashref in $hash is
wrong. The correct syntax is exactly the same as if there'd been a
real hashref in $hash ie. one of...
${\%{$hash}}{$_} = 1; # Almost what you had
${$hash}{$_} = 1; # Remove redundand deref-ref
$$hash{$_} = 1; # Remove redundant {}
$hash->{$_} = 1; # Most people prefer this form
> If I comment out the "no strict refs" line, I get an error as follows:
>
> Setting INVALID_TGT_GROUPS -> adm
> Can't use string ("INVALID_TGT_GROUPS") as a HASH ref while "strict refs"
> in use at ./hdpw line 37, <In> line 10.
>
> Like I said, this seems like something that should be possible.
No, sticking your hands into the machinary is not something that
should be possible while the safety guards are in place. That's like
the whole point isn't it? Perl lets you stink your fingers in the
internal workings (the symbol table) but provides a safety guard to
prevent you doing so accidently.
> Can someone point me in the right direction?
The FAQ.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 09 Jun 2004 17:22:24 GMT
From: Doug O'Leary <dkoleary@olearycomputers.com>
Subject: Re: Variable hash names?
Message-Id: <kHHxc.225$n%5.185@fe07.usenetserver.com>
In article <u9k6ygoedk.fsf@wcl-l.bham.ac.uk>, Brian McCauley wrote:
> The syntax you use to dereference the symbolic hashref in $hash is
> wrong. The correct syntax is exactly the same as if there'd been a
> real hashref in $hash ie. one of...
>
> ${\%{$hash}}{$_} = 1; # Almost what you had
> ${$hash}{$_} = 1; # Remove redundand deref-ref
> $$hash{$_} = 1; # Remove redundant {}
> $hash->{$_} = 1; # Most people prefer this form
I had actually tried three of those with the same results:
sub read_config
{ my $config = shift;
my (%INVALID_TGT_GROUPS, %VALID_HD_USERS, %INVALID_HD_USERS);
open (In, "< $config") || die "Can't read $config - ($!)";
my $hash;
while (<In>)
{ next if (/^#/ || /^$/);
chomp;
### Turn off strict refs so I can build hash tables easily.
# no strict 'refs';
if (/\[\s*(\w+)\s*\]/)
{ $hash = $1;
next;
}
print "Setting $hash -> $_\n";
${$hash}{$_} = 1;
}
print "Dumping\n";
foreach my $user (sort keys %INVALID_TGT_GROUPS)
{ print "$user\n"; }
print "End dumping\n";
}
And the result:
$ ./hdpw
Setting INVALID_TGT_GROUPS -> adm
Can't use string ("INVALID_TGT_GROUPS") as a HASH ref while "strict refs" in use at ./hdpw line 37, <In> line 10.
Thanks for the reply though.
Doug
--
--------
Senior UNIX Admin
O'Leary Computer Enterprises
dkoleary@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume: http://www.olearycomputers.com/resume.html
------------------------------
Date: Wed, 09 Jun 2004 17:40:18 GMT
From: Doug O'Leary <dkoleary@olearycomputers.com>
Subject: Re: Variable hash names?
Message-Id: <6YHxc.226$n%5.146@fe07.usenetserver.com>
In article <u9k6ygoedk.fsf@wcl-l.bham.ac.uk>, Brian McCauley wrote:
>
> You cannot use symrefs to access lexically scoped variables.
That, right there, was the key. Thanks. Changing to a hash
of a hash worked fine.
--
--------
Senior UNIX Admin
O'Leary Computer Enterprises
dkoleary@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume: http://www.olearycomputers.com/resume.html
------------------------------
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 6671
***************************************