[18753] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 921 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 17 06:10:42 2001

Date: Thu, 17 May 2001 03:10:13 -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: <990094212-v10-i921@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 17 May 2001     Volume: 10 Number: 921

Today's topics:
        Excluding certain output variables? <davsoming@lineone.net>
    Re: Excluding certain output variables? <mums_mums83@hotmail.com>
        find.pl private to Perl? <koos_pol@nl.compuware.com.NOJUNKMAIL>
        Hashes and such ... help ! <mums_mums83@hotmail.com>
    Re: mailing from perl (Dennis Schoen)
        Perl bytecode execution (Mark Warnes)
        perl/XML question <peter.sogaard@tjgroup.com>
    Re: perl/XML question <peter.sogaard@tjgroup.com>
        Positive reinforcement, anyone? ( Was: Re: Posting Guid (Philip Lees)
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Bernard El-Hagin)
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <webmaster@webdragon.unmunge.net>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <webmaster@webdragon.unmunge.net>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <webmaster@webdragon.unmunge.net>
    Re: Re: Proposed new pragma: caution. (Bernard El-Hagin)
        ReadLine <h-pota@adfa.edu.au>
    Re: regExp question (Bernard El-Hagin)
        Sorry, I solved it... Re: $myexp =~ s/\%/[aeiou]/; ???? <gerhard.schwarz@fpg.de>
    Re: Taint <dodger@necrosoft.net>
    Re: What is wrong with my Regular Expression? <webmaster@webdragon.unmunge.net>
        What's wrong with my scope? (J.C.Posey)
    Re: What's wrong with my scope? (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 17 May 2001 09:19:51 +0100
From: "David Soming" <davsoming@lineone.net>
Subject: Excluding certain output variables?
Message-Id: <tg7221rdoha26a@corp.supernews.co.uk>

Hi new to perl,
I have this script which displays SSI environment variables in browser:
  #!/usr/local/bin/perl
   print "Content-type: text/html\n\n";
   print "<tt>\n";
   foreach $key (sort keys(%ENV)) {
      print "$key = $ENV{$key}<p>";
   }

Using: <!--#exec cgi="cgi-bin/ALL_ENV.cgi"-->

How can I exclude specific variables in the output namely;
UNIQUE_USER_ID=
REDIRECT_UNIQUE_ID=
REDIRECT_USER_NAME=
What do I need to do to exclude these? Any suggestions what I need to read
up on please?
Thanks very much.




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

Date: Thu, 17 May 2001 10:21:23 +0200
From: grodan_kermit <mums_mums83@hotmail.com>
Subject: Re: Excluding certain output variables?
Message-Id: <3B038A03.65BDADA8@hotmail.com>

You could try something like

 #!/usr/local/bin/perl
   print "Content-type: text/html\n\n";
   print "<tt>\n";
   foreach $key (sort keys(%ENV)) {
      unless ($key eq "UNIQUE_USER_ID" or
                 $key eq "REDIRECT UNIQUE_USER_ID" or
                 $key eq "REDIRECT_USER_NAME")
                    {
                       print "$key = $ENV{$key}<p>";
                    {
   }


But then again I'm jsut a newbie ...

/ Jakob


David Soming wrote:

> Hi new to perl,
> I have this script which displays SSI environment variables in browser:
>   #!/usr/local/bin/perl
>    print "Content-type: text/html\n\n";
>    print "<tt>\n";
>    foreach $key (sort keys(%ENV)) {
>       print "$key = $ENV{$key}<p>";
>    }
>
> Using: <!--#exec cgi="cgi-bin/ALL_ENV.cgi"-->
>
> How can I exclude specific variables in the output namely;
> UNIQUE_USER_ID=
> REDIRECT_UNIQUE_ID=
> REDIRECT_USER_NAME=
> What do I need to do to exclude these? Any suggestions what I need to read
> up on please?
> Thanks very much.



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

Date: Thu, 17 May 2001 08:41:11 +0200
From: Koos Pol <koos_pol@nl.compuware.com.NOJUNKMAIL>
Subject: find.pl private to Perl?
Message-Id: <9dvrq7$e3p@news.nl.compuware.com>

Hello all,

Is find.pl private to Perl? I mean, is it internally used by Perl any 
nowhere else and does Perl call it with a full path (/.../.../.../find.pl)? 
I wrote a search script and wanted to call it find.pl. But I just 
discovered there already is a find.pl in the Perl distribution. It would 
not be smart of me to use this name if it could possibly break Perl...
Anyone?

Cheers,
-- 
Koos Pol - Systems Administrator - Compuware Europe B.V. - Amsterdam
koos_pol@nl.compuware.com_NO_JUNK_MAIL



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

Date: Thu, 17 May 2001 10:08:19 +0200
From: grodan_kermit <mums_mums83@hotmail.com>
Subject: Hashes and such ... help !
Message-Id: <3B0386F3.DFE2E2B8@hotmail.com>

Hi everybody,

I'm having trouble understanding the first line in this snippet :

foreach $data (@{$result->[0]->{"data"}}) {
        my $trader = $data->{"Transaction Type"};
        my $portfolio = $data->{"ABACUS"};
        my $transactions = $data->{"Total"};
        my $total = $data->{"sum"};

$result is the result of an SQL query

$result =  $db->fetch($sql);


Could some friendly soul interpret this for me ?

Br

Jakob



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

Date: Thu, 17 May 2001 07:25:34 GMT
From: dennis@cobolt.net (Dennis Schoen)
Subject: Re: mailing from perl
Message-Id: <slrn9g6v7d.3or.dennis@smart.cobolt.net>

On Wed, 16 May 2001 20:43:30 GMT, Anonymous <nulleq@swwfm.com> wrote:
> I'm working on a script that looks essentially like so, but doesn't work:
> 
> 
> open(FH,"mailing.list");
> 
> while(<FH>) {
> 	system("mail $_  < a_file_to_mail");
> }
> 
> close FH;
> 
> 
> any ideas?
Yes, *always* check the return code from open, close and system:

open(FH,"mailing.list") or die "Can't open mailing.list: $!";

system("mail $_  < a_file_to_mail") == 0 or die "system ... failed: $?"

close FH or die "Error closing file mailing.list: $!";


There are also plenty of Modules for dealing with mail available
so you could avoid the system call.

Dennis
-- 
"The Idea Is Good But The World Isn't Ready Yet"
                    -
    Tocotronic (The Hamburg Years - 1998)


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

Date: Thu, 17 May 2001 08:49:24 GMT
From: mark.warnes@ntlworld.com (Mark Warnes)
Subject: Perl bytecode execution
Message-Id: <3b038f58.4712454@news.firstnet.co.uk>

I am trying to compile a CGI script into Perl bytecode to save time
loading and parsing. My script is running on an ISP who does not
provide mod_perl unfortunately so I want to use bytecode to try and
speed up the loading part.

My question is can I compile on a linux box to then run the bytecode
on a Windows machine. Also, how do you execute the bytecode (.plc
file)? Do I need a small wrapper script which will 'require' the
bytecode file?

Any help appreciated.

Mark


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

Date: Thu, 17 May 2001 09:32:17 +0200
From: "Peter Søgaard" <peter.sogaard@tjgroup.com>
Subject: perl/XML question
Message-Id: <9dvupl$aus$1@news.inet.tele.dk>

Hi all,

I'm playing around with some xml on a webpage, but i'm having some trouble
displaying it in the browser( IE 6.0 )...I only get the content of the
tags - not the default "tree-listing" of xml that IE displays .

I think the problem is printing the right headers and such ( as you in a
normal html page print Content-Type: text/html\n\n )...only i'm not sure
what headers to use with xml.
(Maybe best answer for me is a 10 line example of a working xml displaying
perl script)

Finally, so as not to make this totally off-topic ;) I've been looking at
the module XML::Generator but i'm looking for something a bit more alike to
the CGI module...any ideas?





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

Date: Thu, 17 May 2001 09:52:17 +0200
From: "Peter Søgaard" <peter.sogaard@tjgroup.com>
Subject: Re: perl/XML question
Message-Id: <9dvvv8$env$1@news.inet.tele.dk>


"Peter Søgaard" <peter.sogaard@tjgroup.com> wrote in message
news:9dvupl$aus$1@news.inet.tele.dk...
> Hi all,
>
> I'm playing around with some xml on a webpage, but i'm having some trouble
> displaying it in the browser( IE 6.0 )...I only get the content of the
> tags - not the default "tree-listing" of xml that IE displays .
>
> I think the problem is printing the right headers and such ( as you in a
> normal html page print Content-Type: text/html\n\n )...only i'm not sure
> what headers to use with xml.
> (Maybe best answer for me is a 10 line example of a working xml displaying
> perl script)
>
> Finally, so as not to make this totally off-topic ;) I've been looking at
> the module XML::Generator but i'm looking for something a bit more alike
to
> the CGI module...any ideas?
>
>
Hmm, never mind...I found out ;)

Content-Type: text/xml\n\n

worked this time (it didn't yesterday ;) )




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

Date: Thu, 17 May 2001 06:53:50 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Positive reinforcement, anyone? ( Was: Re: Posting Guidelines ...)
Message-Id: <3b037392.64839374@news.grnet.gr>


Just sticking a stray thought in here. Along with the posting
guidelines, of which I heartily approve, is there any room for some
positive reinforcement for new or infrequent posters?

What prompted this was a post from one Makesh Kothandaraman that I
read today and thought was quite excellent for a first post to the
group: relevant subject line, clear statement of problem, sample code
snippet. The only negative point was the redundant "--help needed"
tagged on to the subject.

Would it be worthwhile to have a "Best post of the week/month" award,
or something similar, limited to first-time or infrequent posters, as
a way of encouraging people to follow the guidelines in a constructive
way?

Thoughts, anyone?

Phil
-- 
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer


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

Date: Thu, 17 May 2001 06:20:30 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <slrn9g6qss.pk3.bernard.el-hagin@gdndev25.lido-tech>

On Wed, 16 May 2001 19:18:12 GMT, Mark Jason Dominus <mjd@plover.com> wrote:
>In article <slrn9g4433.90p.bernard.el-hagin@gdndev25.lido-tech>,
>Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote:
>>You don't seem to understand that the 'must' means 'if you want expert
>>advice from some of the best Perl programmers in the world you must'
>
>If that's what it means, then it should be removed because it is wrong.

What is wrong? That the best here aren't some of the best in the world?  Or
that they won't ignore posts which don't comply with the standards they have
repeatedly asked newbies to comply with?

Cheers,
Bernard


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

Date: 17 May 2001 07:18:54 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <9dvu0u$m17$2@216.155.32.227>

In article <qRbM6.812$3n.42027@news.itd.umich.edu>,
 Miguel Cruz <spam@un.u.nu> wrote:

 | Scott R. Godin <webmaster@webdragon.unmunge.net> wrote:
 | > I realy hate to quote so much just to make a pithy comment like this, 
 | > but I wholeheartedly agree with the above sentiment 100%.
 | 
 | That's pithy?
 | 
 | miguel

well, "me too" is pithy. :-) A carefully crafted and well disguised "me 
too" is just as pithy although somewhat more worthy of respect. :D 

*ducking the spray of saliva as you raspberry the screen*

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


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

Date: 17 May 2001 07:32:13 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <9dvupt$m17$3@216.155.32.227>

In article <m1lmnypqz8.fsf@halfdome.holdit.com>,
 merlyn@stonehenge.com (Randal L. Schwartz) wrote:

 | Godzilla!> Hey! You are still speaking to me!
 | 
 | Kira, I'll always speak to you.  Whether you listen or not is an
 | entirely different matter.  And you *have* listened, many times in the
 | past.  It's evident in your evolution.  In fact, you should probably
 | pick a higher animal for your icon now... perhaps one with fur. :)
 |  

<free-association>
hmmm fur.. Joel Furr... Usenet Oracle.... lemurs? :-D 

ftp over to rtfm.mit.edu and download 
pub/usenet-by-hierarchy/alt/fan/lemurs/lemur-faq/part5

<grin> It's been ages, and I can't believe this thing still exists in 
the archives, but there you have it. :D 

use warnings "Coffee |nose >keyboard";

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


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

Date: 17 May 2001 07:47:13 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <9dvvm1$m17$4@216.155.32.227>

In article <3B01AAD7.8B60FF3E@stomp.stomp.tokyo>,
 "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:

 | David Coppit wrote:
 |  
 | > On Tue, 15 May 2001, Godzilla! wrote:
 |  
 | > > > BTW, all the posts I've seen (besides those of Godzilla!) are in favor
 | > > > of the document, or suggest slight rewording.
 | 
 | > > This is untrue. I am reading increasing amounts of strong
 | > > objection to this document.
 |  
 | > Hm... I guess I missed that. Besides you, I didn't see anyone who
 | > disagreed with the basic idea that some group of cplm regulars
 | > could/should suggest/dictate how others should post to the group.
 | 
 | I have tiny blue monkeys flying out of my big butt.

Thus we witness the genesis of the phrase "Cue the screaming hordes of 
tiny blue monkeys."
  
 | > Admittedly, I probably don't read the newsgroup as closely as you do.
 | 
 | Nor do you equal my talent with language, in both reading and writing.

I completely fail to see how your bald statement achieves any proof of 
this. 
  
 | > > Possibly you face challenges in reading comprehension or, are being
 | > > masquer deceitful?
 |  
 | > Have I done something to deserve this comment? I try to treat other
 | > people with respect, and would appreciate the same unless I
 | > demonstrate myself unworthy of it.
 | 
 | 
 | Ahhh... po' boy. You are breaking my wittle heart.
 | 
[snip - no change of context]
 | 
 | Think of me as the egg which sticks to your teflon pan.

How did you get the teflon to stick to the pan? Inquiring minds want to 
know.

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


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

Date: Thu, 17 May 2001 08:26:05 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Re: Proposed new pragma: caution.
Message-Id: <slrn9g728a.pk3.bernard.el-hagin@gdndev25.lido-tech>

On 11 May 2001 23:04:23 GMT, 194.203.215.187 [demerphq@hotmail.com]
<194.203.215.187[demerphq@hotmail.com]> wrote:
>> On 11 May 2001 11:43:26 GMT, 194.203.215.187 [demerphq@hotmail.com]
>> If you're joking - haha. If you're not - no comment.
>
>No joke. Whats the prob Bernard?

I believe Anno's comment says it best - superfluous.

Cheers,
Bernard


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

Date: Thu, 17 May 2001 18:00:05 +1000
From: Himanshu R Pota <h-pota@adfa.edu.au>
Subject: ReadLine
Message-Id: <3B038504.EDF094EF@adfa.edu.au>

I am using Term::ReadLine
but when I use readline('Prompt', $prein)
the line editing is not satisfactory. I have to give a left-arrow and ctrl-e
twice for it to get into the emacs mode. How can I fix it.

Thanks.

H R Pota
h-pota@adfa.edu.au




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

Date: Thu, 17 May 2001 05:25:56 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: regExp question
Message-Id: <slrn9g6nmi.pk3.bernard.el-hagin@gdndev25.lido-tech>

On 16 May 2001 11:51:14 -0700, Randal L. Schwartz <merlyn@stonehenge.com>
wrote:
>>>>>> "Uri" == Uri Guttman <uri@sysarch.com> writes:
>
>>>>>> "CB" == Craig Berry <cberry@cinenet.net> writes:
>CB> my @daynames = qw(monday tuesday wednesday thursday friday
>CB> saturday sunday);
>
>CB> my %trans;
>CB> @trans{@daynames} = map { substr($_, 0, 3) } @daynames;
>
>Uri> 	my %trans = map { $_, substr($_, 0, 3) } @daynames ;
>
>my %trans = map /((...).*)/, @daynames;

If I were a woman I would marry you.

Cheers,
Bernard


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

Date: Thu, 17 May 2001 11:41:09 +0200
From: Gerhard Schwarz <gerhard.schwarz@fpg.de>
Subject: Sorry, I solved it... Re: $myexp =~ s/\%/[aeiou]/; ????
Message-Id: <3B039CB5.B187F3F0@fpg.de>

Damn, better read twice...

> $match is a String from 0 to n length, and does only contain
> letters.

Wrong, $match can contain "+" od "%". I looked at every single line 
of that array from where $match is taken, and found a handful entries
that contains either one of them.

>           $match =~ s/\+/[bcdfghjklmnpqrstvwxyz]/;
> <>        $match =~ s/\%/[aeiou\344\366\374]/;


The leading Backslash for "%" is to make clear, that both "+" and 
"%" are literals. It's used to build a regular expression that is
later used.

Sorry for wasting your time!


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

Date: Thu, 17 May 2001 06:22:28 GMT
From: "Dodger" <dodger@necrosoft.net>
Subject: Re: Taint
Message-Id: <E6KM6.1$uk2.3505@news1.rdc2.pa.home.com>

"Chris Stith" <mischief@velma.motion.net> wrote in message
news:tg5tm6219h8pa5@corp.supernews.com...

> If I'm running setuid, you'd better believe I want to know
> what it is I'm doing with which datum. The higher the
> program's access to the system, the _more_ you want the
> protection of tainting data.
>
> There are secure ways to untaint data. You don't have to
> rely on a completely unsafe way to do it in order to use
> the value of a variable.

*sigh*

I have grown rather tired with explaining the exact situation I am
concerning myself with.

Here goes one last time.

When you are running a script that runs setuid to authenticate and then
switch to a user.
I see absolutely no reason to restrict a user from doing anything they could
not do through a telnet session.

However, the trick to making CGIs work this way is effectively this:
    You run the script with sufficuent privileges to read the passwd file
and authenticate and setuid lower
    You authenticate
    You setuid lower, to their uid.
    You let them go.

    However, once the UID is set, the taint still remains. Thus, 'blindly
untainting' is equivalent to running the script normally under their
permissions, as if they ran it. setuid is only there to allow authentication
and to switch to the user's uid after such. Nothing taintable runs or should
run before switching to the user's uid. However, Taint mode remains, because
there is no such thing as 'no Taint'.

--
Dodger
www.dodger.org
www.necrosoft.net
www.gothic-classifieds.com





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

Date: 17 May 2001 07:13:19 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: What is wrong with my Regular Expression?
Message-Id: <9dvtmf$m17$1@216.155.32.227>

In article <m1vgn2o913.fsf@halfdome.holdit.com>,
 merlyn@stonehenge.com (Randal L. Schwartz) wrote:

 | You want to get out of their .sig?  Learn how to be less insecure, so
 | that you don't have to be so over-the-top arrogant in your responses
 | to people's responses.  Simple, but could take you the rest of your
 | life to learn that one.  I'm hoping sooner than that.

Alan Wilson Watts (who died in 1973) wrote a book[1] entitled : _The 
Wisdom of Insecurity_ which should be a must-read for any sentient, 
reasonably self-aware, concatenation of protoplasm. :-)[2]

-=-

[1]I recommend starting with _The Book: the Taboo against knowing who 
you are_ before you tackle the above: Mostly to get a beginner's view 
on, and an introduction to, how the gentleman thinks. (quite profoundly, 
IMHO). Additionally good are _Does It Matter?_, _Cloud Hidden, 
Whereabouts Unknown: A Mountain Journal_, _Nature, Man, and Woman_. 
There are also several others.

His _The Supreme Identity_ I've read several times, and never quite 
gotten the same thing out of, at any given time. It's quite intense 
however, and starting with a few of his other works while leading up to 
this one, is recommended.

[2] In the context of the above, reading the subject line again as I was 
about to hit <send>, I was struck by the obvious out-of-left-field 
response, "Your regular expression looks more or less like you're 
sucking on a particularly sour lemon. I should do something about that, 
were I you." Q.E.D. :-)

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


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

Date: 17 May 2001 10:22:49 +0100
From: jcp@myrtle.ukc.ac.uk (J.C.Posey)
Subject: What's wrong with my scope?
Message-Id: <jkoy9rw1g9i.fsf@myrtle.ukc.ac.uk>

I'm afraid that I'm still not getting scope. Below is a script that, 
according to theory, sums the fields for each unique domain.

--DATA SAMPLE--
C|131.231.242.114|9|7847|9|7847
C|131.231.242.117|439|3158435|526|3782766
C|131.111.99.12|0|0|6|3216
C|131.231.81.72|81|1874026|102|1941910
--END DATA--
[NOTE: the actual data file is not delimited at the beginning/end of file
with anything]

--CODE--
#!/usr/local/bin/perl -w

use strict;

my $file = $ARGV[0];
my %urls = ();

$, = '|';

open (INPUT, $file) or die "Can't open file: $!";

    while (my $line = <INPUT>){
	
	chomp($line);
	my @fields  = split(/[|\n]/, $line);

	$urls{$fields[1]} += [$fields[2], $fields[3], $fields[4], $fields[5]];

    }

close (INPUT);

for my $domain (sort keys %urls){
    print $domain, @{ $urls->{$domain}}."\n";
}
--END CODE--

I thought after reading about scope in the Camel, and past groups, and GASP!
even my own past postings, that I understood scope. I thought, that if I 
declared my hash early enough using my %hash, it would then be visible to
the statements that follow (I understand that my $var inside a loop/statement
is only visible inside that loop/statement).

All that said, this script dies in the for loop because "Global symbol "$urls"
requires explicit package name at ./domain-sums2.pl line 24." I've read the
definition of the error from the Camel, but I *thought* I had declared it in
line 6. In short, I'm just not getting it.

A secondary concern that I have is that the script will be used to process a
log file >250MB compressed data, and I am afraid the hash will eat all the
memory.

This is perl, version 5.005_03 built for sun4-solaris

Thanks for your patience and help,
Jake







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

Date: 17 May 2001 09:54:01 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: What's wrong with my scope?
Message-Id: <9e073p$5t2$1@mamenchi.zrz.TU-Berlin.DE>

According to J.C.Posey <jcp@myrtle.ukc.ac.uk>:
> I'm afraid that I'm still not getting scope. Below is a script that, 
> according to theory, sums the fields for each unique domain.

Your scoping is fine.  You don't quite understand Perl variables.

> --DATA SAMPLE--
> C|131.231.242.114|9|7847|9|7847
> C|131.231.242.117|439|3158435|526|3782766
> C|131.111.99.12|0|0|6|3216
> C|131.231.81.72|81|1874026|102|1941910
> --END DATA--
> [NOTE: the actual data file is not delimited at the beginning/end of file
> with anything]
> 
> --CODE--
> #!/usr/local/bin/perl -w
> 
> use strict;
> 
> my $file = $ARGV[0];
> my %urls = ();

This declares the hash %urls.

> 
> $, = '|';
> 
> open (INPUT, $file) or die "Can't open file: $!";
> 
>     while (my $line = <INPUT>){
> 	
> 	chomp($line);
> 	my @fields  = split(/[|\n]/, $line);
> 
> 	$urls{$fields[1]} += [$fields[2], $fields[3], $fields[4], $fields[5]];

The above line is, well, nonsense.  "[$fields[2], ... $fields[5]]" is an
array ref.  You can't reasonably add that to a scalar, as you are trying
to do.  You probably meant to say

       $urls{$fields[1]} +=
           $fields[2] + $fields[3] + $fields[4] + $fields[5];

But this has nothing to do with your question.

>     }
> 
> close (INPUT);
> 
> for my $domain (sort keys %urls){
>     print $domain, @{ $urls->{$domain}}."\n";

Here you are accessing the scalar variable $urls.  It would have
to contain an array reference to be usable this way, but since
it has never been declared, Perl complains.  Lose the "->".

If you look at the error message closely, you will find that it
doesn't mention %urls but $urls.

> }

[...]

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


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