[19681] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1876 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 5 09:05:33 2001

Date: Fri, 5 Oct 2001 06: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)
Message-Id: <1002287107-v10-i1876@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 5 Oct 2001     Volume: 10 Number: 1876

Today's topics:
    Re: 2nd request pls-Embed sound to cgi? (Abigail)
    Re: add a record to the beginnig of a file (Anno Siegel)
    Re: add a record to the beginnig of a file nobull@mail.com
    Re: Address already in use! <goldbb2@earthlink.net>
    Re: Address already in use! (Joe Smith)
    Re: building perl - installing modules in Win32 <qvyht@removejippii.fi>
    Re: CGI form email oddness - not acting as expected (Jennifer)
    Re: CGI form email oddness - not acting as expected (Jennifer)
    Re: https form post using image instead of submit butto <goldbb2@earthlink.net>
    Re: Multiplexing strings (Anno Siegel)
    Re: Multiplexing strings <dtweed@acm.org>
    Re: Nested loops and scoping $_ nobull@mail.com
    Re: Nested loops and scoping $_ <bernie@fantasyfarm.com>
    Re: Newbie: ASP: JScript -> PerlScript -> JScript by se <ReplyVia_contact.asp@URLinSig>
    Re: pervent multiple instances of a server (perl misk)
        Populating Hashes created via ActiveState CreateHash in (David Lopes)
    Re: resetting variables (rolf deenen)
        Undef ALL arrays? <s.warhurst@rl.ac.uk>
    Re: Undef ALL arrays? <s.warhurst@rl.ac.uk>
    Re: Undef ALL arrays? (Bernard El-Hagin)
    Re: Undef ALL arrays? (Rafael Garcia-Suarez)
    Re: Undef ALL arrays? <uri@sysarch.com>
    Re: Undef ALL arrays? <bart.lateur@skynet.be>
    Re: what am I doing wrong ? <tintin@snowy.calculus>
    Re: Yet another fork question (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 5 Oct 2001 07:17:10 GMT
From: abigail@foad.org (Abigail)
Subject: Re: 2nd request pls-Embed sound to cgi?
Message-Id: <slrn9rqngq.bls.abigail@alexandra.xs4all.nl>

christo (casey1@adelphia.net) wrote on MMCMLVI September MCMXCIII in
<URL:news:iliprtk8sthehdci3ouhm23245no63hv7q@4ax.com>:
~~ Attn Thomas Batzler - Soirry for th "forwardness" of emailing you
~~ directly...my appologies. Yes I am a newbie...a little perl knowledge.
~~ I am running this chat script with a web hoste/r mindspring.com..on a
~~ unix box, not sure what flavor..therefore I would want a sound played
~~ on my machine via a web browser. The page does reload. I could mail
~~ you the script if that would help. As I mentioned the script can be
~~ accessed here http://www.crystalservice.com/help/bluechat.cgi
~~ and after log on by anyone, I would naturally be logged on, a beep
~~ sound would go off on my machine.
~~ If you care I would be happy to pay a reasonable fee for your help and
~~ trouble. I hope I have given you enough information. Thanks for any
~~ further help.


So, why are you asking here? What exactly is your problem? If you have
a reloading webpage, all you need to do is to enable a background sound,
a popular webtrick of the mid 90's. 

I fail to see the Perl problems with that, you'd just use "print".
Asking which HTML characters to print is off-topic here - you'd should
visit some group with "www" or "html" in it.



Abigail
-- 
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");


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

Date: 5 Oct 2001 08:25:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: add a record to the beginnig of a file
Message-Id: <9pjqpm$pue$1@mamenchi.zrz.TU-Berlin.DE>

According to Hubert Ming <hubert.ming@iggi.lu.ch>:
> dear perl gurus
> is there a way how i can add a new recrod to the beginning of a file. with
> the following statement
> 
> print DB "$record\n";
> 
> all records a added at the end of my (flat) ascii-file. thanx for a hint

That's a FAQ.  perldoc -q 'line in a file'.

Anno


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

Date: 05 Oct 2001 08:52:52 +0100
From: nobull@mail.com
Subject: Re: add a record to the beginnig of a file
Message-Id: <u9g08ypjds.fsf@wcl-l.bham.ac.uk>

"Hubert Ming" <hubert.ming@iggi.lu.ch> writes:

> is there a way how i can add a new recrod to the beginning of a
> file.

FAQ: "How do I [...] append to the beginning of a file?"

In future, please consult the FAQ _before_ you post.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 05 Oct 2001 03:12:05 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Address already in use!
Message-Id: <3BBD5D45.E1213BA3@earthlink.net>

Michael Gilfix wrote:
[snip]
>   You can also fix this though by setting the SO_REUSEADDR option on
> the socket with:
> 
>   setsockopt SOCKET, SOL_SOCKET, SO_REUSEADDR, 1;
> 
>   Where 'SOCKET' is your socket descriptor. That tells TCP not to
> linger on shutdown. But closing the socket properly is preferrable.

Erm, no.
Turning on reuseaddr does just what it says.  It lets you reuse an
address, even if something else is using it.

To turn off lingering, do:
	setsockopt SOCKET, SOL_SOCKET, SO_LINGER, 0;
As you said, the ideal thing is to not have the problem in the first
place, by gracefully shutting down the socket.

-- 
"I think not," said Descartes, and promptly disappeared.


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

Date: Fri, 5 Oct 2001 09:17:08 +0000 (UTC)
From: inwap@best.com (Joe Smith)
Subject: Re: Address already in use!
Message-Id: <9pjtqk$1rh8$1@nntp1.ba.best.com>

In article <FB9v7.14113$3e6.1772864577@newssvr14.news.prodigy.com>,
ekkis <e@nospam:[arix.com]> wrote:
>hi, I have a piece of code:
>
>    ($name, $aliases, $proto) = getprotobyname('tcp');
>    ($name, $aliases, $PORT) = getservbyport($PORT, 'tcp')
>        if $PORT !~ /^\d+$/;
>
>    $sockaddr = 'S n a4 x8';
>    socket(S, AF_INET, SOCK_STREAM, $proto) || die "socket(): $!";
>    bind(S, pack($sockaddr, AF_INET, $PORT, "\0\0\0\0"))
>        || die "bind(): $!";
>
>    listen(S, 10) || die "listen(): $!";
>
>which works just fine... however, I have a problem: if I run this and
>terminate the program, when I run it again I get a message that the address
>is already in use.
>
>this obviously means that I'm failing to do something upon termination;

Look for the ReuseAddr option in "perldoc IO::Socket::INET".
	-Joe

--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Fri, 05 Oct 2001 09:25:17 GMT
From: Hessu <qvyht@removejippii.fi>
Subject: Re: building perl - installing modules in Win32
Message-Id: <3BBD7B35.4F5E986@removejippii.fi>



Bart Lateur wrote:
> 
> Hessu wrote:
> 
> >1) ok, I need a compiler but have it to be VC++?
> >(cannot afford it!)
> >Can I use Borland's free stuff or what comes
> >with Cygwin!?
> 
> Only if your perl executable is compiled with the same compiler. The
> extension modules (DLL's) and EXE file must be able to interconnect
> without wflaw, which means that they have to be binary compatible. Note
> that Activestate's modules compiled for perl 5.005 cannot work with
> Activestate's perl 5.6, even though both are compiled with the same
> compiler...
> 
> So, if you want to use another compiler, start with building perl from
> the source. Good luck.  ;-) Oh, yeah: there's an introduction manual on
> how to do this on Activestate's site.
> 
> <http://aspn.activestate.com//ASPN/Reference/Products/ActivePerl/lib/Pod/perlwin32.html>
> 
> There's a separate document for Cygwin.
> 
> <http://aspn.activestate.com/ASPN/Reference/Products/ActivePerl/lib/Pod/perlcygwin.html>
> 
> >2) I downloaded ActiveState, in Installer.bat
> >there several instances of string "ActivePerl\Perl\"
> >i guess it means "c:\ActivePerl\Perl\"
> >can I replace them with "MyDir\Perl\" (meaning "c:\MyDir\Perl\")?
> 
> I guess so. Take care to avoid spaces in your path.
> 
> >-and what is "ActivePerl\Perl\bin\perl" then? A mistyping?!
> 
> That is perl.exe which resides in the directory "bin" in the
> distribution file tree located at "ActivePerl\Perl".

I got an error about ...\bin\perl directory.)

> --
>         Bart.


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

Date: 5 Oct 2001 05:36:56 -0700
From: jennlee.2@eudoramail.com (Jennifer)
Subject: Re: CGI form email oddness - not acting as expected
Message-Id: <e836199f.0110050436.1d214051@posting.google.com>

> Your script probably needs to add a "To:" header in the DATA portion. 
> But why are you bypassing a local MSA and connecting directly to a mail 
> server in the first place (which is causing your 
> X-Authentication-Warnings)?  

Thanks much for the advice.  I had tried using "TO:" in the header
section and it hadn't worked and when I did a search on the net all I
could find was stuff on RCPT TO so I figured that should have been it.
 In the data section it does indeed work as you indicated.

Regarding bypassing a local MSA and connecting directly to a mail
server, I'm not sure I understand what you mean.  I know I'm going to
sound pretty ignorant but what does MSA stand for?  I did some
searching on the net and couldn't find anything that looked right.

We are on a Novell Server and can't run any executables like WindMail
or something like that - so says our webmaster, anyway, hence using
this sendmail.pl program that I think our webmaster got from Novell or
it came in the install or something.  At least I can customize it.
 
> Have you considered using a module from CPAN, like say Mail::SendMail?  
> Have you seen

I would love to use SendMail but currently our webmaster will not
install any modules, so I'm mostly stuck with what actually came
installed on the web server.  Reinventing the wheel is always fun ;-)

Thanks again for the info - I appreciate the response - 

Jennifer


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

Date: 5 Oct 2001 05:53:49 -0700
From: jennlee.2@eudoramail.com (Jennifer)
Subject: Re: CGI form email oddness - not acting as expected
Message-Id: <e836199f.0110050453.325739d0@posting.google.com>

> What makes you think they may be Perl related as opposed to
> application-domain related?  I would have thought that even with near
> zero Perl or SMTP knowledge it should have been possible to figure out
> that these were likely to be SMTP issues not Perl ones.

Sorry, I guess I figured I could start there because all the code I
was using was in Perl, and there could have been something wrong with
the Perl code. If not, as was the case apparently, a lot of Perl
programmers have probably done programming related to SMTP and I
figured maybe someone would be nice enough to give me some advice on
that if so.

Its sometimes difficult to pinpoint an issue between several
technologies and I certainly didn't mean to step on any toes by
posting.  Maybe, in retrospect, I didn't start in the best place, but
people are certainly free to ignore the posting if they feel it isn't
relevant.

> Again this has nothing to do with Perl.  The reason it looks OK to you
> is again related to your lack of knowledge of SMTP.  The HELO command
> takes a manatory parameter.

Thanks for the parameter info.  I had done some searching on the web
and many  of the examples I found had a parameter but I didn't see
anything on being mandatory - this was why I assumed what was coded
was 'OK'.  Glad to know better now.
 
> The code is not acting as expected because the expectation is based on
> misconceptions about SMTP.  This, as I said, has nothing to do with Perl.

And yet, you responded, despite it not actually being about Perl.
Thanks for the info.  Have a nice day ;-)

Jennifer


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

Date: Fri, 05 Oct 2001 03:21:54 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: https form post using image instead of submit button
Message-Id: <3BBD5F92.60876ACC@earthlink.net>

perl-student wrote:
> 
> How to post a form with an image instead of submit button?  The
> following code is failing to post correct credentials.  Should I get a
> client certificate first? How to associate variables to appropriate
> forms if a page contains multiple forms.

To post, use POST where you have GET.

Credentials may be set using the 'credentials' method of LWP::UserAgent.
You might also [instead] choose to subclass LWP::UserAgent and override
get_basic_credentials, as is done by the "lwp-request" program.

What do you mean by associating variables with forms?

-- 
"I think not," said Descartes, and promptly disappeared.


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

Date: 5 Oct 2001 10:01:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Multiplexing strings
Message-Id: <9pk0dn$v0$1@mamenchi.zrz.TU-Berlin.DE>

According to Dimitri <mauroid@csi.forth.gr>:
> I have N=3 strings of equal length, and I want to multiplex them by taking
> M=2 characters from each string (the length of each string is divisible by
> M). Example :
> 
> Input:
> 
> $str1 = "aabbccddeeff";
> $str2 = "AABBCCDDEEFF";
> $str3 = "001122334455";
> 
> Output :
> 
> $out = "aaAA00bbBB11ccCC22ddDD33eeEE44ffFF55";
> 
> Besides the obvious for loop :
> 
> $out = ""; $len = length($str1);
> 
> for ($i = 0; $i < $len; $i += 2) {
>  $out .= substr($str1, $i, 2) . substr($str2, $i, 2) . substr($str3, $i, 2);
> }
> 
> Is there a more elegant (faster) way?

    $str1 =~ s/(..)/$1\0\0\0\0/g;
    $str2 =~ s/(..)/\0\0$1\0\0/g;
    $str3 =~ s/(..)/\0\0\0\0$1/g;
    $out = $str1 ^ $str2 ^ $str3;

No, it isn't fast.

Anno


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

Date: Fri, 05 Oct 2001 11:44:33 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: Multiplexing strings
Message-Id: <3BBD9BD4.86060ABA@acm.org>

Joe Schaefer wrote:
> Wins what?  I didn't realize there was a prize to be had for
> avoiding subroutine calls in the solution.

The OP asked, "Is there a more elegant (faster) way?"

-- Dave Tweed


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

Date: 05 Oct 2001 08:57:52 +0100
From: nobull@mail.com
Subject: Re: Nested loops and scoping $_
Message-Id: <u9d742pixy.fsf@wcl-l.bham.ac.uk>

"Gregory Toomey" <nobody@nowhere.com> writes:

> I thought there might by a syntax for accessing the nested $_. It
> becomes more complex when using $_ with nested map, grep, for.

No, you cannot directly access the outer $_ in the inner loop. I'm
affraid you just have to copy it as in expressions like:

my @z = map { my $q = $_; [ grep { $_ > $q } @x ] } @y;

Of course $q is a copy of $_ so modifying it does not modify the
element of @y.
 
-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 05 Oct 2001 07:17:10 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: Nested loops and scoping $_
Message-Id: <ca5rrtsi7fri93k4u20caildqohk81k9sd@news.supernews.net>

nobull@mail.com wrote:

} "Gregory Toomey" <nobody@nowhere.com> writes:
} 
} > I thought there might by a syntax for accessing the nested $_. It
} > becomes more complex when using $_ with nested map, grep, for.
} 
} No, you cannot directly access the outer $_ in the inner loop. I'm
} affraid you just have to copy it as in expressions like:
} 
} my @z = map { my $q = $_; [ grep { $_ > $q } @x ] } @y;
} 
} Of course $q is a copy of $_ so modifying it does not modify the
} element of @y.

Yup, and to make *THAT* work, you need to do something like local *q = \$_
or some such... yuk!

This is, alas, one of the failings of using shallow binding over real
dynamic binding...

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: Fri, 5 Oct 2001 11:42:19 +0100
From: "Andrew U" <ReplyVia_contact.asp@URLinSig>
Subject: Re: Newbie: ASP: JScript -> PerlScript -> JScript by session variables in the same page, urgh.
Message-Id: <k8gv7.9686$jE3.1248831@news6-win.server.ntlworld.com>

"Andrew U" <ReplyVia_contact.asp@URLinSig> wrote in message
news:825v7.6233$jE3.762067@news6-win.server.ntlworld.com...
> I want a variable from a JScript code lump to be used by a PerlScript, the
> PerlScript then returns the value to a further lump of JScript. Since I
> couldn't fathom a way of sharing variables between the two languages I
> decided that Session variables would be a way of getting round this
variable
> sharing issue. My JScript creates a session variable, the PerlScript reads
> it, uses it, creates a new Session variable and then a subsequent block of
> JScript reads the new Session variable and does some processing on the
data.
> OK, here's the problem, the PerlScript isn't retrieving the JScript
created
> Session variable, but the later JScript does retrieve the PerlScript
created
> Session variable. Here's the dual-language code:
>
> <snip>

The issue seems to have been resolved, it's due to a different execution
order of the scripts than seems to be implied by the actual script layout.
Using <SCRIPT> tags throughout rather than <% %> appears to have fixed the
problem.
--
Andrew U
o-----------------------
http://www.andrewu.co.uk








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

Date: 5 Oct 2001 01:58:51 -0700
From: perlmisk@yahoo.co.uk (perl misk)
Subject: Re: pervent multiple instances of a server
Message-Id: <7fe42fcd.0110050058.120702c4@posting.google.com>

efflandt@xnet.com (David Efflandt) wrote in message news:<slrn9rq6os.dmg.efflandt@typhoon.xnet.com>...
> On Thu, 04 Oct 2001 13:52:18 +0200, Thomas Bätzler <Thomas@Baetzler.de> wrote:
> > On 4 Oct 2001 04:02:26 -0700, perlmisk@yahoo.co.uk (perl misk) wrote:
> >>what is the best way to prevent multiple instances of a server from
> >>being invoked?
>  
> >>3. try connecting to a predefined socket
> > 
> > You probably mean binding instead of connecting.
> 
> That should work if the server uses a specific socket that nothing else
> uses.  I have a Perl fake smtp daemon that just listens to port 25 and
> bounces back a "554 Service not available" message, and when I try to
> start a second instance of it, it dies with:
> 
> bind: Address already in use at ./fakemail line 33.

Ahhh, yes, that will work perfectly.  The server only ever wants to
bind to one socket, so if an instance is running and has hold of a
socket then a second instance can never start.


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

Date: 5 Oct 2001 04:53:33 -0700
From: DavidLopes213@hotmail.com (David Lopes)
Subject: Populating Hashes created via ActiveState CreateHash in VC++
Message-Id: <cd129204.0110050353.5d22b720@posting.google.com>

Dear All,

Does anyone have Visual C++ code which creates and populates (the part
I'm having problems with) hash tables via ActiveState's COM interface.

I've got as far as being able to create the hash ...

IPerlCOM_Script *hash;
 ...
IDispatch* p_myhash=hash->CreateHash();

However I have no idea how now to populate this hash table.  There are
no VC++ examples for this in the ActiveState documentation, only VB
and J++.

Many thanks in advance, 

David Lopes.


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

Date: 5 Oct 2001 05:01:44 -0700
From: rdeenen@mollymail.com (rolf deenen)
Subject: Re: resetting variables
Message-Id: <5b51a4e6.0110050401.7eb0532a@posting.google.com>

rdeenen@mollymail.com (rolf deenen) wrote in message news:<5b51a4e6.0110030232.6eea9339@posting.google.com>...
> Hello group,
> 
> Simple question. In a cgi-script i wrote to store web-links i want to
> clear some variables at the end of the script so that when a user
> refreshes the page the freshly added new entry doesn't get added
> again. How can I do this. It's a hash I want to clear completely....
> 
> Thanks in advance
> Rolf Deenen
> 
> PS. I already looked at perldoc.com and found something about "undef"
> and "delete" but with only limited experience i wasn't able to use
> them succesfully....

Ok, so, the fact that an item is added to the database when refreshing
a page is not the result of the hash remembering it's value but of the
browser sending the same value again... Can this be stopped?


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

Date: Fri, 5 Oct 2001 08:16:20 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Undef ALL arrays?
Message-Id: <9pjmo4$q16@newton.cc.rl.ac.uk>

I haven't been able to find anything in the perldocs on this yet (still
surfing) but is there a way to undefine ALL scalars, arrays & hashes? I want
to make sure that all variables are cleared down before I loop through the
program again (it's a fairly big program with alot of different variables).

Thanks


---------¦
  Bigus @ work
             ¦----------






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

Date: Fri, 5 Oct 2001 08:27:12 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Re: Undef ALL arrays?
Message-Id: <9pjnch$11f6@newton.cc.rl.ac.uk>

Ignore that.. found it!

reset 'a-z|A-Z';

seems to do the trick :)

---------¦
  Bigus @ work
             ¦----------


"S Warhurst" <s.warhurst@rl.ac.uk> wrote in message
news:9pjmo4$q16@newton.cc.rl.ac.uk...
> I haven't been able to find anything in the perldocs on this yet (still
> surfing) but is there a way to undefine ALL scalars, arrays & hashes? I
want
> to make sure that all variables are cleared down before I loop through the
> program again (it's a fairly big program with alot of different
variables).
>
> Thanks
>
>
> ---------¦
>   Bigus @ work
>              ¦----------
>
>
>
>




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

Date: Fri, 5 Oct 2001 07:37:40 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Undef ALL arrays?
Message-Id: <slrn9rqodj.8li.bernard.el-hagin@gdndev25.lido-tech>

On Fri, 5 Oct 2001 08:27:12 +0100, S Warhurst <s.warhurst@rl.ac.uk> wrote:
>Ignore that.. found it!
>
>reset 'a-z|A-Z';
>
>seems to do the trick :)


You realise, of course, that resetting 'A-Z' will undef
variables like %ENV, @ARGV, @INC?


Cheers,
Bernard


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

Date: 5 Oct 2001 07:32:37 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Undef ALL arrays?
Message-Id: <slrn9rqog9.so9.rgarciasuarez@rafael.kazibao.net>

S Warhurst wrote in comp.lang.perl.misc:
} I haven't been able to find anything in the perldocs on this yet (still
} surfing) but is there a way to undefine ALL scalars, arrays & hashes? I want
} to make sure that all variables are cleared down before I loop through the
} program again (it's a fairly big program with alot of different variables).

perldoc -f reset

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
This theory has become known as the waste of time theory and was
abandoned in 1956. -- Monty Python, Penguins


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

Date: Fri, 05 Oct 2001 07:43:56 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Undef ALL arrays?
Message-Id: <x7hete8raa.fsf@home.sysarch.com>

>>>>> "SW" == S Warhurst <s.warhurst@rl.ac.uk> writes:

  SW> Ignore that.. found it!
  SW> reset 'a-z|A-Z';

  SW> seems to do the trick :)

if you need to do that, then your program probably needs a major
redesign. it may mean you have too many globals. put more of them in
scopes and let them get initialized to undef upon entry to the
scopes. put more of the vars into hashes or lists and reduce the number
of declared vars. many other software engineering techniques would help
too but i have no idea what your program is like. but doing a global
reset is a very weak answer to a more fundamental problem.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: Fri, 05 Oct 2001 09:08:33 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Undef ALL arrays?
Message-Id: <fqtqrt8dihb5i2k283hb3e988f6gt3ec84@4ax.com>

S Warhurst wrote:

>I haven't been able to find anything in the perldocs on this yet (still
>surfing) but is there a way to undefine ALL scalars, arrays & hashes? I want
>to make sure that all variables are cleared down before I loop through the
>program again (it's a fairly big program with alot of different variables).

	use strict;

This demands that you declare all your variables, so it's the proper
time to make most of them lexicals, using "my". Preferably, do this in a
the loop block.


For globals, use 

	use vars qw/$var @var %var/;

or

	our($var, @var, %var);	# only 5.6.0 and later

and local'ise them in the loop block:

	local($var);

if you change them. You can do

	local(%ENV) = %ENV;

to initialise them to their initial, outer value every time.

p.s. If you RUN the program again instead of looping, there shouldn't
even be a problem.

-- 
	Bart.


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

Date: Fri, 5 Oct 2001 22:54:21 +1000
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: what am I doing wrong ?
Message-Id: <b5iv7.11$Et7.5401685@news.interact.net.au>


"Tana" <tana@acedsl.com> wrote in message
news:4294f74d.0110041720.2afc78bc@posting.google.com...
> I have a simple perl script like this:
> #!/usr/bin/perl
> use CGI;
>
> $cgi=new CGI;
> print $cgi->header();
>
> print "User ID: $user_id";
>
>
> And I call the script from internet browser like this:
> http://hepek.com/cgi-bin/test.pl?user_id=100
>
> I would expect to see a value for user_id (100) as a result, but value is
emty.
> All I see is "User ID: ".
>
> what am I doing wrong?

And where did you expect $user_id to magically be populated with a value?




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

Date: 5 Oct 2001 11:40:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Yet another fork question
Message-Id: <9pk671$v0$2@mamenchi.zrz.TU-Berlin.DE>

According to Benjamin Goldberg  <goldbb2@earthlink.net>:
> Mr. Sunblade wrote:
> > 
> > Benjamin Goldberg wrote:
> [snip]
> > > Like I said, signal handlers are really funky things... in general,
> > > if you can, try and avoid having to mess with them.
> > 
> > I read Lincoln Stein's "Network Programming with Perl" book and that's
> > how he set up the signal handlers for client/server apps (i.e. with
> > $SIG{CHLD}). After I saw that, I started getting into the habit of
> > using it everywhere I used fork.  Perhaps it was a case of "give
> > someone a hammer...".
> > 
> > Thanks for the tips.  I'll have to break this habit now (for non
> > client/server apps, anyway). :)
> 
> Indeed.  A forking server is one of those places where you just about
> *need* to have a signal handler.  This is because the server spends it's
> time in accept(), gets a connection, forks a child to handle that
> connection, and then goes back into accept() ... there isn't any
> "obvious" place to put a call to wait or waitpid, especially since the
> server process will probably be in accept() at the time the child dies.

MJD has recently shown code where each kid runs its own accept loop
and the parent does nothing but wait(pid) and more forks.  I like
that solution a lot (if applicable), and it has me wondering why
practically all standard examples in the Perl literature place the
accept call in the parent.

Anno


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

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.  

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 1876
***************************************


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