[11091] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4691 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 19 16:05:21 1999

Date: Tue, 19 Jan 99 13:00:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 19 Jan 1999     Volume: 8 Number: 4691

Today's topics:
    Re: "Back button" in CGI script (Mike Bristow)
    Re: Array slices with a maximum length <uri@home.sysarch.com>
        Can you help me pass data? q2020262@my-dejanews.com
    Re: CC via email (Was Re: "Back button" in CGI script) (Larry Rosler)
    Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus dturley@pobox.com
        Date::Manip and Daylight Savings Times (Bill Moseley)
        dbmopen vs. tie bluepuma@mailexcite.com
    Re: Determining the OS... (Greg Ward)
        Don't grok closure behavior w/memory (Clinton Pierce)
    Re: Downloading, Perl, Navigator, and file names (Dan Wilga)
    Re: f <gellyfish@btinternet.com>
    Re: How to determine time? <baliga@synopsys.com>
    Re: How to determine time? <kangas@anlon.com>
    Re: How to link image in Perl script ? (Larry Rosler)
    Re: I forgot <dropzone@mail.utexas.edu>
    Re: joining lines from file and sending to array <cdkaiser@delete.these.four.words.concentric.net>
    Re: Lame coding question (Larry Rosler)
        MacPerl question PETER@yaleads.ycc.yale.edu
    Re: Newbie Question (Abigail)
        Parsing Command Line <kangas@anlon.com>
        Pass username and password with a cgi-perl script bryan@scattergood.com
    Re: Perl Criticism <james.b.crigler@lmco.com>
    Re: Perl Criticism (David Formosa (aka ? the Platypus))
    Re: Perl Criticism <gellyfish@btinternet.com>
    Re: Perl Criticism (Gregory Snow)
    Re: Perl Criticism <uri@home.sysarch.com>
    Re: Perl problem :(Offline mode... <gellyfish@btinternet.com>
    Re: Perl, MySQL, and Hassan shopping cart. (Abigail)
    Re: Questions about cookies (Abigail)
    Re: Statistics for comp.lang.perl.misc (Greg Bacon)
        UNIVERSAL::AUTOLOAD <dropzone@mail.utexas.edu>
    Re: Using PERL to access SQL (Abigail)
    Re: Verify an email address (Robert Saunders)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 19 Jan 1999 18:39:35 GMT
From: mike@fat.dotat.at (Mike Bristow)
Subject: Re: "Back button" in CGI script
Message-Id: <slrn7a9kb7.1da.mike@lindt.fat.dotat.at>

On Tue, 19 Jan 1999 18:05:32 GMT, Scratchie <upsetter@ziplink.net> wrote:
>Anyone who uses Lynx, or bothers to turn off JavaScript, is probably not
>going to be seriously confused by a broken "go back" button. I don't use
>JS-enabled "back" buttons myself, but realistically, it's still going to
>work for *most* WWW users. If that's good enough for your purposes, have
>at it. 

You assume that the user disabled javascript, rather than the security
concious IT/MIS/whatever department.

I feel this is a dangerous, even silly, assumption.

However, this is off topic, IMHO.  FU set.  Override if you want to ;-)

-- 
"...Deep Hack Mode--that mysterious and frightening state of
consciousness where Mortal Users fear to tread."
	-- Matt Welsh


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

Date: 19 Jan 1999 14:54:40 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Array slices with a maximum length
Message-Id: <x73e57f37j.fsf@home.sysarch.com>

>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:

  BL> And this doesn't work:

  BL> 	@slice = (@result = &search())[ $page*$slice ..
  BL> 			&min(($page+1)*$slice -1, $#result)];

  BL> because, apparently, @result isn't set yet when $#result gets used (it
  BL> contains -1).

why do you have to assign @result inside the main expression? if you are
going to use a temp var, do it before and it will work as we have
stated. you can't have it both ways.

another idea is to have search return only $n rows maximum and it does
the limiting for the caller. you have to do the max limit somewhere!

  BL> If I am to use an array anyway, I might use an approach with less
  BL> computation:

  BL> 	$page = 2; $slice = 10;
  BL> 	my @result = &search();
  BL> 	@slice = splice @result,$slice*$page,$slice;
  BL> 	$" = "#";
  BL> 	print "\[@slice\]\n";

  BL> Lo and behold, it WORKS. NO undefined fill values! The only thing I
  BL> don't like now, is that the original result array is messed up, which
  BL> *may* be a rather expensive operation.

but again, you are using a proper temp variable here, so the SLICE
operations we have posted would work fine. slice is a loser here as you
say because of the destruction of the array, but only if you need to
keep the array. if this is a cgi search engine, where you get a page of
results, who cares about the rest of the array after this invocation.

you aren't being clear how this search() is being used and why you need
to slice the results. the solution may be at a higher level than just
eliminating undefined values.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Tue, 19 Jan 1999 20:36:03 GMT
From: q2020262@my-dejanews.com
Subject: Can you help me pass data?
Message-Id: <782qbi$jdt$1@nnrp1.dejanews.com>

At the moment I seem to have a slight problem, I've created a program that
creates a frameset using perl, pretty simple, the windows in this frameset are
created using seperate perl scripts (using a standard <frame src="perl.pl">),
is there anyway to pass data to these frame pages?

Thanking anybody in advance.

Steven Cook

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 19 Jan 1999 12:50:36 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: CC via email (Was Re: "Back button" in CGI script)
Message-Id: <MPG.110e8ffcdc768bee9899a6@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <slrn7a9k67.1da.mike@lindt.fat.dotat.at> on Tue, 19 Jan 1999 
18:36:55 GMT, Mike Bristow <mike@fat.dotat.at> says...
> On the vexed question of CCing followups via email.
> 
> On Tue, 19 Jan 1999 08:32:03 -0800, Larry Rosler <lr@hpl.hp.com> wrote:
> >I agree.  Refusal to do so as a matter of policy is a fascistic response 
> >to a polite and reasonable request.  I often CC the response on my 
> >own, unless requested not to -- it gets to the questioner much faster, as 
> >a rule.
> 
> I, personally, find this irritating.  
> 
> Unless I notice that it's an email copy, I will often reply to the email
> and then get a sense of deja vu when reading the newsgroup.

A decent newsreader puts in a notice automatically (see the first line 
above), and it's hard for the recipient to overlook.  I agree that 
without such a notice, it is discourteous, and I resent it too.

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


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

Date: Tue, 19 Jan 1999 19:44:59 GMT
From: dturley@pobox.com
Subject: Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus!
Message-Id: <782nbn$gkb$1@nnrp1.dejanews.com>

In article <7824gr$v01$1@nnrp1.dejanews.com>,
  droby@copyright.com wrote:
> In article <ebohlmanF5pMvx.7u6@netcom.com>,
>   Eric Bohlman <ebohlman@netcom.com> wrote:
> > Jonathan Feinberg <jdf@pobox.com> wrote:
> > : dturley@pobox.com writes:

<SNIP>

I just think its hilarious that a (bad) joke turned into a thread!

--
____________________________________
David Turley
dturley@pobox.com
http://www.binary.net/dturley/

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 19 Jan 1999 12:27:41 -0800
From: moseley@best.com (Bill Moseley)
Subject: Date::Manip and Daylight Savings Times
Message-Id: <MPG.110e8a969fb5aaf5989688@nntp1.ba.best.com>

I'm using Date::Manip's ParseDate() to read input, and I was using 
UnixDate() to convert the results of ParseDate() to a unix time.  But 
that doesn't work across DST changes, it would seem.

         May 1 at noon = 1999050112:00:00
              UnixDate = 925588800
Locatime( UnixDate() ) = Sat May  1 13:00:00 1999 <- off by an hour
     using timelocal() = Sat May  1 12:00:00 1999

Am I doing something wrong in my attempt to use UnixDate()?

(Also, is there a better way to unpack $date below, at least without 
using "$dummy"?)


use Date::Manip qw/ParseDate UnixDate Date_Init/;

use Time::Local;

print "\n";

$date  = ParseDate('May 1 1999 noon');
$utime = UnixDate( $date, '%s');

print "     May 1 at noon = $date\n",
      "          UnixDate = $utime\n",
      'Locatime(UnixDate) = ', scalar localtime( $utime ),"\n";

      ($year, $mon, $mday, $hours, $dummy,  $min, $dummy, $sec) =
          unpack("a4 a2 a2 a2 a2 a a2 a a2", $date);

print ' using timelocal() = ',
       scalar localtime( 
               timelocal($sec,$min,$hours,$mday,--$mon,$year-1900) );



-- 
Bill Moseley mailto:moseley@best.com


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

Date: Tue, 19 Jan 1999 19:56:24 GMT
From: bluepuma@mailexcite.com
Subject: dbmopen vs. tie
Message-Id: <782o12$h9e$1@nnrp1.dejanews.com>

Hi folks,

I just run into an error message using dbmopen :
ndbm store returned -1, errno 28, key "204.174.244.4" at ./analyse line 143.

After browsing through newsgroups and altavista I believe it's because
the value exceeds 1024 characters (bytes).

If I would use the (not as easy to use) tie function, could I get
rid of the 1024 byte limitation of the value ?

regards   Michael

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 19 Jan 1999 18:38:17 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: Determining the OS...
Message-Id: <782jep$455$5@news0-alterdial.uu.net>

Andrew Fry <andrewf@beausys.demon.co.uk> wrote:
> Q1:
> What is the correct (OS-independent) way to determine the
> OS ... is it $^O ?

Yep.  $^O is short for $Config{'osname'}, except you don't have to 'use
Config' (which is kind of expensive).  $Config{'archname'} is more
detailed, but for that you do need to 'use Config'.

> Q2:
> Also, I have a Perl script which sets up configuration files
> for IP-over-X.25 operation. This requires super-user privileges.
> I am trying to produce a CGI version of this script ... but how,
> basically, do I become super-user from within the script ?
> I am aware of the security concerns surrounding this.
> 
> Does this involve use of setuid ? Do I need th caller to provide
> username and password for super-user access ?

This is fraught with danger, but if you insist, two options occur to me:
  * make the CGI script itself setuid, and be very VERY careful
    to give up superuser privileges as soon as possible
  * have an ordinary CGI script call a setuid script for privileged stuff

'man perlsec' for the ins and outs of writing setuid scripts that aren't
hopelessly insecure (I hesitate to use the word "secure" in the same
sentence as "setuid", Perl publicity notwithstanding ;-)

The latter is probably preferable, although you have the problem of one
hit resulting in *two* Perl startups -- not insignificant especially if
the script(s) pull in a lot of modules.

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Tue, 19 Jan 1999 19:10:07 GMT
From: cpierce1@mail.ford.com (Clinton Pierce)
Subject: Don't grok closure behavior w/memory
Message-Id: <36a9d284.354311913@news.ford.com>

I'm about to do something that seems so....counter-intuitive, but
apparently it does the right thing.  Here's a sample of code:

	#!/usr/bin/perl
 
	sub get_response {
 
	        my $rs=sub {
	                print rand(100), "\n";   # or something...
	        };
	        return($rs);
	}
 
	while (1) {
		my $subref;

	        $subref=&get_response;   
	        &$subref;
	}

I plan on setting up get_response to return lots and lots of anonymous
subs, and for some reason, in the back of my head, experience is
whispering:  "This...leaks...memory..."

I tried it, and no, it doesn't leak at all, apparently.  I don't quite
grok why (or how) perl knows that the compiled sub returned in $rs is no
longer accessable.  The only reference to the memory used by the sub is
stored in $subref...  Is it important that $subref be lexically scoped?

I know that $rs needs to be lexically scoped, but on the second (and
subsequent) calls to get_response, how does perl know that the space
currently being referred to by $subref is available at this time?   Does
perl know that &get_response is going to clobber $subref, and therefore
frees its memory before the second invocation of "my $rs=sub {...."?  I
didn't think perl would know that $subref's (pointed to) memory was
available until the return (and assignment) to $subref.

It seems like either perl can predict (while still in get_response) that
$subref value will get clobbered, or that it leaks memory...once.

I understand reference counts to referred to chunks of memory, I just
can't figure out how perl can "look ahead" and free the first anonymous
sub's memory while in the _second_ invocation of get_response...it seems
like it would leak the first chunk of memory...and then reclaim it on
the third invocation...



Thanks you. I am only an egg.
-- 
 Clinton A. Pierce    "If you rush a Miracle Man, you get rotten
 cpierce1@ford.com        miracles" --Miracle Max, The Princess Bride
clintp@geeksalad.org   http://www.geeksalad.org


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

Date: Tue, 19 Jan 1999 13:47:26 -0500
From: dwilgaREMOVE@mtholyoke.edu (Dan Wilga)
Subject: Re: Downloading, Perl, Navigator, and file names
Message-Id: <dwilgaREMOVE-1901991347270001@wilga.mtholyoke.edu>

> I'm trying to have the user save a downloaded file through Navigator 4.x.
> That's not the problem though. The problem is that the default filename is
> always the name of the Perl script that is doing the downloading.

A better way is to use the real URL of the file to be sent, and have the
Web server pass this type of file to the appropriate CGI script. With
Apache, this is done with the AddType and Action directives. So, for
instance, to display "myfile.txt" using "mycgi.cgi":

  <a href="myfile.txt">view file</a>

Then, in access.conf:

  AddType application/x-file-viewer .txt
  Action application/x-file-viewer /cgi-bin/mycgi.cgi

Dan Wilga          dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply  **


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

Date: 19 Jan 1999 18:59:37 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: f
Message-Id: <782kmp$119$1@gellyfish.btinternet.com>

On 19 Jan 1999 17:51:29 GMT Decision Systems Inc wrote:
> What is the best way to pass switches or parameters to my perl script from
> the command line?
> 

A quick survey of the documentation would help of course.

You can obtain the raw arguments from @ARGV or you could use Getopt:Std or
Getopt::Long both of which are included in the standard distribution.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Tue, 19 Jan 1999 11:15:35 -0800
From: Yogish Baliga <baliga@synopsys.com>
To: info@netstyle.nl
Subject: Re: How to determine time?
Message-Id: <36A4D9D6.D76628BF@synopsys.com>

Use
  $tim = `date +%d-%m-%Y/%I.%M%p`;

-- Baliga

info@netstyle.nl wrote:

> Hi newsgroup,
>
> I would like to know how to put the time in a string variable.
> I know this:
>
> $tim= time;
>
> but this gives me the epoch-relative time and I do not want that.
> How to let $tim have the folowing content i.e.
> 19-01-1999/8.05PM
>
> ofcourse I want the actual hosstime instead of static stringcontent.
>
> thanks,
>
> Michel
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own



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

Date: Tue, 19 Jan 1999 13:39:03 -0600
From: Michael Kangas <kangas@anlon.com>
Subject: Re: How to determine time?
Message-Id: <36A4DF56.9FBF6D90@anlon.com>

($s,$m,$h,$d,$mo,$yr,$wk,$yd,$i) = localtime(time);

print "seconds: $s\n";
print "minutes: $m\n";
print "hour: $h\n";
print "day of month: $d\n";
print "month: $mo\n";
print "year: $yr\n";
print "weekday: $wk\n";
print "Day of Year: $yd\n";
print "isdst: $i\n";

Hope this helps.
kangas@anlon.com

Abigail wrote:

> info@netstyle.nl (info@netstyle.nl) wrote on MCMLXVII September MCMXCIII
> in <URL:news:7820h8$rfl$1@nnrp1.dejanews.com>:
> __
> __ I would like to know how to put the time in a string variable.
>
> localtime
>
> Abigail
> --
> perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
>                        -> define ("foldoc", "perl")) [0] -> print'



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

Date: Tue, 19 Jan 1999 12:46:16 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to link image in Perl script ?
Message-Id: <MPG.110e8ef7f06377529899a5@nntp.hpl.hp.com>

In article <83k8yjbn8m.fsf@vcpc.univie.ac.at> on 19 Jan 1999 10:55:37 
+0100, Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> says...
> Re: How to link image in Perl script ?, Larry
> <lr@hpl.hp.com> said:
 ...
> Larry> Small yeccch.  Much clearer:
> 
> Larry>   print '<CENTER><IMG SRC="mainlogo.gif"
> Larry> HEIGHT=54 WIDTH=577></CENTER>';
> 
> Even clearer still?
> 
>     use CGI qw(:all);
>     print center(img({src => 'mainlogo.gif',
>                       height => 54, width => 577}));

Sure, if you don't mind loading a huge module to crack this tiny nut, 
and learning Yet Another Little Language.  I already know HTML.

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


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

Date: Tue, 19 Jan 1999 13:48:25 -0600
From: Forrest Reynolds <dropzone@mail.utexas.edu>
Subject: Re: I forgot
Message-Id: <36A4E189.11737AD6@mail.utexas.edu>

Joe wrote:
> 
> Hi... I remember doing this once but I forgot how to get the values out of
> this baby (it is a variable that got printed and this was the result):
> 
> IO::Socket::INET=GLOB(0x8131790)


this means that it is a reference to a typeglob.. you printed the reference
not the value


that's about all I know , yodie-yo, yodie-yo,
   Forrest
> 
> Can anyone give me a trail to follow... thanks


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

Date: 19 Jan 1999 12:10:22 PST
From: Cameron Kaiser <cdkaiser@delete.these.four.words.concentric.net>
Subject: Re: joining lines from file and sending to array
Message-Id: <782ore$dho@chronicle.concentric.net>

Hampton Keathley <hamptonk@bible.org> writes:

>I'm trying to read in an html file with lines like this:

><div2 type=title><head>Here's the text<BR>
>here's some more text<BR>
>and some more text.

>I want to remove the "<BR>\n" at the end of each line that has <BR>'s
>and make one long line so that it looks like this:

><div2 type=title><head>Here's the text<lb>here's some more text<lb>and
>some more text.

It would probably be easier, and a little more efficient, to treat the
entire file at once versus line-by-line.

undef $/;
open(S, "your/file") || die("open: $!\n");
$q = scalar(<S>); # scalar() prolly not necessary, here only for clarity
close(S);
$q =~ s/<br>\n//ig; # this means that <br> and <BR> also get treated right

--
Cameron Kaiser * cdkaiser.cris@com * powered by eight bits * operating on faith
  -- supporting the Commodore 64/128:  http://www.armory.com/~spectre/cwi/ --
   head moderator comp.binaries.cbm * cbm special forces unit $ea31 (tincsf)
personal page http://calvin.ptloma.edu/~spectre/ * "when in doubt, take a pawn"


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

Date: Tue, 19 Jan 1999 12:33:35 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Lame coding question
Message-Id: <MPG.110e8bfc29f62d2e9899a4@nntp.hpl.hp.com>

In article <781u9c$hl0$1@dinkel.civ.utwente.nl> on Tue, 19 Jan 1999 
13:33:40 +0100, Willem <spam@dikkelul.com> says...
> >if ($network eq "q") {   ## how do I make it check for a uppercase Q as
> well
> 
> if ($network =~ /^q$/i)
> 
> # ^ means beginning of string
> # $ means end of string
> # i means case insensitive

TIMTOWTDI, and when there are other ways than regexen, they are usually 
faster.

#!/usr/local/bin/perl -w
use Benchmark;

$y = 'Q';

timethese(1 << (shift || 0), {
    Cntrl => sub { my $x = 1 },
    Lc    => sub { my $x = lc $y eq 'q' },
    Regex => sub { my $x = $y =~ /^q$/i },
});
__END__

Benchmark: timing 262144 iterations of Cntrl, Lc, Regex...
     Cntrl:  3 wallclock secs ( 1.41 usr +  0.00 sys =  1.41 CPU)
        Lc:  2 wallclock secs ( 2.17 usr +  0.00 sys =  2.17 CPU)
     Regex:  4 wallclock secs ( 3.00 usr +  0.00 sys =  3.00 CPU)

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


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

Date: Tue, 19 Jan 99 15:03:55 EST
From: PETER@yaleads.ycc.yale.edu
Subject: MacPerl question
Message-Id: <182CBD3DCS86.PETER@yaleads.ycc.yale.edu>

Hi.  Can someone tell me how to call a MacPerl script from within another
MacPerl script?


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

Date: 19 Jan 1999 17:18:01 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Newbie Question
Message-Id: <782eo9$pp$8@client2.news.psi.net>

Nathan Owen (nathan.owen@isocor.com) wrote on MCMLXVI September MCMXCIII
in <URL:news:780gk6$r9b$1@ash.prod.itd.earthlink.net>:
== I have a (very) newbie question.  I am writing a Perl script in which I am
== generating a statistical report.  The stats are generated by a program
== outside of perl along with some options.   I use the "exec" function in perl
== to fire off the process along with the options I need.  I execute the
== process nine times, each time with seperate options.  What I need to know is
== how do I "exec" a operating system command, and make sure the that command
== has completed before the next "exec" of a operating system command fires
== off?  I think I am looking for some kind of wait statement.

Did you actually bother to read about the exec statement? If so, your
question is rather amazing....



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)))))))))))))))))))))))))


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

Date: Tue, 19 Jan 1999 13:18:34 -0600
From: Michael Kangas <kangas@anlon.com>
Subject: Parsing Command Line
Message-Id: <36A4DA8A.D8CF7ADA@anlon.com>

Here is some sample text of how I check for options for
a DOS type rgrep.

foreach $arg(@ARGV) {
  if ($arg =~/((\-\w)|(\/.*\/))/) {
     $ignore = 1 if($1 eq "-i");
     $long = 1 if($1 eq "-l");
     $regex = $1 if($arg =~/\/(.*)\//);
 }
}

Hope this is some help.
Michael Kangas
kangas@anlon.com



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

Date: Tue, 19 Jan 1999 19:06:35 GMT
From: bryan@scattergood.com
Subject: Pass username and password with a cgi-perl script
Message-Id: <782l3j$eia$1@nnrp1.dejanews.com>

I would like to be able to pass a username and password to a protected
directory on an httpd unix webserver. I have a goup of usernames and passwords
set up with .htaccess and all of that, but would like to create a back door
link for channel partners and the like.

Any suggestions or tips would be appreciated.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 19 Jan 1999 14:41:41 -0500
From: James B Crigler <james.b.crigler@lmco.com>
Subject: Re: Perl Criticism
Message-Id: <36A4DFF5.9F05184F@lmco.com>

Replying to topmind, Daniel Grisinger wrote:

> >                                      Do you all use only one
> > language and/or always keep them strait?
> 
> >                                           (I am sure a few
> > do keep them strait, but don't exprapolate your greatness
> > in such a narrow area to everybody else.)
> 
> Ability to use your tools is not a sign of greatness.

Including basic knowledge of spelling and grammar (and sometimes 
gramper! ;-) should be included in the toolset.  Topmind is 
evidently lacking in these, to wit:  s/strait/straight/
and s/exprapolate/extrapolate/.  The latter even a spelling checker
would have caught.
-- 
Jim Crigler                 | james.b.crigler@lmco.com
Zone 0100                   | Voice: (770)494-4528
86 S. Cobb Dr.              | "There are three kinds of people:  Those
Marietta GA 30063           | who can count and those who can't."


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

Date: 19 Jan 1999 19:47:51 GMT
From: dformosa@zeta.org.au (David Formosa (aka ? the Platypus))
Subject: Re: Perl Criticism
Message-Id: <slrn7a9ob8.lu1.dformosa@godzilla.zeta.org.au>

In article <782co4$6k0$1@nnrp1.dejanews.com>, topmind@technologist.com wrote:

[...]

>And probably a Perl programmer with variables with
>names like:
>
>ththththaaaattzzit  = thththfileoppzen(<ffffilehandle>,"name.ththat")

This is not perl code.


-- 
Grep bait: troll flame StukaFox catapult 
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
How to win arguments on usenet http://www.zeta.org.au/~dformosa/usenet.html



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

Date: 19 Jan 1999 18:44:59 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Perl Criticism
Message-Id: <782jrb$116$1@gellyfish.btinternet.com>

On Tue, 19 Jan 1999 17:51:15 GMT Richard Clamp wrote:
> 
> [1] excluding that shady group calling themselves Perl Mongers :)

Of course *we* ( that being London.pm ) are probably no better than most
but of course thats as much to do with beer than anything else ... :-}

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 19 Jan 1999 19:42:45 GMT
From: snow@biostat.washington.edu (Gregory Snow)
Subject: Re: Perl Criticism
Message-Id: <782n7l$mrk$1@nntp6.u.washington.edu>

In article <782dek$790$1@nnrp1.dejanews.com>,
 <topmind@technologist.com> wrote:
>In article <36A372C1.D74CD228@atrieva.com>,
>  Jerome O'Neil <jeromeo@atrieva.com> wrote:

>> This has been my contention for some time.  Perl makes it *easier* to
>> write maintainable code due to it's linguistic background.  I have a QA
>> department to which I like to submit my code for review before I place
>> it on-line.  These guys don't know a whole lot of perl, but it is
>> readable enough to get good feedback from them.
>
>
>What exactly is special about Perl or Perlers that makes Perl
>*more* readable? I have seen nothing yet to set Perl apart.
>

Will you listen to an example?

Let's compare with the english language for a minute.  Suppose that as
my wife was leaving the house this morning she is thinking that it
would be good to have dinner as soon as possible after we both get
home (maybe we have somewhere to go after) she says one of the
following to me:

1. If I'm not home befor you, please start on dinner when you get home. 
 
  or

2. Please start dinner when you get home, unless I'm already home.

Both sentances contain the same basic information, but where is the
emphasis of thought put.  For me, sentance 1 focuses my thought first
on who will be home first and what conditions might occure to put each
of us home first, then as an after thought I think about fixing
dinner.  In sentance 2, I'm first thinking about fixing dinner, there
is just the understanding that I may not need to.

Now to bring this around to Perl.  Let's look at 3 code snippets found
inside a loop (based on something I actually wrote).

1.
if ( $var >= $thresh ) {
	$count++;
}

2.
$count++ if  $var >= $thresh;

3.
$count++ unless $var < $thresh;


All three do the same thing (the computer understands what to do in
any of the 3 cases), but what do people think when they see them (code
maintainers).  In the first case the emphasis is on the conditional,
we think first about what circumstances will cause it to be executed
and secondly about what gets done. In cases 2 and 3 it is easy to see
that $count is a count of something (even if it had been named $a32b
or something worse), and then after understanding it is a count, we
can look to the conditional to see what casses are or are not counted.

The differences between 2 and 3 are what the "default" action is.
Statement 2 implies (to me) that $count will not be incremented in
most cases, only the few where the condition holds, while statement 3
implies that the standard (most often) case is to increment $count
except in a few cases.  (2 and 3 have the added advantage of fewer
braces to keep track of and possibly mess up)

So without any comments, we can focus the readers attention 3
different ways (actually more) just by the style of coding.  For my
case I used statement 3, but I can easily imagine other cases where 1
or 2 would convey the reasoning behind code better.

Does that help?  

--
-------------------------------------------------------------------------------
     Gregory L. Snow         |       snow@biostat.washington.edu
     (Greg)                  |
-------------------------------------------------------------------------------
"Would you tell me, please, which way I ought to go from here?"

"That depends a good deal on where you want to get to," said the Cat
                -- Lewis Carrol, "Alice in Wonderland"
-------------------------------------------------------------------------------




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

Date: 19 Jan 1999 15:32:35 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Perl Criticism
Message-Id: <x7sod7dmvw.fsf@home.sysarch.com>

>>>>> "GS" == Gregory Snow <snow@biostat.washington.edu> writes:

  GS> In article <782dek$790$1@nnrp1.dejanews.com>,
  GS>  <topmind@technologist.com> wrote:
  >> 
  >> What exactly is special about Perl or Perlers that makes Perl
  >> *more* readable? I have seen nothing yet to set Perl apart.

  GS> Now to bring this around to Perl.  Let's look at 3 code snippets found
  GS> inside a loop (based on something I actually wrote).

  GS> 1.
  GS> if ( $var >= $thresh ) {
  GS> 	$count++;
  GS> }

  GS> 2.
  GS> $count++ if  $var >= $thresh;

  GS> 3.
  GS> $count++ unless $var < $thresh;


  GS> The differences between 2 and 3 are what the "default" action is.
  GS> Statement 2 implies (to me) that $count will not be incremented in
  GS> most cases, only the few where the condition holds, while statement 3
  GS> implies that the standard (most often) case is to increment $count
  GS> except in a few cases.  (2 and 3 have the added advantage of fewer
  GS> braces to keep track of and possibly mess up)

  GS> So without any comments, we can focus the readers attention 3
  GS> different ways (actually more) just by the style of coding.  For my
  GS> case I used statement 3, but I can easily imagine other cases where 1
  GS> or 2 would convey the reasoning behind code better.

an excellent essay on choice in perl. i use all 3 styles (and others too
like ||, &&) depending on my needs to express what is important and what
is not. i love using unless in both block and modifier roles. it is much
more than just if (!). it expresses that the clause will be less likely
to be executed or you don't care as much about it.

a common idiom to remove blank lines is:

	next if /^\s*$/ ;

which is clear that next is the focus. skip blank lines.

	if ( /^\s*$/ ) {
		next ;
	}

is much less clear. this is a blank line so we are going to do
something. oh, skip it!

perl allows you to express the human semantics of your design in
code. most other lanaguages don't allow that.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 19 Jan 1999 19:07:39 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Perl problem :(Offline mode...
Message-Id: <782l5r$11f$1@gellyfish.btinternet.com>

On Tue, 19 Jan 1999 12:19:45 +0000 Andrew Fry wrote:
> (offline mode : please give name=value pairs via STDIN)
> (... or something like that) and then waiting for some
> reply.
> Why is it doing this ? And what is offline mode ?
> 

You are using CGI.pm - when a program that is using that is run outside
a CGI environment (from the command line for instance) - it will prompt
you to input parameters.  Depending on what platform yu are on then you
will enter something like:

blah=blah
eee=oooh
^[ZD]

The [ZD] is dependent on whether you are using Unix or Windows.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 19 Jan 1999 18:06:20 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl, MySQL, and Hassan shopping cart.
Message-Id: <782his$1kd$1@client2.news.psi.net>

KernelKlink@webtv.net (KernelKlink@webtv.net) wrote on MCMLXVII September
MCMXCIII in <URL:news:27551-36A428B8-49@newsd-104.iap.bryant.webtv.net>:
%% 
%% Can anyone tell me if the following can be done with Perl script(s)
%% Interfacing with the shopping cart and the MySQL database?
%% 
%% "When someone goes to a product page on my site I want the current
%% number of items in stock to display next to the item. When the person
%% orders a product via the shopping cart "add to cart" option, I want the
%% MySQL database to be debited that item at checkout time so that the next
%% person to visit the product page will see the current number of that
%% item in stock."


Yes.


Anything computable can be done with Perl. How difficult it is will
largely depend on your skills.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|8;
 .qq;8768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F;
 .qq;76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V
/=$^U}while$^V!=$^W'


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

Date: 19 Jan 1999 18:09:53 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Questions about cookies
Message-Id: <782hph$1kd$3@client2.news.psi.net>

John (jdebay@NOSPAMearthlink.net) wrote on MCMLXVII September MCMXCIII in
<URL:news:780ta0$qgl$1@fir.prod.itd.earthlink.net>:
== I have a page where I set a number of cookies from JavaScript.  I then want
== to read these cookies when a seperate form is submitted.  The script that
== handles the form can't seem to see the cookies.  I try to read the
== HTTP_COOKIES (or whatever it is) envoronment variable, but it doesn't
== contain any data.  These cookies do exist when I check through JavaScript,
== though.  Is there something I'm doing wrong?  Is there something special I
== have to do to get them sent to the script?  The books I have are no help.
== Thanks to anyone who has any advice.


So, what's the Perl question?



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|8;
 .qq;8768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F;
 .qq;76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V
/=$^U}while$^V!=$^W'


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

Date: 19 Jan 1999 18:28:45 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <782ist$q2b$2@info.uah.edu>

In article <36a84e4c.2986601@news.skynet.be>,
	bart.lateur@skynet.be (Bart Lateur) writes:
: I object! Abigail cheated!

Yeah, I know.  I noticed that she was using different quote characters
and thought about updating the quote regular expression.  I decided
that it would be too long and ugly.  I can wait until we get the nice
[:ispunct:] in the regular expression engine. :-)

Greg
-- 
Boon: Now, she should be decent looking, but we're willing to trade looks for
      a certain kind of morally casual attitude.


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

Date: Tue, 19 Jan 1999 12:54:55 -0600
From: Forrest Reynolds <dropzone@mail.utexas.edu>
Subject: UNIVERSAL::AUTOLOAD
Message-Id: <36A4D4FF.38BFE615@mail.utexas.edu>

Hello,
   I'm currently reading the Panther book and I have two questions:

1) Does UNIVERSAL have an AUTOLOAD subroutine? It doesn't seem like it would (should?)

2) What does "qw" mean in the following:
@ISA = qw(Mammal);

 I looked in the index----> no "qw"!

     Thanks for the info, Forrest


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

Date: 19 Jan 1999 18:28:42 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Using PERL to access SQL
Message-Id: <782isq$1s7$1@client2.news.psi.net>

Stewart Eastham (sme@planetpod.com) wrote on MCMLXVII September MCMXCIII
in <URL:news:36A3D19D.E8F5F782@planetpod.com>:
!! We are using  PERL to import data from a large amount of text files
!! (30,000 files) to a mySQL database.  Here is the method I used, but the
!! system bogged down (i.e. used up too much processing power, so the ISP
!! killed it).   Now, I need to come up with another method:
!! 
!! 1. The script loops through all of text the files in a particular
!! directory
!! 2. It reads in the "key" field from the record contained in the text
!! file
!! 3. It uses a SQL select command to make sure the "key" is not already in
!! the database
!! "select firstName from DB where key='$key'"
!! 4. If the record is not in there, the PERL script creates a "userName"
!! for the record to be entered.
!! 5. The script then uses a SQL select command to make sure that userName
!! is not already in use in the DB.
!! "select firstName from DB where userName='$userName'
!! 6.  If a record in the DB already has that userName, the script will
!! loop, and create a new userName until a unique userName is created for
!! that record.

*boggle* mySQL doesn't know the concept of "identify" columns?

!! 7.  The record from the text file (along with its newly created
!! userName) is entered into the DB.
!! "insert into DB values ('$userName', '$key', '$firstName', '$lastName',
!! '$address')"
!! 8.  The text file is deleted.
!! 
!! This process continues through all of the files in the specified
!! directory.
!! 
!! 
!! The only other method I can think of is to, at the very start of the
!! PERL script, import all of the "key" and "userName" fields from the
!! mySQL database.  Then, instead of querying the SQL DB at least twice for
!! each text file, it would just search through a large array maintained in
!! the PERL script.
!! 
!! I'm sure this method would take up more RAM (since two arrays with 30,
!! 000 entries each would be built), but I'm wondering if it would use less
!! processing power, since there would be less queries to the SQL DB.  Any
!! ideas would be appreciated.  Thank you.


It's impossible to say what takes more processing resources - too many
unknowns. Just measure it.

Of course, going through 30000 files takes a lot of resources anyhow,
no matter what.
-- 
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)))))))))))))))))))))))))


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

Date: Tue, 19 Jan 1999 20:10:34 GMT
From: robert@iminet.com (Robert Saunders)
Subject: Re: Verify an email address
Message-Id: <8DA7B5511767E691.4641BF027F4AC7BE.F9A2610140EA6DE0@library-proxy.airnews.net>

Question... I am a newbie. I guess that is the way you are suppose to
start from reading other post.. anyway.. my question

I saw that I needed The Mail::Address module before this will all
work..  now not totally understanding CSPAN yet.. what steps would I
go thru to look this up.. if I can find it I think the readme will get
me thru the install.. but I am not sure where to start to look for
it..

Robert Saunders
robert@iminet.com








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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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 V8 Issue 4691
**************************************

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