[12978] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 388 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 5 17:17:28 1999

Date: Thu, 5 Aug 1999 14:05:11 -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           Thu, 5 Aug 1999     Volume: 9 Number: 388

Today's topics:
    Re: [offtopic]RE:Quot St and the Jeop Gm <tchrist@mox.perl.com>
    Re: arrays in perl <rootbeer@redcat.com>
    Re: arrays in perl <pwhst+@pitt.edu>
    Re: Cache Problems <cassell@mail.cor.epa.gov>
        chroot mod_perl install programs <trotsky_l@my-deja.com>
        counterfeit cancels, was Re: chomp not working <flavell@mail.cern.ch>
    Re: displaying results a screen at a time. <rmhorton@attotron.com>
        Filtering records from a RADIUS accounting logfile jeff_canning@my-deja.com
    Re: Fwd: Re: My Last Words on =- vs comma (Chris Nandor)
    Re: Fwd: Re: My Last Words on =- vs comma <elaine@chaos.wustl.edu>
    Re: Help - Matching a variable in RegEx. <rootbeer@redcat.com>
    Re: Help getting Perl to work on Windows 98 <dchristensen@california.com>
    Re: Help with a more elegant solution to common problem (Bill Moseley)
        how do I count number of \n in a string? <russell.zah@tellabs.com>
    Re: how do I count number of \n in a string? (Chris Nandor)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 5 Aug 1999 14:23:16 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: [offtopic]RE:Quot St and the Jeop Gm
Message-Id: <37a9f2b4@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    neko_ga_iru@my-deja.com writes:
:Let me say it for you *PLONK*.

Make sure to remove anything on your system from me while
you're at it.  Make sure you don't learn anything.

--tom
-- 
"Imagine you are a congressman. Now imagine you are an idiot.  But I repeat 
 myself." 
				- Mark Twain


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

Date: Thu, 5 Aug 1999 13:20:08 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: arrays in perl
Message-Id: <Pine.GSO.4.10.9908051304430.9452-100000@user2.teleport.com>

On Thu, 5 Aug 1999, Paul W. Hanbury, Jr. wrote:

> In terms of runtime speed, I was wondering how arrays were 
> implemented.

In general, perl will gladly use extra memory in order to save you time.
After all, you can potentially purchase additional memory, but not time.

> For example, if I said 
>     $#my_array = 20_000;
> should I worry about adding more elements than 20,000.

If I understand you correctly, yes, at least temporarily. But you may have
the idea that an array in Perl is a contiguous chunk of memory, as it
would be in some other languages; it's not. Of course, the implementation
details shouldn't matter for most purposes. Here are some possible
exceptions which may be relevant:

    If you're worried about running out of memory, consider a tied array
    which could live on disk.

    If you're wanting a sparse array, perhaps a hash or tied array would
    suit your needs.

    If you're needing to keep a large array of identical items (such as,
    say, more than 10_000 small integers), perhaps you could use vec() or
    something similar to do this efficiently.

If you need something different from these, you may need to be more
specific in your question. Have fun with Perl!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 5 Aug 1999 16:39:48 -0400
From: "Paul W. Hanbury, Jr." <pwhst+@pitt.edu>
To: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: arrays in perl
Message-Id: <Pine.GSO.3.96L.990805163332.25836B-100000@unixs-eval.cis.pitt.edu>



On Thu, 5 Aug 1999, Tom Phoenix wrote:

*On Thu, 5 Aug 1999, Paul W. Hanbury, Jr. wrote:
*
 [text cut from here]
*                                                      But you may have
*the idea that an array in Perl is a contiguous chunk of memory, as it
*would be in some other languages; it's not. 
*
 That answers my question perfectly.  Thank you!  I suspected as much
 from reading perlguts, but wasn't quite sure.
 
 [more text cut]



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

Date: Thu, 05 Aug 1999 13:53:42 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Cache Problems
Message-Id: <37A9F9D6.20543B63@mail.cor.epa.gov>

Jordan DeLozier wrote:
> 
> I have a banner script I have been working on. It loads the images great using
> the Location: $banner, This script has to be made so it does not host the
> image files and it can not be SSI. When I load up an image, then someone else
> loads up an image, then I hit reload, it brings up the same banner, but a
> different link.
> 
> Anyone know how to fix this?

Yes.  Since this is a CGI problem [even though your script is
written in Perl], you're likely to get a more useful response
in the comp.infosystems.www.authoring.cgi newsgroup.  Yes, I
know, your program is in Perl so you thought this was a Perl
issue.  But trust me on this, you really have a CGI issue.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 05 Aug 1999 20:15:57 GMT
From: cahkt-netepbyr <trotsky_l@my-deja.com>
Subject: chroot mod_perl install programs
Message-Id: <7ocrdh$sau$1@nnrp1.deja.com>

I'm attempting to install mod_perl chrooted with Apache on a RH6.0
machine.

I'm having serious problems getting Apache to compile with mod_perl.

I know httpd isn't compiling mod_perl in (or I think it isn't).

The problem is, i don't know if i'm having problems because i don't have
everything required in the correct path for apache
(/usr/local/jail/apache) or what.

When i attempt to compile it according to mod_perl-1.21's INSTALL.apaci,
i get the following:
** A test compilation with your Makefile configuration
** failed. This is most likely because your C compiler
** is not ANSI. Apache requires an ANSI C Compiler, such
** as gcc. The above error message from your compiler
** will also provide a clue.
 Aborting!
Checking CGI.pm VERSION..........ok
Checking for LWP::UserAgent......failed
Can't locate LWP/UserAgent.pm in @INC (@INC contains: ./lib
/usr/lib/perl5/5.00503/i386-linux /usr/lib/perl5/5.00503
/usr/lib/perl5/site_perl/5.005/i386-linux /usr/lib/perl5/site_perl/5.005
 .) at Makefile.PL line 1002.

The libwww-perl library is needed to run the test suite.
Installation of this library is recommended, but not required.


I'm a newbie at the chroot mod_perl installation, and i've read every
doc i can get my hands on, and i'm still really lost.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 5 Aug 1999 21:34:06 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
To: m.ray@ulcc.ac.uk, Tom Christiansen <tchrist@mox.perl.com>
Subject: counterfeit cancels, was Re: chomp not working
Message-Id: <Pine.HPP.3.95a.990805212515.3617C-100000@hpplus03.cern.ch>


[posted and emailed]

On 5 Aug 1999, Tom Christiansen wrote:

> Cancelled by whom, though?  Someone should track this down.  
> Perhaps it's a script kiddie who got RTFM'd. :-)

Here's one

Path:
cern.ch!EU.net!news-peer.gip.net!news.gsl.net!gip.net!news-peer1.sprintlink.net!
news-in-central.sprintlink.net!news.sprintlink.net!news.VirtualVillage.com
Newsgroups: comp.lang.perl.misc
From: "M.Ray@ulcc.ac.uk (Malcolm Ray)" <M.Ray@ulcc.ac.uk>
Subject: cancel <slrn7qgrjo.46k.M.Ray@carlova.ulcc.ac.uk>
Message-ID: <B4D2B6EFB757D211B23B00805F59AC43BBC371@ukmail.virtualvillage.co.uk>
Sender: "M.Ray@ulcc.ac.uk (Malcolm Ray)" <M.Ray@ulcc.ac.uk>
Date: Thu, 5 Aug 1999 05:08:27 -0500
Lines: 3
X-Newsreader: Microsoft (R) Exchange Internet News Service Version 5.5.2448.0
Control: cancel <slrn7qgrjo.46k.M.Ray@carlova.ulcc.ac.uk>



There seemed to be a whole batch of them, targetting a whole swath of
posters here.  Not all the victims were regulars (though an ingenious
kiddie would presumably cancel his own postings too, to confuse the
hunt).




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

Date: Thu, 05 Aug 1999 13:42:25 -0700
From: rmhorton <rmhorton@attotron.com>
Subject: Re: displaying results a screen at a time.
Message-Id: <37A9F731.2395CC68@attotron.com>



sharda@hotmail.com wrote:

> Is there a way to display the result as x number of rows (for example
> 50 rows) at a time, so that when the user reads it all, he can get the
> next 50 rows (by clicking "more" button, for example) and so on.

There might be a way to use the "write" command, using a "format" that
you define. The special variable "$=" sets the lines per page used by
"write".  A defined format can have a top-of-page header defined; you
could probably use this to break the output into pages.

-- 
              Robert M. Horton, Ph.D.
 0  []~ ~ ~ ~ http://www.attotron.com ~ ~ ~ ~[]  0
 |-/_|         rmhorton@attotron.com         |_\-|
 -\_|| He travels swiftest who telecommutes. ||_/-


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

Date: Thu, 05 Aug 1999 20:44:08 GMT
From: jeff_canning@my-deja.com
Subject: Filtering records from a RADIUS accounting logfile
Message-Id: <7oct2l$tko$1@nnrp1.deja.com>

Hi,

Question from a newbie here:

Consider the following record entry from a RADIUS accounting logfile:

Mon Aug  2 14:39:27 1999
        NAS-IP-Address = 100.100.100.1
        Acct-Status-Type = Start
        Acct-Session-Id = "123456"
        Acct-Delay-Time = 0
        Acct-Authentic = RADIUS
        Service-Type = Framed
        NAS-Port-Type = Async
        NAS-Port = 9
        Calling-Station-Id = "0123456789"
        Called-Station-Id = "0123456789"
        Framed-Protocol = PPP
        Framed-IP-Address = 100.100.100.101
        Acct-Link-Count = 1
        Acct-Multi-Session-Id = "23561"
        User-Name = "ABC/aperson"

For the User-Name entry in each "start" record there are essentially
4 unique types representing proxy and standard userids:

For example:
Standard userid:  User-Name = "aperson"
Proxy userid:     User-Name = "aperson@abc.com"
                  or
                  User-Name = "ABC/aperson"
                  or
                  User-Name = "ABC/aperson@abc.com"

What I would like to do is to parse the master detail accounting logfile
and produce separate detail logfiles based on the value of the
"User-Name" entries such as follows:

If user-name begins with "ABC/" and Framed-Protocol=PPP filter to
detail.ABC

If user-name contains a realm-id(i.e an @ sign) and Framed-Protocol=PPP
filter to detail.abc.com.

I have the code for the realm-id working but I'm having a problem with
the "ABC/aperson" entries:

 # Capture the Username and Realm.  No need to look further
 # if we've already seen the Start record.
 next if ($user{$id});
 if ($inputrec =~ /User-Name = "(\S+)"/) {
         ($user{$id},$realm{$id}) = split(/\@/,$1);
 }



# Normalize the realm name.  Records with a NULL realm should be
# assigned to abc.net for PPP sessions.
# Records with a proxy realm should be assigned to each respective
# proxy identity.
if (!$realm{$id}) {
        $realm{$id} = "ppp.abc.net" if ($proto{$id} eq "PPP");
        $realm{$id} = "pptp.abc.net" if ($proto{$id} eq "PPTP");

}

 $realm{$id}=lc($realm{$id});
 # Create an output file name for the realm.
 $outfile = "$infile.$realm{$id}";

Any suggestions including snippets of code would be greatly appreciated!

Regards,
Jeff
________


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 05 Aug 1999 20:36:44 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Fwd: Re: My Last Words on =- vs comma
Message-Id: <pudge-0508991636490001@192.168.0.16>

In article <19990805194435.83398.qmail@hotmail.com>, "Perl King"
<perlking@hotmail.com> wrote:

>We the Perl King hereby approve of the occasional use of =>
>(outside of hash initialization).
>Please do not abuse this privilege.

If you don't want personal attacks, then don't be an anonymous jackass.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Thu, 05 Aug 1999 16:46:54 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: Fwd: Re: My Last Words on =- vs comma
Message-Id: <37A9F823.434AD1A1@chaos.wustl.edu>

Chris Nandor wrote:
> >We the Perl King hereby approve of the occasional use of =>
> >(outside of hash initialization).
> >Please do not abuse this privilege.
> 
> If you don't want personal attacks, then don't be an anonymous jackass.

Oh, c'mon Chris...I'm still laughing at this obvious parody.

/me smiles wickedly at the troll and waves.

e.


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

Date: Thu, 5 Aug 1999 13:37:14 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Help - Matching a variable in RegEx.
Message-Id: <Pine.GSO.4.10.9908051334370.9452-100000@user2.teleport.com>

On Thu, 5 Aug 1999, Nico Zigouras wrote:

> I am interested in matching a variable in my RegEx like.
> 
> $var = "hello";
> if ( $question_variable =~ /$var/ ) {
>   print"$question_variable has the string \"hello\" in it.";
> }

What happened when you tried it?

> I checked the FAQ and they suggested escaping it with a \Q which
> didn't seem to work.

Perhaps it worked, but it did something differently than you intended.

If there's some line of code which isn't doing what you think it should,
could you make a short sample program which shows what's happening and
how that differs from what you expected? Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 5 Aug 1999 13:51:41 -0700
From: "David Christensen" <dchristensen@california.com>
Subject: Re: Help getting Perl to work on Windows 98
Message-Id: <37a9f74c@news5.newsfeeds.com>

Hello, World!

I checked out the DJGPP site:

    http://www.delorie.com/djgpp/

It's a P5/166 running Linux and Apache on an ADSL line.  There are
Lynx and html checkers under the www tools section, but I didn't
see any httpd, browser, or cgi stuff (bad netlag locked me out).
The next step would be to ask on the newsgroup:

    comp.os.msdos.djgpp


For Perl binaries, look on CPAN at:

    http://www.perl.com/CPAN/ports/index.html#win32


The ActivePerl (5.005) for x86 and Alpha link takes you
ActiveState.  Follow the links and you end up at:

    http://www.activestate.com/ActivePerl/download.htm


Back on the CPAN ports page, the modules link under ActivePerl
takes you to:

    http://www.activestate.com/packages/zips/


For www stuff, I think you want the www bundle:

   5/29/99  2:42 AM       266392 libwww-perl.zip


The ActiveState site says their package runs on Win98, and I hope
the module builders checked also.


I assume all the ActiveState stuff was built using Visual C++,
nmake, and cmd.exe on NT.  Type perl -V or use Config to find out
more.


Back on the CPAN ports page, if you follow the Standard Perl
(5.004) for Win32 for x86 link, I believe you get a zip file
containing binaries built with Borland C++ 5.02, dmake, and cmd.exe
under NT.    Type perl -V or use Config to find out more.


For modules, you will need to download source and build them using
identical tools:

    http://www.perl.com/CPAN/modules/01modules.index.html


The Perl 5.005_03 source distribution README.win32 states "this
port is reported to build under Windows95 using the 4DOS shell".


--
David Christensen
dchristensen@california.com





  -----------== 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: Thu, 5 Aug 1999 13:15:28 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Help with a more elegant solution to common problem
Message-Id: <MPG.121390bfdf7db79c989689@nntp1.ba.best.com>

Larry Rosler (lr@hpl.hp.com) seems to say...
> The only serious problem I see in this code is here:
> 
> > sub scan_lines {
> 
> It strongly resembles the situation described in perlfaq6:

Ok,  That makes sense.  I can do this:

   sub build {
        my @regexp = @_;  # this MUST not be local(); need my()
        my $expr = join '||', map { "m/\$regexp[$_]/o" } (0..$#regexp);
        my $match_func = eval "sub { $expr }";

        die if $@;  # propagate $@; this shouldn't happen!
        return $match_func;
    }

my @fields = qw/
                UCB.rank
                DC.identifier
                DC.subject
                DC.title
               /;

    my $find_fields = build( 
            map { qq[<META NAME="$_" CONTENT="(.+)">/I] } @fields
    );

That seems to build a good regular expression, and I assume that which ever
matches will end up in $1.

But then I have this problem:  How do I know WHICH of the regular expressions
matched?  What is returned in $1 has to be place in the correct slot.

That is, I don't know what $fld is below.

    foreach ( @$lines_ref ) {

        if ( &$find_fields ) {

            push( @{$content{$fld}}, $1 );
        }
    }



Also, sub build generates something like
  m/$regexp[0]/o||m/$regexp[1]/o||m/$regexp[2]/o||m/$regexp[3]/o

Why use the array $regexp instead of just plain text passed to the eval
as with:

m/<META NAME="UCB.rank" CONTENT="(.+)">       ||
m/<META NAME="DC.identifier" CONTENT="(.+)">/ ||
m/<META NAME="DC.subject" CONTENT="(.+)">/    ||
m/<META NAME="DC.title" CONTENT="(.+)">/





-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Thu, 05 Aug 1999 16:36:13 -0400
From: Russell Zah <russell.zah@tellabs.com>
Subject: how do I count number of \n in a string?
Message-Id: <37A9F5BD.432BE467@tellabs.com>

Hi,

I have a variable that absorbed the output of a shell program. The
output was a list of names. So

$info ="name1\n
            name2\n
            name3\n
            name4\n
            name5\n
            name6\n
            name7"

Is there a way to calculate the number of lines here? For perl it is one
unique line but I want it to consider this as 7 lines. I tried

while ($info =~ /\n\d+/g)
{ $count++ }

and without parens

while ($info =~ /(\n)\d+/g)
{ $count++ }

and added 'm' and 's' after /g but that didn't help either.
They all returned 0 for $count.

Thanks for any help,

Russell



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

Date: Thu, 05 Aug 1999 20:54:01 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: how do I count number of \n in a string?
Message-Id: <pudge-0508991654060001@192.168.0.16>

In article <37A9F5BD.432BE467@tellabs.com>, Russell Zah
<russell.zah@tellabs.com> wrote:

>I have a variable that absorbed the output of a shell program. The
>output was a list of names. So
>
>$info ="name1\n
>            name2\n
>            name3\n
>            name4\n
>            name5\n
>            name6\n
>            name7"
>
>Is there a way to calculate the number of lines here? For perl it is one
>unique line but I want it to consider this as 7 lines.

But you have 13 lines (12 newline characters).  Don't see them?  Look more
closely.  You have 6 \n sequences, and 6 literal newlines (one after each
\n).

>while ($info =~ /\n\d+/g)
>{ $count++ }
>
>and without parens
>
>while ($info =~ /(\n)\d+/g)
>{ $count++ }

Hm.  Why are you looking for a newline directly before a digit, when the
newline comes after the digit?

   print $info =~ tr/\n/\n/;  # 12 newlines

   print scalar @{[split /\n/, $info]};  # 13 lines

   $count++ while $info =~ /\n/;  # 12 newlines

If you really want to match the digit and then the newline:

   print scalar @{[split /\d\n/, $info]};  # 7

   $count++ while $info =~ /\d\n/;  # 6

Note that the second literal newline after each \n is not counted, because
there is no \d adjacent to it.  But now you don't have the number of lines
or newlines, but the number of lines or newlines ending in a digit (well,
in the case of the split, it is 6 lines ending in a digit and one more
ending in anything at all).

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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


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