[13983] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1393 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 16 06:13:52 1999

Date: Tue, 16 Nov 1999 03:10:19 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942750617-v9-i1393@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 16 Nov 1999     Volume: 9 Number: 1393

Today's topics:
        Q: Dodgy use of undef on global variables? <iain@zip.com.au>
    Re: Q: Dodgy use of undef on global variables? <uri@sysarch.com>
    Re: Q: Dodgy use of undef on global variables? (Ilya Zakharevich)
        Question... Carriage Returns in PERL <nyc_investment_banker@yahoo.com>
    Re: Removing all combinations of spaces/tabs at end of  (Abigail)
        seeking seek algorithm paul_p_francis@my-deja.com
    Re: server access <gellyfish@gellyfish.com>
        Sys::Syslog setlogsock <jvahn@short.circuit.com>
    Re: Too much Perl? (hoz)
    Re: Trying to use a variable as an operator (Abigail)
    Re: Where can i find more information on Schwartzian tr <lr@hpl.hp.com>
        Why isn't the HTML::Parser an HTML::Parser? <A.Lazic@Austria.EU.net>
    Re: Writing to binary files in Perl <gte017gNOgtSPAM@prism.gatech.edu.invalid>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 16 Nov 1999 16:22:03 +1100
From: Iain Waugh <iain@zip.com.au>
Subject: Q: Dodgy use of undef on global variables?
Message-Id: <Pine.LNX.4.10.9911161608590.27937-100000@zipperii.zip.com.au>

Hi,

I have a bit of code like this...

#!/usr/bin/perl -w
use strict;

my %hashvar = (...something or other...);
&IsThisDodgy(%hashvar);

exit(0);

sub IsThisDodgy
{
  my %temphash = %hashvar;

  undef %hashvar;

  %hashvar = %temphash;
}
# Code end

OK, so this is a dumb example, but it illustrates my point: can a
subroutine undefine a global variable and then re-create it?

The answer is yes (I've done it), but are there any nasty side-effects
that I should be aware of?

Cheers,
--
                 .    .                 Iain Waugh
 . o  ._o   .o    \#/.   o.   o_.  o .  iain@zip.com.au
  `)   /\   =)  .-kai-   )=   /\   )'   http://www.zip.com.au/~iain
  /<    <    <    /#\ .  >    >    >\   :.::.:TAG.:.::.
                .



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

Date: 16 Nov 1999 01:38:22 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Q: Dodgy use of undef on global variables?
Message-Id: <x7emdruejl.fsf@home.sysarch.com>

>>>>> "IW" == Iain Waugh <iain@zip.com.au> writes:

  IW> my %hashvar = (...something or other...);
  IW> &IsThisDodgy(%hashvar);

this is not passing %hashvar to your sub. it is passing a list of
key/value pairs to it. and you don't even use those args.

  IW> sub IsThisDodgy
  IW> {
  IW>   my %temphash = %hashvar;

  IW>   undef %hashvar;

this doesn't undefine the var. it wipes out its storage. better to use

	%hashvar = () ;

for that purpose. like defined doesn't mean much when used on perl
aggregates, undef doesn't do what you think on them either.

  IW>   %hashvar = %temphash;

this does not create %hashvar, it just assigns its old values back to it.

  IW> OK, so this is a dumb example, but it illustrates my point: can a
  IW> subroutine undefine a global variable and then re-create it?

what are you realy trying to do? this make little sense even for dumb
code.

  IW> The answer is yes (I've done it), but are there any nasty side-effects
  IW> that I should be aware of?

no you haven't. and you shouldn't use undef on aggregates. it has no
proper meaning for most programs.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 16 Nov 1999 08:21:55 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Q: Dodgy use of undef on global variables?
Message-Id: <80r473$jp0$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Uri Guttman 
<uri@sysarch.com>],
who wrote in article <x7emdruejl.fsf@home.sysarch.com>:
>   IW> The answer is yes (I've done it), but are there any nasty side-effects
>   IW> that I should be aware of?
> 
> no you haven't. and you shouldn't use undef on aggregates. it has no
> proper meaning for most programs.

What are you talking about?  undef %hash is the *only* way to
completely reclaim storage associated to hash.  (Maybe with an
exception of "shared" keys: I made patches, but never understood how
this actually works.)

Moreover,

> perl -wle "%a=(3..8); print defined %a"
1

> perl -wle "%a=(3..8); undef %a; print defined %a"

Hope this helps,
Ilya


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

Date: Tue, 16 Nov 1999 00:35:32 -0600
From: Doug Fleming <nyc_investment_banker@yahoo.com>
Subject: Question... Carriage Returns in PERL
Message-Id: <3830FB34.2F5AE7F9@yahoo.com>

Hi everyone...

Question? I am currently authoring an HTML messageboard system in PERL.
I don't want to accept messages where people do not type anything in the
message box. Thus, I have created a subroutine that returns an error
when people try to submit blank message fields to the program.

THE PROBLEM IS THIS...

If one hits the enter key, the tab key, or the space bar, my program
recognizes that as a message, even though a tangible message is not
really posted. I managed to get PERL to recognize a continuous string of
spaces as something that does not constitute a message, but I have not
been able to do so with a continuous string of enter keys, a continuous
string of tab keys, or any combination of spaces, tabs, or enters. 

HOW DOES PERL INTERPRET ENTER KEYS? HOW DOES PERL INTERPRET TAB KEYS?

Is the enter key signalled in PERL as \n? Is the tab key \t? I tried
filtering those patterns, and it doesn't seem to work.

Any help would be much appreciated.

Thanks!

--Doug


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

Date: 15 Nov 1999 23:21:17 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Removing all combinations of spaces/tabs at end of string
Message-Id: <slrn831qka.cvu.abigail@alexandra.delanet.com>

Mark Bluemel (mark.bluemelNOmaSPAM@siemens.co.uk.invalid) wrote on
MMCCLXVII September MCMXCIII in <URL:news:1415c574.2d0976d5@usw-ex0101-006.remarq.com>:
,, 
,, Anyway, running the example given generates "Substitution replacement
,, not terminated". You missed a "/" - $MyString =~ s/\s+$//g; is what's
,, needed.


No, because none of the examples given had tabs in them. They had back-
slashes and t's though.

    s'(?:\t| )+$'';

should do. And there's no need for /g.



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Tue, 16 Nov 1999 05:18:41 GMT
From: paul_p_francis@my-deja.com
Subject: seeking seek algorithm
Message-Id: <80qpfg$9rt$1@nnrp1.deja.com>

hello,

i have a large (over 20 Gig) binary file with fixed length records. i
have to aggregate 2 fields and calculate frequency distribution on
another field. the problem is it takes over 65 minutes for my perl
script to complete on a unix server running perl 5.005.

if possible, i am hoping to find a way to speed this up.

currently i am trying to use threads and seek() to start at 4
different places (tot_recs/4)in the file and work forward until overlap-
1 with no luck so far.

if anyone has a better approach or a related example, i would really
appreciate it.

thanks,
--paul


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Nov 1999 10:02:59 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: server access
Message-Id: <38312bd3_2@newsread3.dircon.co.uk>

In comp.lang.perl.misc Darrin H <dthusma@home.com> wrote:
> Jonathan Stowe wrote:
> 
>> On Tue, 9 Nov 1999 23:20:54 +0100 Alan J. Flavell wrote:
>> > On 9 Nov 1999, Jonathan Stowe wrote:
>> >
>> >> > Is it possible to do a remote login?  If so how?
>> >>
>> >> I tend to use telnet myself ...
>> >
>> > I'm using ssh these days wherever I can.
>> >
>>
>> Late I know but is anyone working on a Net::SSH module ?
>>
> I personally use the RPC.pm (modified to use a unauth_commands and local
> hosts file)
> from Sriram Srinivasan (Advanced Perl Programming).  It requires
> FreezeThaw.pm and ,MSG.pm , but it is soooo easy to use and very quick.
> Here is a snippet :
> 

<snip>

> Again, the
> addition of a local hosts and unauth_commands file allows more security
> that
> you would think, because its buried within your app.  However, if you want
> more
> security, just xor the stuff on both sides of the rpc call, or buy the
> Mastering Algos with perl and perl2exe, then become a hassel to the NSA.
> 

Er, explain to me again how that works with SSH (Or Unix for that matter) ?

/J\
-- 
"Mark my words, sex is never enough. Sooner of later she'll want a
dishwasher" - Policeman, City Central


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

Date: 15 Nov 1999 22:07:39 -0800
From: James Vahn <jvahn@short.circuit.com>
Subject: Sys::Syslog setlogsock
Message-Id: <80qsbb$6u8$1@short.circuit.com>

The old method was   use Sys::Syslog;

The new method is    use Sys::Syslog qw(:DEFAULT setlogsock);
                     setlogsock 'unix';
    
How do we program perl to accomodate whichever method is
appropriate for whatever version?

Specifically, I need to run the same script on perl versions
5.003_07 and 5.004_05.

-- 


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

Date: Tue, 16 Nov 1999 19:01:48 GMT
From: hoz@rocketmail.com (hoz)
Subject: Re: Too much Perl?
Message-Id: <3831a9dd.70712602@news.netvision.net.il>

> There's the perl-jobs
>mailing list, which has lots of Silicon Valley and NYC positions.

What is the address for this list? how do I subscribe?
-hoz


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

Date: 15 Nov 1999 23:34:43 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Trying to use a variable as an operator
Message-Id: <slrn831rdu.cvu.abigail@alexandra.delanet.com>

Craig Berry (cberry@cinenet.net) wrote on MMCCLXVII September MCMXCIII in
<URL:news:s314p056hsq32@corp.supernews.com>:
{} Scott Lanning (slanning@bu.edu) wrote:
{} : Tom Briles <sariq@texas.net> writes:
{} : > eval STRING is evil... eval STRING is evil...
{} : 
{} : bah.. Like any judgement of good/evil, it depends on context.
{} : If eval() were evil in and of itself, then why did Larry Wall
{} : put it in Perl? Surely you're not claiming Larry was evil. :)
{} 
{} Larry, in His wisdom, set before us both evil and good, that we may
{} through His grace choose the good and be saved.


eval is good. It allows us the calculate the average of an array of
numbers easily.


    $avg = do {local $" = "+"; eval ("@array") / @array};


Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Mon, 15 Nov 1999 23:37:22 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Where can i find more information on Schwartzian transform!
Message-Id: <MPG.129aa98eb0668d1598a211@nntp.hpl.hp.com>

In article <x7u2mnusqw.fsf@home.sysarch.com> on 15 Nov 1999 20:31:35 -
0500, Uri Guttman <uri@sysarch.com> says...
> >>>>> "BG" == Benjamin Gu <Benjamin_Gu@email.mot.com> writes:
> 
>   BG> Dear all, would like to show me
>   BG> where i can find more information on
>   BG> Schwartzian transform?
> 
> have you tried searching deja for past references to it? or searching
> www.perl.com? or searching the web (i doubt it will show many false
> hits)?
> 
> at least 2 good articles exist which cover the ST, one by tom c. and the
> other by yours truly and larry rosler. hint: my site might have it.
> 
> larry: (i know you will read this) should our article/sort pages link to
> tom's article and other pages?

How did you know?  :-)

The HTML version includes the following references and hyperlinks:

9. How do I sort an array by (anything)?,     
http://www.perl.com/CPAN/doc/manual/html/pod/perlfaq4.html#How_do_I_sort
_an_array_by_anyth

10. Christiansen, T. & Torkington, N. (1998). The Perl Cookbook, Recipe 
4.15: "Sorting a List by Computable Field". O´Reilly.

11. Christiansen, T., Far More Than Everything You´ve Ever Wanted to 
Know About Sorting, http://www.perl.com/CPAN/doc/FMTEYEWTK/sort.html

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 16 Nov 1999 08:13:17 +0100
From: Alexander Lazic <A.Lazic@Austria.EU.net>
Subject: Why isn't the HTML::Parser an HTML::Parser?
Message-Id: <m3hfimzz76.fsf@samurai.intern.austria.eu.net>

hi,

in some article i have read that, but i don't anderstand it because i
use it and i haven't any problems.

Please say me ;-)


al ;-)


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

Date: Mon, 15 Nov 1999 20:59:30 -0800
From: vsam1 <gte017gNOgtSPAM@prism.gatech.edu.invalid>
Subject: Re: Writing to binary files in Perl
Message-Id: <1415c574.f4fb18b0@usw-ex0107-043.remarq.com>

I am sorry. Last time I checked there were no answers to my previous
question and it was on the third or 4th page by then. So I figured
people wouldn't bother scrolling to my question.

Evidently they did.

My apologies!


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 1393
**************************************


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