[12897] in Perl-Users-Digest
Perl-Users Digest, Issue: 307 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 30 03:07:17 1999
Date: Fri, 30 Jul 1999 00:05:14 -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 Fri, 30 Jul 1999 Volume: 9 Number: 307
Today's topics:
Re: [Summary] Korn Shell or Perl? (Michael Wang)
Re: Breaking things into modules <cassell@mail.cor.epa.gov>
Re: changing file owner (David Efflandt)
Re: Creating dynamic GIF-s from CGI-script <cassell@mail.cor.epa.gov>
Does this make sense to anyone? (Sean McAfee)
Re: Easy way to emulate Unix's "sort" command? (Larry Rosler)
Re: File upload problem Newbie!! (Abigail)
Re: File upload with cgi-bin and port to MSQL Please he (Abigail)
Re: finding http-redirection (Abigail)
Help pls..<how to use perl to get a file from the inter <leech6@ie.cuhk.edu.hk>
Re: Help pls..<how to use perl to get a file from the i (Mike G.)
Re: Help! - Monitoring script (Abigail)
Re: How do I access the array stored in a given memory (Abigail)
Re: How to count clicks to HTML link. (Abigail)
Re: Modules for Dummies <cassell@mail.cor.epa.gov>
Re: OOP question. (Abigail)
Re: Outputting a HTTP Header (Abigail)
Re: paging text (Abigail)
Re: Printing lines BTW two strings in file (NOT!) (Eric Bohlman)
Re: Re: How to read the submit button as a name or valu <v0xman@yahoo.com>
Re: Refresh problem coming out of Perl script (Abigail)
regexp gurus, perls grep <daniel.heiserer@bmw.de>
Re: Stopping one from breaking the script (Abigail)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Jul 1999 06:40:00 GMT
From: mwang@mindspring.com (Michael Wang)
Subject: Re: [Summary] Korn Shell or Perl?
Message-Id: <37a148c0@news3.us.ibm.net>
brian d foy <brian@pm.org> wrote:
>
>$_ = "local yp";
>foreach my $i ( split )
> {
> open FILE, $i eq 'local' ? "/etc/passwd" : "ypcat passwd |"
> or next;
>
> while( defined( my $line = <FILE> ) )
> {
> ....
> }
>
> close FILE;
> }
Thank you for showing the code. It is close to the shell style, it is cool.
However I still can not apply the code to the mixture of "file"
such as "/etc/passwd" or "ypcat passwd |", and list keys(%beeper_byname).
I would like to go back the "original" problem that I started with
(it is not I who changed the problem):
Randal's code shows clearly what I want to do. My only problem is the
use of @hits, which will cause memory overflow when applied to large
amount of data.
my @hits;
if ($opt_d eq "all") {
for ( split /,/, $opt_b ) {
if (/local/) {
push @hits, keys %beeper_byname;
} elsif (/yp/) {
push @hits, map /(\w+)/, `ypcat -k beeper.byname`;
}
}
} else {
@hits = split /,\s*/, $opt_d;
}
for (@hits) {
next if /YP_/;
my @i=($_);
}
brian showed how @hits can be hidden. But "out of memory" problem
is still there. (I fail to understand why Perl choose to load the whole
thing of `ypcat -k beeper.byname` in memory instead
of piece by piece). Besides it is not real life code.
map (
{ $_ }
grep (
{ ! /^YP_/ }
( $opt_d eq "all" ?
map(
{ if ( /local/ ) { keys(%beeper_byname); }
elsif ( /yp/ ) { map( { /(\w+)/ } `ypcat -k beeper.byname`); }
} split(/,/, $opt_b)
) : split(/,\s*/, $opt_d)
)
)
)
In my "summary", I said Korn Shell pipelines can be done in Perl
without storing the whole stdout in memory, and hence cause
"out of memory" problem, tchrist disagreed but he changed the
specification of the problem, that is why we have to go back and forth.
With brian's new code, I see some hope IF somehow we can associate
a filehandle with things like keys(), map(), grep().
Let me simply state my question again. I need Perl code which does the same
as what shown above, but does not have "out of memory" problem when
applied to large amount of data. I appreciate your help.
------------------------------
Date: Thu, 29 Jul 1999 23:59:38 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Breaking things into modules
Message-Id: <37A14D5A.304F392A@mail.cor.epa.gov>
Hal Mounce wrote:
>
> I have a chunk of perl code which has gotten too big to manage. I broke
> it up into half a dozen subroutines to handle the scut work, and a
> screen or so of mainline code that maps out what I want to do.
> Everything is in package main, and is all in the same file.
That isn't necessarily a bad thing. Yet.
> Now I want to code my first module. At least, I think that's what I
> want to do. I know I'll want to reuse, pretty much verbatim, about half
> of the subroutines I've written. I don't however, want to make a
> federal case out of things. I just want to be able to stash each
> subroutine into a separate file under a directory somewhere.
Okay, now you *do* want to write a module. Or at least a
library of subroutines.
> So, I read up on things, and everything (the FAQ, Came, Panther,
> Cookbook, Effective Perl) seems to say that modules are the way to go.
> Libraries are out of favor.
We're seriously into fads here. :-)
> I've been a couple of days now trying to modularize just one
> subroutine. Should this be hard? (One prior strike: I'm new to unix
> as well as to perl. What the hell is a "make" file anyway...?) I used
> h2xs as described in Effective Perl. (Great book, BTW)
Yikes. My first modules never went anywhere near 'make'
or h2xs. You may be working way too hard.
BTW, 'make' is a nifty unix utility that lets you
'maintain, update, and regenerate related programs and
files' [from the make manpage on Slowlaris]. It uses a
file of directives to tell it what to do to whom. That's
the 'makefile'.
> I seem to be having trouble in three areas. Perhaps someone could buy
> me a vowel:
>
> Area 1)
>
> Although I'm the admin for all the systems I want to use, I don't want
> to integrate my scripts into the perl installation. I'd like to keep
> everything off of /home/hal/perlstuff someplace, and be able to tar
> everything under /home/hal up and squirt it onto different machines.
>
> All of the doc I've read has a blurb about you can do this if you want
> to, but I can't seem to pull it off. I tried use lib
> "/home/hal/perlstuff/MyModules"; with use MyModules::Module; (I put
> &mysub in @EXPORT) but I can't seem to get the incantation just
> right. (I tried @EXPORT = "mysub" as well.)
I like:
@EXPORT = qw/list $of &names %to @export/;
as in
@EXPORT = qw/ &mysub $omething @nother_thing /;
^^^^^
And you did include the magic words 'require Exporter;'
didn't you?
> Does anyone know of something I could model off of out on CPAN
> somewhere? I nosed around, but didn't spot anything between "hack and
> slash" and "software engineering." I'd like to see a perl script that
> counts on some modules in a local library? I think I could get it right
> if I could watch somebody else do it first.
Okay, here's the shortest bit of code I could find that illustrates
this:
------ WTdebug.pm to be placed in *current* directory -------
package WTdebug;
require Exporter;
@ISA = qw/Exporter/;
@EXPORT = qw/ CONST1 CONST2 /;
use constant CONST1 => 3.1415926535;
use constant CONST2 => 2.7182818246;
1;
----- jh1.pl - cheap program to illustrate use constant; ----
#!/usr/local/bin/perl -w
use strict;
use lib '.';
use WTdebug;
my $tmp1 = WTdebug::CONST1; # no '$' since this is a constant
my $tmp2 = WTdebug::CONST2; # ditto
my $circum = $tmp1 * 42;
print $circum, "\n", $tmp2, "\n";
-----------------------------------------------------------
What could be more local than the current working dir?
> Area 2)
>
> Do I really need all that directory hierarchy just to put a subroutine
> in its own file? My script is in /home/hal/perl, but now my subroutine
> is down in /home/hal/perl/MyModules/Module/blib/lib/MyModules/Module.
> Or is that the "real" Module.pm?
You don't need a hierarchy like that, unless it's meaningful
in some external context. What's wrong with having your
private module repository in some simple place like
/home/hal/perl/MyModules/ ? Then you use this path in your
'use lib' statement.
> My intent was to put each subroutine in its own file, so as to be easy
> to reach, yet out of the way when I was busy editing the mainline code.
>
> What does one normally do? One subroutine per module? One module with
> all of ones subroutines?
Depends. Take a look at Text::Soundex . One function.
Now take a look in the CGI module. A shedload of related
package names. Arrange your modules in a way that seems most
meaningful for your re-use patterns.
> Area 3)
>
> I have (so far) one global called $diag which I set in the mainline, and
> use everywhere, like so: print "DIAG: We're here and x is $x\n" if
> $diag; I did a use vars($diag); in package MyModules::Module, but
> that doesn't seem to drag $diag in from package main. Am I in the weeds
Yes. If in your module you say:
use vars qw /$diag &yadda &yada &yaddah/;
then you have predeclared package variables that are global
within your package. You have just obliterated the value of
$diag from main. To find it now, you'd have to access
$main::diag rather than $diag.
> here? Again, a (well written) application to model off of might help.
>
> I was thinking of picking up Learning Perl, but it looks like I'm about
> to the point where Learning Perl drops off. How about Programmer's
> Companion?
No. Try the Perl Cookbook and/or Programming Perl. Both, if
you can afford the cash decrement. Here's my simple rule:
If the authors include any one of {Larry Wall, Randal Schwartz,
Tom Christiansen} then it automatically belongs on my shelf.
Other books have to be inspected. Any book which is for
'dummies' or promises to teach me stuff in a multiple of 7
days is headed for the ol' circular file.
> Oh, and one more thing...
>
> Is it truly evil to use a library? It's very tempting to throw each
> subroutine into a flat file and just require everything in. I don't
> want vinyl siding, but I don't want to sand everything down to bare wood
> either.
Libraries don't kill programs. People kill programs. [I hope
I don't hear from Chuck Heston on this one.] Libraries are
IMHO fine when used by a program, much like you want to do.
But as soon as you need to use one library from another,
you're in deep dreck. And considering that you can turn that
library into a module with a handful of lines of code, it's
hard to argue against making it a module. If you look around,
you'll find Perl libraries out there. Things like syslog.pl
for instance. And as soon as you move to an OO interface...
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 30 Jul 1999 05:24:04 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: changing file owner
Message-Id: <slrn7q2dv6.pp.efflandt@efflandt.xnet.com>
On Tue, 27 Jul 1999 11:53:35 GMT, S Berch <sberch_no-spam_@world.std.com>
wrote:
>On Mon, 26 Jul 1999 14:29:43 GMT, cpierce1@ford.com (Clinton Pierce)
>wrote:
>
>
>>Make the file readable by you, copy its contents into a new file, delete
>>the original (assuming the directory is writable by you and it's not "s").
>
>Thanks for helping.
>
>When I copy the contents of "old" file in to the "new" file, I can not
>change the properties of "new" file. The "chmod" running in the script
>gets an error message that is not the owner. After the script finishes
>"nobody" is the owner and I can not use "chmod" from the command line.
Copy the file from the shell (not from the CGI script) then delete the
original. Otherwise simply 'chmod 0606,filename;' from the CGI, so you
have read and write permission and can do whatever you want to with it in
the shell.
>I seem to get locked out of changing properties and ownership from
>both places. The only solution I can come up with is running the
>script on my user id, which I've been told is a big security risk.
The only security risk is if you don't know what you are doing and
somebody hacks your script. It cannot do any more damage to the system
than you could do yourself. Just note that most systems ignore the suid
bits for scripts (you would likely need a C wrapper).
--
David Efflandt efflandt@xnet.com http://www.xnet.com/~efflandt/
http://www.de-srv.com/ http://cgi-help.virtualave.net/
------------------------------
Date: Thu, 29 Jul 1999 23:17:48 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Creating dynamic GIF-s from CGI-script
Message-Id: <37A1438C.64289D89@mail.cor.epa.gov>
brian d foy wrote:
[snip]
> i was not exxaggerating. you're just not including the full task in
> your answer.
And there's still more. Most beginning Perlites do not write
efficient code. So it might take 50% more code to produce the
same effects. Or 500%, considering some of the code I've
seen. That would put the resulting program at around 12,000
lines just to duplicate some available modules. Ewwwwwww.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Fri, 30 Jul 1999 06:47:10 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Does this make sense to anyone?
Message-Id: <OTbo3.3235$nB.476706@news.itd.umich.edu>
> perl -e '$a = \@b; push @{ $a }, "foo", "bar"; print "@b\n"'
foo bar
> perl -e '$a = \@b; push @{ do { $a } }, "foo", "bar"; print "@b\n"'
Type of arg 1 to push must be array (not hash slice) at -e line 1, near ""bar";"
Execution of -e aborted due to compilation errors.
Replacing "do" with "+do" fixes the problem, but I don't see a hash slice
anywhere in this code. Could this be a parsing bug?
> perl -v
This is perl, version 5.005_02 built for sun4-solaris
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
Date: Thu, 29 Jul 1999 23:36:28 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Easy way to emulate Unix's "sort" command?
Message-Id: <MPG.120ae7bf2d7e3bd6989d74@nntp.hpl.hp.com>
[Posted, and a courtesy copy sent to TomC.]
In article <lfdqn7.eoq.ln@magna.metronet.com> on Thu, 29 Jul 1999
16:27:33 -0400, Tad McClellan <tadmc@metronet.com> says...
> Jim Hutchison (jimhutchison@metronet.ca) wrote:
> : On 28 Jul 1999 20:04:13 -0000, Jonathan Stowe
> : <gellyfish@gellyfish.com> wrote:
...
> : >I would read the article entitled :
> : >
> : > =head2 How do I sort an array by (anything)?
> : >
> : >in perlfaq4. Of course after you have read that and possibly still
> : >have difficulties please feel free to ask again.
...
> @sorted = map { $_->[0] }
> sort { $a->[1] cmp $b->[1] }
> map { [ $_, uc((/\d+\s*(\S+)/ )[0] ] } @data;
> ^^^^^^^^^^^^^^^^^^^^^^
The first time I saw this buggy code today (in the response in this
thread by Darrin Edwards), I chose to ignore it. But now you have
rubbed our noses in it again, Tad, so I thought it was worth an
observation here.
Some of us sometimes boast to newcomers about the thousands of eye-hours
that the solutions in the FAQ have received. Obviously this one hasn't.
Do I need to send a patch, TomC, or can you take it from here?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 30 Jul 1999 01:26:11 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: File upload problem Newbie!!
Message-Id: <slrn7q2hb3.fmt.abigail@alexandra.delanet.com>
Paul Foran (Paul.Foran@analog.com) wrote on MMCLVIII September MCMXCIII
in <URL:news:37A05998.2C01C06D@analog.com>:
== Hi all,
== Can somebody get me started on this one as I am new to Perl. I need to
Here are the first two lines:
#!/opt/perl/bin/perl -w
use strict;
== be able to upload a Data file to a server via a HTML form. The datafile
== is delimited table from MS Access. I need towrite to srcipts that will
== accept the file being uploaded and to also get MSQL to read this table
== into an exsisting table within MSQL.
==
== Any solutions , thanks alot
You mean, completely written programs, based on the 0 characters you
contributed? Sure, but are you going to pay the rates?
Here's a suggestion: learn Perl. Study the specifics of your problem.
Write code. Fail. Learn from your failures. Meditate over the FAQ.
Hug a tree. Write more code. Don't crosspost to comp.lang.perl.modules.
Then, if you get stuck with a specific Perl problem, that's not a FAQ,
or explained in the manual, you post your question here.
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: 30 Jul 1999 01:27:39 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: File upload with cgi-bin and port to MSQL Please help!!
Message-Id: <slrn7q2hds.fmt.abigail@alexandra.delanet.com>
Paul Foran (Paul.Foran@analog.com) wrote on MMCLVIII September MCMXCIII
in <URL:news:37A05727.ABCBE189@analog.com>:
%% I need to be able to upload a delimited data table to me ISP's unix
%% box. How can I get user to browse to the file to upload and execute a
%% perl sctip to accept this file. How Do I pass it onto MSQL table?
Fear. That's the best way to get users do something.
Though passing users onto MSQL tables is pushing it.
Abigail
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
-----------== 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: 30 Jul 1999 01:30:36 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: finding http-redirection
Message-Id: <slrn7q2hjd.fmt.abigail@alexandra.delanet.com>
Uwe W. Gehring (gehring@politik.uni-mainz.de) wrote on MMCLIX September
MCMXCIII in <URL:news:37A1043A.EB7A0966@politik.uni-mainz.de>:
'' Hi,
''
'' I like to query some domains to find their ips, look if they are
'' reachable, to whom they belong (whois), and finally, if the domain is
'' redirected. For example: www.foo.com is actually redirected to
'' www.bar.com/gnu/gnats/. How can I find out that by simply putting
'' "www.foo.com" into my perl script? (Or is there a system program
'' instead?)
#!/opt/perl/bin/perl
www.foo.com
__END__
Well, it compiles and runs, but it doesn't do much, so I guess you
cannot simply put "www.foo.com" in your script!
Try something else, and if you have a real Perl problem, don't be
afraid to ask!
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: Fri, 30 Jul 1999 13:44:18 +0800
From: HING <leech6@ie.cuhk.edu.hk>
Subject: Help pls..<how to use perl to get a file from the internet??>
Message-Id: <Pine.GSO.4.10.9907301342020.18486-100000@iesun44>
HI HI.
can i open a page from the internet??
say open(FH,"http://XXX");
if not what can i do to get file from XXX by using perl??
------------------------------
Date: 30 Jul 1999 06:19:47 GMT
From: tcsh@holly.colostate.edu (Mike G.)
Subject: Re: Help pls..<how to use perl to get a file from the internet??>
Message-Id: <slrn7q2hab.tcj.tcsh@localhost.localdomain>
leech6@ie.cuhk.edu.hk (HING):
> HI HI.
> can i open a page from the internet??
> say open(FH,"http://XXX");
> if not what can i do to get file from XXX by using perl??
>
If you have lynx, here is an easy way :
@array = `lynx -source http://XXX`;
Otherwise, look into LWP::UserAgent
--
Mike G.
------------------------------
Date: 30 Jul 1999 01:33:21 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Help! - Monitoring script
Message-Id: <slrn7q2hoj.fmt.abigail@alexandra.delanet.com>
James Nedham (James_Nedham@ml.com) wrote on MMCLVIII September MCMXCIII
in <URL:news:7npn26$hie$1@news.ml.com>:
[] Does anyone know any examples of Perl scripts that check log files for
[] certain words then notifies me when those words are written to the log
[] files?
[]
[] Also does anyone know how to write a script in Perl to check if a certain
[] process is running & if it isn't then it would notify me?
Yes, I do.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
-----------== 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: 30 Jul 1999 01:01:57 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How do I access the array stored in a given memory location?
Message-Id: <slrn7q2fti.fmt.abigail@alexandra.delanet.com>
Mac Xie (yxie@po-box.mcgill.ca) wrote on MMCLVIII September MCMXCIII in
<URL:news:37A0D512.F2E894BB@po-box.mcgill.ca>:
//
// foreach $i (@temp)
// {
// undef @array;
// ....
// $hash{$i} = \@array;
// }
//
// when I did "print %hash;" here is an example of what I get.
//
// 304-200-1ARRAY(0x2aaa08)304-487-1ARRAY(0x2aaa08)304-487-2ARRAY(0x2aaa08)304-211-1ARRAY(0x2aaa08)304-211-2ARRAY(0x2aaa08)
//
// I noticed that the memory addresses for each key are the same!
Well, yes. That's because you store a reference to the same variable
each time.
// I suspect the problem is that I am using the same array for different
// keys.
Indeed.
// So how do i solve this problem ?
$hash {$i} = [];
Abigail
--
tie $" => A; $, = " "; $\ = "\n"; @a = ("") x 2; print map {"@a"} 1 .. 4;
sub A::TIESCALAR {bless \my $A => A} # Yet Another silly JAPH by Abigail
sub A::FETCH {@q = qw /Just Another Perl Hacker/ unless @q; shift @q}
-----------== 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: 30 Jul 1999 01:05:10 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How to count clicks to HTML link.
Message-Id: <slrn7q2g3o.fmt.abigail@alexandra.delanet.com>
andres (Andres.Magi@microlink.ee) wrote on MMCLVIII September MCMXCIII in
<URL:news:37A067FC.D761A847@microlink.ee>:
:: How to solve problem to count clicks on certain links(pointing out of
:: my site) on my website?
- The easiest way is not to care, then the problem goes away.
- Another easy way is to remove the links, your count will then be 0.
- A slightly more complicated solution is to deny access to the page
if the user agent isn't Lynx. Lynxers don't click, so there's nothing
to count.
- Finally, click counting programs are best written in Forth. You should
ask this question in comp.lang.forth.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
-----------== 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, 29 Jul 1999 23:15:08 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Modules for Dummies
Message-Id: <37A142EC.DA3413AD@mail.cor.epa.gov>
Warren Bell wrote:
[snip]
> I have very limited programing knowledge. I don't want to learn how to write
> a module, I just would like to take advantage of them.
If reading 'perlmod' didn't help, you may have missed the salient
parts, which are about 80% of the way down. Try reading it again,
starting with the part which begins:
Perl modules are included into your program by saying
use Module;
or
use Module LIST;
You see, *using* modules is a lot easier than developing modules.
You just say something like:
use Cwd;
then you use the functions which get imported from the Cwd package.
For example:
use Cwd; # import names from Cwd::
$here = getcwd();
Now $here contains the 'current working directory'. Even better,
each module comes with documentation which tells you what interesting
names [functions, constants, subroutines, ...] the package has to
import.
That's all there is to it. You stick in a 'use File::Copy;' line,
and then you can work with whatever is exported from the package,
just like it was a regular Perl function. There can be additional
complications, but you should be able to get started just by reading
the docs for whatever module catches your fancy.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 30 Jul 1999 00:50:33 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: OOP question.
Message-Id: <slrn7q2f86.fmt.abigail@alexandra.delanet.com>
Colin Jacobs (coljac@home.com) wrote on MMCLIX September MCMXCIII in
<URL:news:37A10668.CAA29008@home.com>:
@@ Hmm... My original question had more to it than I thought, and the
@@ responses have been very illumunating. Thanks, folks.
@@
@@ For those who are interested, the original question was from "Perl 5
@@ Interactive Course" by Jon Orwant. The problem follows:
@@
@@ 'Create four classes: Candy, Gum, Lollipop and Blowpop. Gum and Lollipop
@@ should inherit from Candy; Blowpop should inherit from both Lollipop and
@@ Gum, in that order. All Blowpop objects should contain a variable called
@@ "name". If "name" is "Owl", the order of the @ISA array should be
@@ reversed: Blowpop should inherit from Gum first.'
@@
Well, if one asks evil questions, one is allowed to give evil answers, right?
[[Observation: the question is poorly defined. @ISA is a class variable,
``shared'' by all instances (objects) of Blowpop. Yet name is suggested to
be an instance variable. If A and B are both of objects of class Blowpop,
and A -> {name} eq 'Owl' and B -> {name} eq 'Log', it's unclear what
@Blowpop::ISA should be. So, for the sake of finding an answer, let's
assume $Blowpop::name is a class variable.]]
So, let's try to tie @ISA. ;-)
package Evil::ISA;
sub TIEARRAY {
my $class = shift;
my $owl = shift;
bless [$owl, [@_], [reverse @_]] => $class;
}
sub _which {
${shift -> [0]} ne 'Owl' ? 1 : 2
}
sub FETCH {
my $self = shift;
my $index = shift;
$self -> [_which $self] -> [$index];
}
sub STORE {
my $self = shift;
my $index = shift;
my $value = shift;
my $main = _which $self;
my $other = 3 - $main;
$self -> [$main] -> [$index] = $value;
$self -> [$other] = [reverse @{$self -> [$main]}];
$value;
}
sub FETCHSIZE {
my $self = shift;
scalar @{$self -> [1]};
}
sub STORESIZE {
my $self = shift;
my $size = shift;
my $main = _which $self;
my $other = 3 - $main;
$#{$self -> [$main]} = $size + 1;
$self -> [$other] = [reverse @{$self -> [$main]}];
$size;
}
sub CLEAR {
my $self = shift;
$self -> [1] = [];
$self -> [2] = [];
return;
}
sub PUSH {
my $self = shift;
my $main = _which $self;
my $other = 3 - $main;
push @{$self -> [$main ]}, @_;
unshift @{$self -> [$other]}, reverse @_;
@_;
}
sub POP {
my $self = shift;
my $main = _which $self;
my $other = 3 - $main;
pop @{$self -> [$main ]};
shift @{$self -> [$other]};
}
sub SHIFT {
my $self = shift;
my $main = _which $self;
my $other = 3 - $main;
shift @{$self -> [$main ]};
pop @{$self -> [$other]};
}
sub UNSHIFT {
my $self = shift;
my $main = _which $self;
my $other = 3 - $main;
unshift @{$self -> [$main ]}, @_;
push @{$self -> [$other]}, reverse @_;
@_;
}
sub SPLICE {
my $self = shift;
my $off = shift;
my $len = shift;
my $main = _which $self;
my $other = 3 - $main;
my @r = splice @{$self -> [$main ]}, $off, $len, @_;
$self -> [$other] = [reverse @{$self -> [$main]}];
@r;
}
sub EXTEND {}
package Lollipop;
sub consume {
print "This is Lollipop::Consume\n";
}
package Gum;
sub consume {
print "This is Gum::Consume\n";
}
package Blowpop;
use vars qw /@ISA $name/;
$name = 'Log';
tie @ISA, 'Evil::ISA', \$name, qw /Lollipop Gum/;
sub new {
my $proto = shift;
my $class = ref $proto || $proto;
bless \my $x => $class;
}
package main;
my $stick = Blowpop -> new;
# print "@Blowpop::ISA\n";
$stick -> consume;
__END__
However, Perl must be playing some dirty tricks, as it cannot find
the method 'consume'. Uncommenting the print shows that @Blowpop::ISA
is set to ("Lollipop", "Gum"), and if we replace the tie to a simple
@ISA = qw /Lollipop Gum/, things work correctly.
Too bad.
Abigail
--
Hmmm, should I take the above code and send it to perlbug?
-----------== 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: 30 Jul 1999 01:41:46 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Outputting a HTTP Header
Message-Id: <slrn7q2i8b.fmt.abigail@alexandra.delanet.com>
news.mdo.net (norris@mdo.net) wrote on MMCLIX September MCMXCIII in
<URL:news:jn3o3.941$IE.19784@typ21b.nn.bcandid.com>:
\\ Hi all,
\\ I am trying to figure out how to redirect to a document that is in a
\\ password protected directory on NT system without giving that
\\ login/password information to the user. Can I override the HTTP headers and
\\ replace them with what I want to use and will NT parse and accept them
\\ before automatically kicking out a login request to the user?
And what is your Perl question?
Abigail
--
perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'
-----------== 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: 30 Jul 1999 01:06:53 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: paging text
Message-Id: <slrn7q2g6v.fmt.abigail@alexandra.delanet.com>
John Pavlakis (johnp@vcimail.com.remove.me) wrote on MMCLVIII September
MCMXCIII in <URL:news:rq15q6$0$37nspbi$n2p@corp.supernews.com>:
{} How do I page text read from STDIN or a file so it does not scroll all at
{} once? I am using NT and Unix. Thank you.
Pipe it into a pager. (I assume you mean STDOUT).
Of course, this isn't at all relevant to Perl.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
-----------== 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: 30 Jul 1999 06:06:32 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Printing lines BTW two strings in file (NOT!)
Message-Id: <7nrfd8$9mp@dfw-ixnews15.ix.netcom.com>
John Hagen (jhagen@blarg.net) wrote:
: I have a perl script that does not print lines between two strings in a file,
: as I expected it would. In fact, it does not print anything at all.
: foreach $i ( 0 .. $#eks_file ) {
:
: if ( $eks_file[$i] =~ /BALANCING CONDITIONS/ ) {
:
: while ( $eks_file[$i] !~ /\*\*\*\*/ ) {
:
: print "++> $eks_file[$i]";
:
: }
The previous loop will run either forever or not at all, since the only
variable part of the conditional ($i) is never changed within the loop.
Incrementing it, though, won't help because the next time around the main
loop, $i will get reset.
As others have pointed out, this type of problem really cries out for the
range operator.
------------------------------
Date: Fri, 30 Jul 1999 02:43:41 -0300
From: "Vox" <v0xman@yahoo.com>
Subject: Re: Re: How to read the submit button as a name or value
Message-Id: <uXao3.42463$jl.29878042@newscontent-01.sprint.ca>
Abigail <abigail@delanet.com> wrote in message
news:slrn7q29ed.fmt.abigail@alexandra.delanet.com...
Vox (v0xman@yahoo.com) wrote on MMCLIX September MCMXCIII in
<URL:news:Tb6o3.41439$jl.29705745@newscontent-01.sprint.ca>:
%% On my page I have more than one submit button with different names and
%% values ...
%%
%% how can do I get perl to read the input below?
%%
%% <input type=submit name="answer" value="Yes">
%% <input type=submit name="answer" value="No">
%% <input type=submit name="cancel" value="Cancel">
%%
%% I've seen this in other places but don't know how to implement it myself.
>Then you lack knowledge of how CGI works. Which means your question
>isn't a Perl question, as you wouldn't know how to implement it in C,
>Forth or Ada either. You wouldn't even know how to do it in English.
I was trying to figure out how to get the perl to read the input html of the
'submit' buttons. Although I do lack a lot of knowledge about CGI because I
am a rookie, I do have a basic understanding of it.
I ended up figuring it out that the problem had nothing to do with my
question. The submit button is read with other common input but I thought
that the submit button would be read differently. I tried getting the cgi
to read the submit button as any other input by giving it a name and value
the first time but it didn't work because of a different bug in my program.
After fixing the bug it all worked out fine.
%% To get the users input and configure it I do the code below:
%%
%% read(STDIN, $input, $ENV{'CONTENT_LENGTH'})
>Stop! Do not use such code. Why don't you use CGI.pm?
>Abigail
What do you mean by 'Do not use such code'. It works fine for getting the
input from users and what is CGI.pm?
------------------------------
Date: 30 Jul 1999 01:46:47 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Refresh problem coming out of Perl script
Message-Id: <slrn7q2ihb.fmt.abigail@alexandra.delanet.com>
Jeff Pitman (jpitman@novell.com) wrote on MMCLVIII September MCMXCIII in
<URL:news:7npr0b$cl8$1@acs2.byu.edu>:
;; Anyone had this problem? When the user hits back on the browser it re runs
;; the perl script and goes to the same "redirected" page. What I want to do
;; is when the user clicks on a link, the perl script takes them to a
;; redirected page and then when they hit Back, they go to the originating
;; referer page. I've tried <meta http-equiv="refresh.... and also I've tried
;; a mixture of JavaScript to force the browser to skip/delete the Perl script
;; entry in the history.
;;
;; Got any solutions? It's been bugging me all week!!
Yes. Go away. This group is about Perl, not about misusing HTML for
HTTP tasks.
Abigail
--
perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
-----------== 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: Fri, 30 Jul 1999 08:49:53 +0200
From: Daniel Heiserer <daniel.heiserer@bmw.de>
Subject: regexp gurus, perls grep
Message-Id: <37A14B11.EE58E19F@bmw.de>
Hi,
I am hacking around in a ascript for parsing
larger files (up to 200MB).
I read the stuff with
"read ip,$data,3E8;"
then I split it into lines
"@Data=split("\n",$data);"
after that I search for the stuff I am interested:
"@Tmp=grep(m/perl/,@Data);"
Now I would like to have back not only the lines
which match, I also would like to have back the
array-indices which match (similar to unix' "grep -n").
There is some information, which is not in the line
I know the pattern for, but one, or two lines below or
above:
example:
I would like to know what language somebody prefers:
#------------------------------------------------
perl
is cool, I like it
tcl
I don't like
#------------------------------------------------
Now, if I search for /perl/ and I know that in the
next line is my information I could get it IMMEDIATELY
once i know the array-index for the perl-matches.
I just would take $Data[n+1] if perl matches in "n".
I know I could work on the whole $data with
some
s/(.|\n)*perl\n//;
But remember my variable $data is REALLY BIG and I don't want
an overkill.
I also know I could do some loops
for ($ii=0;$ii<=#$@Data;$ii++){
if ($Data[$ii]=~m/perl/){
#take $ii+1
}
}
But I think that's too long. :-(
So the question is simple:
Is there a better way to do it?
Perhaps like one similar to "grep -n"?
Maybe something really efficient and elegant?
Or do I have to take one of the above I mentioned?
Thanks for your time,
Bye daniel
Please
mailto:daniel.heiserer@bmw.de
------------------------------
Date: 30 Jul 1999 01:53:30 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Stopping one from breaking the script
Message-Id: <slrn7q2iu6.fmt.abigail@alexandra.delanet.com>
Ben Hall (bhall@omega.scs.carleton.ca) wrote on MMCLVIII September
MCMXCIII in <URL:news:37A05927.2C4010F0@omega.scs.carleton.ca>:
^^ Hi, could someone tell me (preferibly by e-mail) how one can stop ctrl-c
^^ from breaking out of my perl script? I wan't to catch it and send it to
^^ /dev/null, I guess.
That's a FAQ.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
-----------== 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: 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 307
*************************************