[19385] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1580 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 21 18:05:32 2001

Date: Tue, 21 Aug 2001 15: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)
Message-Id: <998431511-v10-i1580@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 21 Aug 2001     Volume: 10 Number: 1580

Today's topics:
    Re: Baiting Gozilla to obtain quality code for nothing! <fty@mediapulse.com>
    Re: Baiting Gozilla to obtain quality code for nothing! (John J. Trammell)
    Re: Baiting Gozilla to obtain quality code for nothing! <tsee@gmx.net>
    Re: Best Perl shops? (Clarence Johnson)
        CGI FAQ beta =) (was Re: CGI) (Tim Hammerquist)
    Re: CGI FAQ beta =) (was Re: CGI) <EvR@compuserve.com>
        CGI <Jeff@aetherweb.co.uk>
    Re: CGI <Tassilo.Parseval@post.rwth-aachen.de>
    Re: CGI (John J. Trammell)
    Re: CGI (Randal L. Schwartz)
    Re: CGI <Tassilo.Parseval@post.rwth-aachen.de>
    Re: CGI <gnarinn@hotmail.com>
        Custom Perl Script for Scanning IP's and Resources? <globalpunk@hotmail.com>
        For loop iterator variable not working correctly?? <miscellaneousemail@yahoo.com>
    Re: For loop iterator variable not working correctly?? (Eric Bohlman)
    Re: For loop iterator variable not working correctly?? (Abigail)
    Re: For loop iterator variable not working correctly?? <miscellaneousemail@yahoo.com>
    Re: For loop iterator variable not working correctly?? (Tad McClellan)
    Re: Help w/grep <gnarinn@hotmail.com>
    Re: HTTP::Request::Common file upload <gnarinn@hotmail.com>
    Re: Is element in array <pascal.jolin@videotron.ca>
    Re: Is element in array <pascal.jolin@videotron.ca>
    Re: Is element in array <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Is element in array (Tim Hammerquist)
        Last index of array referenced in a scalar?? <miscellaneousemail@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 21 Aug 2001 18:08:13 GMT
From: "Jay Flaherty" <fty@mediapulse.com>
Subject: Re: Baiting Gozilla to obtain quality code for nothing!!
Message-Id: <hsxg7.93095$ai2.6511088@bin2.nnrp.aus1.giganews.com>


"Dave Stafford" <Dave.Stafford@globis.net> wrote in message
news:Qkbb7.344055$XL1.5838870@nlnews00.chello.com...
> "Walnut" <walnut@froggy.com.au> wrote in message
> However, whilst his social skills are somewhat lacking, I do enjoy his
> sentence constructions which are most amusing (albeit accidentally so).
> Perhaps we can start a "my favourite Godzilla-isms" list. My recent fav
is:
>
> "your repeated attempts at censorious censure"
>
> I imagine him saying it as Biggus Dickus would in the Life of Brian. (Say
it
> to yourself with a bigger lisp than Daffy duck and you're pretty much
> there:-)

Godzilla! has always come across to me as Ignatius J. Reilly from John
Kennedy Toole's "A Confederacy of Dunces". There are a lot of Ignatiusisms
in his posts:
"My presumption is you are childishly helpless or exhibit flatline brain
activity, perhaps both."
"Personally, I hold an opinion both you and your troll articles amount to
nothing more than canned mule manure."
"There is no doubt about your enjoying being the loving mouthpiece for
geekster boys around here."
"What you are missing leaves you without an ability to think about what you
are missing."
"Yours is mindless Perl 5 Cargo Cult Dogma."
" Nonetheless, others will benefit from this article. In this, I take pride;
I am a beneficial contributor to our Perl community."
"Clearly the originating author enjoys two loving mouthpieces."

Anyone who has read C of D know what I mean :-)

Jay











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

Date: 21 Aug 2001 18:46:28 GMT
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Baiting Gozilla to obtain quality code for nothing!!
Message-Id: <slrn9o5qa2.3qv.trammell@haqq.hypersloth.net>

On Tue, 21 Aug 2001 18:08:13 GMT, Jay Flaherty <fty@mediapulse.com> wrote:
> Godzilla! has always come across to me as Ignatius J. Reilly from John
> Kennedy Toole's "A Confederacy of Dunces".

http://www.winternet.com/~mikelr/flame63.html



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

Date: Tue, 21 Aug 2001 23:06:36 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Baiting Gozilla to obtain quality code for nothing!!
Message-Id: <9lui9u$1tv$07$1@news.t-online.com>

"John J. Trammell" <trammell@haqq.hypersloth.invalid> schrieb im Newsbeitrag
news:slrn9o5qa2.3qv.trammell@haqq.hypersloth.net...
> On Tue, 21 Aug 2001 18:08:13 GMT, Jay Flaherty <fty@mediapulse.com> wrote:
> > Godzilla! has always come across to me as Ignatius J. Reilly from John
> > Kennedy Toole's "A Confederacy of Dunces".
>
> http://www.winternet.com/~mikelr/flame63.html

http://www.winternet.com/~mikelr/flame67.html

;P




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

Date: 21 Aug 2001 14:42:17 -0700
From: clarencewjohnson@yahoo.com (Clarence Johnson)
Subject: Re: Best Perl shops?
Message-Id: <928b6bc8.0108211342.1a28465a@posting.google.com>

> > Can anyone recommend consulting firms (smaller size) that have very
>
> why small?

actually, it doesn't have to be small.  it's just that smaller firms can
take on smaller jobs for often lower prices (e.g., the sapients of the world
charge an arm and a leg--they're way out of league).

> it depends on what a reasonable price is, but i think i could
> recoomend one ;)

"reasonable price" is just a competitive rate for the quality being utilized

> what sort of Perl work is it that you need?  some Perl support
> and training firms are listed on www.perl.org.

need to build a perl interface to a c library.  i checked out www.perl.org
and couldn't find the list you were referring to.

thanks, clarence


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

Date: Tue, 21 Aug 2001 21:30:53 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: CGI FAQ beta =) (was Re: CGI)
Message-Id: <slrn9o5ldm.m92.tim@vegeta.ath.cx>

Me parece que Jeff Snoxell <Jeff@aetherweb.co.uk> dijo:
> Hi,
> 
> Does anyone else think there's a massive need for a decent CGI newsgroup.
> It's such a widely used thingy jobby that it should warrant a high profile,
> and busy, newsgroup. The only one I can find, however, is
> "comp.infosystems.www.authoring.cgi" which is "self moderated", whatever
> that means, and receives maybe 2 posts a day.
> 
> On that note, would anyone mind if I posted a CGI related question in here?

You might try the perl-win32-web maillist at activestate.com. If your
CGI question is not directly related to Perl, don't count on getting out
flame-free. =)

FAQ: Generic CGI FAQ

Q: The server displays my cgi scripts instead of executing them.

    A: server config problem; not Perl; check server docs

Q: I get a HTTP 500 error when running my CGI script.

    A: Possibly Perl. Check the server logs. Run script from the command
    line with -w and 'use strict' (at least do this before posting a Q,
    if not all the time).

Q: I'm using Windows and have never heard of this 'command line' you
    speak of.

    A: This dates back to when our great-great-grandparents were young,
    raising small dinosaurs on the veldt. Before we had CD-ROM drives, MP3s,
    or even sliced bread. Vinyl records were still the state-of-the-art
    medium, and "Personal Computers" were a science-fiction myth. The
    coolest video game you could find was Pong (which is still fun, btw).
    Examples of command line interpreters (or 'shells') are: sh, bash, csh,
    tcsh, ksh, command.com. The latter was only found on MS-DOS
    (the oldest but still most stable software ever to be produces by
    Microsoft), and MS Windows. The others were developed for *nix OS's and,
    until recently, not available on Microsoft operating systems.

Q: Windows has a command line?!?!

    A: Check the Start menu for 'MS-DOS Prompt' or 'Command Shell', et al.

Q: Ok, I found this 'command line' thing. How does it work?

    A: I'm not about to explain how it works because a) I haven't figure out
    what brand of logic is ascribes to and b) Microsoft hasn't even felt the
    need to document it since, what, MS-DOS 5.0 (circa release of Win3.0)?

But all in all, the perl-win32-web group is much more receptive to
server config problems, if not CGI problems.

-- 
We all know linux is great...it does infinite loops in 5 seconds.
    -- Linux Torvalds


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

Date: Tue, 21 Aug 2001 15:49:01 -0600
From: "Richard A. Evans" <EvR@compuserve.com>
Subject: Re: CGI FAQ beta =) (was Re: CGI)
Message-Id: <9lul1a$5f7$1@suaar1ac.prod.compuserve.com>

> Q: I'm using Windows and have never heard of this 'command line' you
>     speak of.
>
>     A: This dates back to when our great-great-grandparents were young,
>     raising small dinosaurs on the veldt. Before we had CD-ROM drives,
MP3s,
>     or even sliced bread. Vinyl records were still the state-of-the-art
>     medium, and "Personal Computers" were a science-fiction myth. The
>     coolest video game you could find was Pong (which is still fun, btw).
>     Examples of command line interpreters (or 'shells') are: sh, bash,
csh,
>     tcsh, ksh, command.com. The latter was only found on MS-DOS
>     (the oldest but still most stable software ever to be produces by
>     Microsoft), and MS Windows. The others were developed for *nix OS's
and,
>     until recently, not available on Microsoft operating systems.

Ouch!!!  I remember those days quite well.  Contrary to what a lot of people
today seem to think, you can do a lot of work without a GUI.

> Q: Windows has a command line?!?!
>
>     A: Check the Start menu for 'MS-DOS Prompt' or 'Command Shell', et al.

And personally, I find you can get a lot of work done using the prompt --
often easier than using the GUI tools.


> Q: Ok, I found this 'command line' thing. How does it work?
>
>     A: I'm not about to explain how it works because a) I haven't figure
out
>     what brand of logic is ascribes to and b) Microsoft hasn't even felt
the
>     need to document it since, what, MS-DOS 5.0 (circa release of Win3.0)?

I believe it was actually a little later than v5.0, but they have certainly
neglected this, as Win95 was to do away with DOS entirely.  Then Win98 was
to do so.  Then Win2000.  Perhaps XP?




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

Date: Tue, 21 Aug 2001 21:03:10 +0100
From: "Jeff Snoxell" <Jeff@aetherweb.co.uk>
Subject: CGI
Message-Id: <9luevk$huv$1@plutonium.btinternet.com>

Hi,

Does anyone else think there's a massive need for a decent CGI newsgroup.
It's such a widely used thingy jobby that it should warrant a high profile,
and busy, newsgroup. The only one I can find, however, is
"comp.infosystems.www.authoring.cgi" which is "self moderated", whatever
that means, and receives maybe 2 posts a day.

On that note, would anyone mind if I posted a CGI related question in here?

:)

Jeff




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

Date: Tue, 21 Aug 2001 22:23:25 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: CGI
Message-Id: <3B82C33D.9020505@post.rwth-aachen.de>

Jeff Snoxell wrote:
> Hi,
> 
> Does anyone else think there's a massive need for a decent CGI newsgroup.
> It's such a widely used thingy jobby that it should warrant a high profile,
> and busy, newsgroup. The only one I can find, however, is
> "comp.infosystems.www.authoring.cgi" which is "self moderated", whatever
> that means, and receives maybe 2 posts a day.
> 
> On that note, would anyone mind if I posted a CGI related question in here?

I am sure no one would mind if you posted a Perl related question. So, 
hmmh, assuming you do your CGI stuff in Python, people would mind that. ;-)

Tassilo

PS: You are aware that comp.lang.perl.cgi exists?--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: 21 Aug 2001 20:26:19 GMT
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: CGI
Message-Id: <slrn9o6059.48v.trammell@haqq.hypersloth.net>

On Tue, 21 Aug 2001 21:03:10 +0100, Jeff Snoxell <Jeff@aetherweb.co.uk> wrote:
> On that note, would anyone mind if I posted a CGI related question in here?

Wait a sec....

*PLONK*

kay, go right ahead.

-- 
To think intelligently about copyrights, patents or trademarks, you must
think about them separately.  The first step is declining to lump them
together as "intellectual property".                  - Richard Stallman


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

Date: 21 Aug 2001 14:09:01 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: CGI
Message-Id: <m1n14tjf2q.fsf@halfdome.holdit.com>

>>>>> "Tassilo" == Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> writes:

Tassilo> Jeff Snoxell wrote:
>> Hi,
>> Does anyone else think there's a massive need for a decent CGI
>> newsgroup.
>> It's such a widely used thingy jobby that it should warrant a high profile,
>> and busy, newsgroup. The only one I can find, however, is
>> "comp.infosystems.www.authoring.cgi" which is "self moderated", whatever
>> that means, and receives maybe 2 posts a day.
>> On that note, would anyone mind if I posted a CGI related question
>> in here?

Tassilo> I am sure no one would mind if you posted a Perl related question. So,
Tassilo> hmmh, assuming you do your CGI stuff in Python, people would mind
Tassilo> that. ;-)

Well, comp.infosystems.www.authoring.cgi usually has the intersection
of Perl and CGI experts.  Perl is used for a lot more than CGI, and
most Perl-CGI problems turn out to be more CGI-related than
Perl-related, so having people with the right weird mindset clearly
helps the quality of answers.

Tassilo> PS: You are aware that comp.lang.perl.cgi exists?--

No, it doesn't.  I didn't see a smiley there.  Are you confusing it
with CIWAC?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 21 Aug 2001 23:19:28 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: CGI
Message-Id: <3B82D060.7030405@post.rwth-aachen.de>

Randal L. Schwartz wrote:

> Tassilo> PS: You are aware that comp.lang.perl.cgi exists?--
> 
> No, it doesn't.  I didn't see a smiley there.  Are you confusing it
> with CIWAC?

No, I was confusing it with de.comp.lang.perl.cgi. This tiny de. is 
easily overlooked. :-)

Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Tue, 21 Aug 2001 20:50:10 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: CGI
Message-Id: <998427010.870296372100711.gnarinn@hotmail.com>

In article <9luevk$huv$1@plutonium.btinternet.com>,
Jeff Snoxell <Jeff@aetherweb.co.uk> wrote:
>Does anyone else think there's a massive need for a decent CGI newsgroup.
>It's such a widely used thingy jobby that it should warrant a high profile,
>and busy, newsgroup. The only one I can find, however, is
>"comp.infosystems.www.authoring.cgi" which is "self moderated", whatever
>that means, and receives maybe 2 posts a day.

maybe your ISP's newsserver is dropping a lot of articles. according to
google, it received 116 articles in the last 7 days

>
>On that note, would anyone mind if I posted a CGI related question in here?

not if the question is more perl related than cgi related.
otherwise comp.infosystems.www.authoring.cgi is the place to go.

just make sure you read all FAQs you can find first.

gnari

P.S. the answer is probably: 
  use CGI;



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

Date: Tue, 21 Aug 2001 15:17:22 -0300
From: "Belphegor" <globalpunk@hotmail.com>
Subject: Custom Perl Script for Scanning IP's and Resources?
Message-Id: <isyg7.31951$vG4.1593277@weber.videotron.net>

Okay, here's the issue

I need to get a perl script that will scan ips, (ping them) with a given
set.
1. I say "192.1.1 -100" and it'll ping  from "192.1.1.1" to "192.1.1.255",
with the exception of "192.1.1.100".
2. Then it asks for Samba Share name.
3. Then it asks for the SHARES it enters ALL Share data, and EVERY Last file
into a given database......

can someone help me out here please? that's very important!
thanks in advance!

Belphegor




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

Date: Tue, 21 Aug 2001 19:26:07 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: For loop iterator variable not working correctly??
Message-Id: <MPG.15ec6388741b86e7989785@news.edmonton.telusplanet.net>

Hi everyone,

In the following code the variable $i does not seem to increment at all 
when the code uses a for loop.  When I change the code to being inside a 
while loop like so...

$i = 0;
while (@$new[$i]) {
  ...
  $i++;
}

the iterator variable, $i, is incremented just fine.  Why is it that when 
inside the corresponding for loop it is not?  

The code:

#!/usr/bin/perl -W

use diagnostics;
use strict;

my %g_hash = (
  "jack\@ardvark.com" => "Jack,020010812 18:34,Canada,Kissimee,Yes",
  "tammy\@kangaroo.com" => "Tammy,20010812 18:34,United 
States,Chicago,Yes",);
my ($key, @new);

$key = "tammy\@kangaroo.com";
@new = qw/harry\@tiger.net undef undef Russia undef undef/;
print "\@new = @new\n";
update_record($key, \@new);
foreach my $string (%g_hash) {
  print $string."\n";
}

sub update_record
{
  my ($old_key, $new) = @_;
  my (@old, $i); 
  print "\@\$new[0] = @$new[0]\n";
  print "\@\$new[1] = @$new[1]\n";
  print "\@\$new[2] = @$new[2]\n";
  print "\@\$new[3] = @$new[3]\n";
  print "\@\$new[4] = @$new[4]\n";
  print "\@\$new[5] = @$new[5]\n";
  if ($g_hash{$old_key}) { 
    @old = ($old_key, split(/,/,$g_hash{$old_key}));
    print "\@old = @old\n";
	for ($i = 0, @$new[$i], $i++) {
	  if (@$new[$i]) {
           print "\$i = $i\n";
           print "\$old[$i] = $old[$i]\n\@\$new[$i] = @$new[$i]\n";
	    $old[$i] = @$new[$i];
         }		
       }
    delete $g_hash{$old_key};
    print "@old\n";
    $g_hash{$old[0]} = join(",",$old[1..$#old]);
  }	
}  
  
As always critique or suggestions as to how to write the code better 
would be most welcomed.  Thanks.

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so please don't 
subscribe.  Thanks.


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

Date: 21 Aug 2001 20:10:30 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: For loop iterator variable not working correctly??
Message-Id: <9luf7m$2l0$1@bob.news.rcn.net>

Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:
> Hi everyone,

> In the following code the variable $i does not seem to increment at all 

[snip]
> #!/usr/bin/perl -W

> use diagnostics;
> use strict;

> my %g_hash = (
>   "jack\@ardvark.com" => "Jack,020010812 18:34,Canada,Kissimee,Yes",
>   "tammy\@kangaroo.com" => "Tammy,20010812 18:34,United 
> States,Chicago,Yes",);
> my ($key, @new);

> $key = "tammy\@kangaroo.com";
> @new = qw/harry\@tiger.net undef undef Russia undef undef/;

I hope you realize that the second, third, fifth, and sixth elements of 
@new are going to be set to the literal string "undef," not Perl's 
undefined value.


> print "\@new = @new\n";
> update_record($key, \@new);
> foreach my $string (%g_hash) {
>   print $string."\n";
> }

This will print key, value, ..., key, value in no particular order. 

> sub update_record
> {
>   my ($old_key, $new) = @_;
>   my (@old, $i); 
>   print "\@\$new[0] = @$new[0]\n";

You want $$new here, not @$new.  I'd actually write it as $new->[0], but 
that's a matter of personal preference.

This can be made easier to type and read if you remember that print takes 
multiple arguments:

    print '$$new[0] = ', "$$new[0]\n";

>   print "\@\$new[1] = @$new[1]\n";
>   print "\@\$new[2] = @$new[2]\n";
>   print "\@\$new[3] = @$new[3]\n";
>   print "\@\$new[4] = @$new[4]\n";
>   print "\@\$new[5] = @$new[5]\n";
>   if ($g_hash{$old_key}) { 
>     @old = ($old_key, split(/,/,$g_hash{$old_key}));
>     print "\@old = @old\n";
> 	for ($i = 0, @$new[$i], $i++) {

In a C-style (indexed) for loop, the loop expressions are separated by 
semicolons, not commas.  What you've unintentionally set up is a 
foreach-type loop over a three-element list (0, whatever is in $new->[0], 
and 0 again).

> 	  if (@$new[$i]) {
>            print "\$i = $i\n";
>            print "\$old[$i] = $old[$i]\n\@\$new[$i] = @$new[$i]\n";
> 	    $old[$i] = @$new[$i];
>          }		
>        }
>     delete $g_hash{$old_key};
>     print "@old\n";
>     $g_hash{$old[0]} = join(",",$old[1..$#old]);
>   }	
> }  


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

Date: 21 Aug 2001 20:14:39 GMT
From: abigail@foad.org (Abigail)
Subject: Re: For loop iterator variable not working correctly??
Message-Id: <slrn9o5g9s.6m2.abigail@alexandra.xs4all.nl>

Carlos C. Gonzalez (miscellaneousemail@yahoo.com) wrote on MMCMXII
September MCMXCIII in <URL:news:MPG.15ec6388741b86e7989785@news.edmonton.telusplanet.net>:
,,
,, 	for ($i = 0, @$new[$i], $i++) {


This loops over 3 elements: $i, @$new[$i] and $i, with $i being 1
at the first and second iteration, and $i being 0 at the end.

Perhaps you want to use:

        for ($i = 0; @$new[$i]; $i ++) { }



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, 21 Aug 2001 20:48:12 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: For loop iterator variable not working correctly??
Message-Id: <MPG.15ec76c69d21e3df989786@news.edmonton.telusplanet.net>

Eric Bohlman at ebohlman@omsdev.com said...

> > @new = qw/harry\@tiger.net undef undef Russia undef undef/;
> 
> I hope you realize that the second, third, fifth, and sixth elements of 
> @new are going to be set to the literal string "undef," not Perl's 
> undefined value.

Thanks Eric.  I didn't realize that.  Very glad you pointed that out to 
me.  I will have to study up on using Perl's undefined value which is 
what I meant to use.  

> > sub update_record
> > {
> >   my ($old_key, $new) = @_;
> >   my (@old, $i); 
> >   print "\@\$new[0] = @$new[0]\n";
> 
> You want $$new here, not @$new.  I'd actually write it as $new->[0], but 
> that's a matter of personal preference.

@$new seems to work fine Eric.  I read somewhere that whenever you have a 
reference to something, to dereference it (or pull it's value out) you 
just put the symbol for the type of variable that is being referenced in 
front of the "$".  So far this seems to work for me and makes my perlisms 
a bit more consistent.  I think I will switch my code to using the arrow 
though.  That definitely seems to be the clearest way to do it.

> This can be made easier to type and read if you remember that print takes 
> multiple arguments:

Thanks Eric.  Good point.

> In a C-style (indexed) for loop, the loop expressions are separated by 
> semicolons, not commas.  What you've unintentionally set up is a 
> foreach-type loop over a three-element list (0, whatever is in $new->[0], 
> and 0 again).

Talk about missing the forest for the trees.  I was so focused on the 
operations in my for loop that I completely missed the need for ";"'s.  I 
kept staring and staring and staring at my for loop and couldn't see 
anything wrong with it.  I even looked through documentation on the for 
loop and the ";"'s were right there in front of me.  But it was like 
they were invisible.  Sorry about that.

Thanks again Eric (you too Abigail).

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so please don't 
subscribe.  Thanks.


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

Date: Tue, 21 Aug 2001 16:51:36 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: For loop iterator variable not working correctly??
Message-Id: <slrn9o5ieo.vpf.tadmc@tadmc26.august.net>

Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:
>
>In the following code the variable $i does not seem to increment at all 
>when the code uses a for loop. 

[snip]

>my %g_hash = (
>  "jack\@ardvark.com" => "Jack,020010812 18:34,Canada,Kissimee,Yes",
>  "tammy\@kangaroo.com" => "Tammy,20010812 18:34,United 
>States,Chicago,Yes",);
>my ($key, @new);
>
>$key = "tammy\@kangaroo.com";


You should use single quotes unless you _need_ one of the two
extra things that double quotes give you. Would have saved a
bunch of backslashing, which you then have to mentally filter
out when reading your own code.


>@new = qw/harry\@tiger.net undef undef Russia undef undef/;
                ^

Why do you want a backslash in the first string?

If you need some sort of flag value, I suggest you use some
string other than "undef". Too easy to confuse with Perl's undef.

If you want real undefs, then you cannot use qw//:

   my @new = ( 'harry@tiger.net', undef, undef, 'Russia', undef, undef);


>print "\@new = @new\n";
>update_record($key, \@new);
>foreach my $string (%g_hash) {
>  print $string."\n";


   print "$string\n";  # interpolation is easier to read than concatenation


You are printing alternating keys and values, one per line.

Don't you want to visualize the associations?

   foreach my $string ( keys %g_hash) {
     print "$string => $g_hash{$string}\n";
   }


>sub update_record
>{
>  my ($old_key, $new) = @_;
>  my (@old, $i); 
>  print "\@\$new[0] = @$new[0]\n";
>  print "\@\$new[1] = @$new[1]\n";
>  print "\@\$new[2] = @$new[2]\n";
>  print "\@\$new[3] = @$new[3]\n";
>  print "\@\$new[4] = @$new[4]\n";
>  print "\@\$new[5] = @$new[5]\n";


Doesn't that look awfully repetitive?

   print map { "\@\$new[$_] = @$new[$_]\n" } 0..$#new;

Now it works unchanged when you add a 7th field.


>  if ($g_hash{$old_key}) { 


That will be false if you ever happen to have a '0' key:

   if ( exists $g_hash{$old_key}) {


>	for ($i = 0, @$new[$i], $i++) {
                   ^          ^
                   ^          ^

That is not the syntax for a "for loop":

   for ($i = 0; @$new[$i]; $i++) {


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 21 Aug 2001 18:27:01 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Help w/grep
Message-Id: <998418421.259762815665454.gnarinn@hotmail.com>

In article <3B7AA3DC.4D001409@cca-int.com>, jlm  <jlm@cca-int.com> wrote:
>I wrote a search engine in perl/cgi for our web site that searches for
>files containing user supplied text string.
>@farr = `find $dir -type f -exec grep -il $text {} \\;`;


i usually just pipe the output to another grep process:

  grep foo pod/*.pod | grep bar


>I then proces the array constructing url's as I go & write out new web
>page. Works great.
>Now management wants the ability to optionally specify two strings and
>return results only if both strings appear in a file.
>I can't seem to figure out how to manipulate grep to do that.
>Can someone solve this problem?
>Or maybe the perl grep function can do the job better?

should work like a charm also.

gnari


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

Date: Tue, 21 Aug 2001 19:06:05 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: HTTP::Request::Common file upload
Message-Id: <998420765.0150068118236959.gnarinn@hotmail.com>

In article <998399257.275886@newsreader2.wirehub.nl>,
Peter du Marchie <pdumarchie@goldenbytes.com> wrote:

>
>According to the documentation for HTTP::Request::Common, I have to "[u]se
>an undef as $file value if [I] want to specify the content directly." But
>what does that mean? How do I provide the contents if $file has to be
>undefined?

i do not know, but the documentation also says:
    A header key called 'Content' is special and when seen the value will
    initialize the content part of the request instead of setting a header.

did you try that?

gnari



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

Date: Tue, 21 Aug 2001 16:22:48 -0400
From: Pascal Jolin <pascal.jolin@videotron.ca>
Subject: Re: Is element in array
Message-Id: <3B82C318.9D4EFD06@videotron.ca>

Happy GREP!!!

my @bla=("one","two","three");

if ( grep {/two/}@bla){ 
  print "true";
} else {
  print "False";
}

Pascal Jolin

Guy wrote:
> 
> How can test a scalar to see if it is an element in a given array?
> Example:
> @bla=("one","two","three");
> 
> if ("two" IS IN @bla) #returns true
> {
>     #this code would be executed
> ....
> }
> 
> if ("four" IS IN @bla)#returns false
> {
>     #this code would not be executed
> }
> 
> TIA,
> Guy


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

Date: Tue, 21 Aug 2001 16:23:21 -0400
From: Pascal Jolin <pascal.jolin@videotron.ca>
Subject: Re: Is element in array
Message-Id: <3B82C339.36B806EF@videotron.ca>

Happy GREP!!!

my @bla=("one","two","three");

if ( grep {/two/}@bla){ 
  print "true";
} else {
  print "False";
}

Pascal Jolin

Guy wrote:
> 
> How can test a scalar to see if it is an element in a given array?
> Example:
> @bla=("one","two","three");
> 
> if ("two" IS IN @bla) #returns true
> {
>     #this code would be executed
> ....
> }
> 
> if ("four" IS IN @bla)#returns false
> {
>     #this code would not be executed
> }
> 
> TIA,
> Guy


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

Date: Tue, 21 Aug 2001 22:27:47 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Is element in array
Message-Id: <3B82C443.4050700@post.rwth-aachen.de>

Pascal Jolin wrote:
> Happy GREP!!!
> 
> my @bla=("one","two","three");
> 
> if ( grep {/two/}@bla){ 
>   print "true";
> } else {
>   print "False";
> }

I think it is a bad habit to check a contain with grep. Imagine you have 
an array of 10.000 elements and the first element already contains the 
value. Then you still "Happy[ly] GREP!!!" through another 9.999 elements.

grep may be nice for a quick hack, in case the array isn't too large or 
you're just too lazy to do a for-loop. Or in the rare case you use it in 
the way it was supposed to be used. ;-)


Tassilo
-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Tue, 21 Aug 2001 20:55:15 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: Is element in array
Message-Id: <slrn9o5jak.m92.tim@vegeta.ath.cx>

Me parece que Pascal Jolin <pascal.jolin@videotron.ca> dijo:
> Guy wrote:
> > How can test a scalar to see if it is an element in a given array?
> > Example:
> > @bla=("one","two","three");
> > 
> > if ("two" IS IN @bla) #returns true
> > {
> >     #this code would be executed
> > ....
> > }
> > 
> > if ("four" IS IN @bla)#returns false
> > {
> >     #this code would not be executed
> > }
> Happy GREP!!!
> 
> my @bla=("one","two","three");
> 
> if ( grep {/two/}@bla){ 
>   print "true";
> } else {
>   print "False";
> }

Note that this would also print 'true' for words such as:

    # words containing 'one'
    erroneous
    Londoner
    Antigone
    Persephone
    Stonehenge
    boner
    # words containing 'two'
    network
    flatworm
    breastwork

Anchors are a good thing. =)

OTOH, why use regex's when all you want is simple equality?

-- 
You're quite free to convert your strings to byte arrays and do the
entire pattern tree by hand in pure logic code if you'd like. By the
time you finish most of the rest of us will be doing contract work on
Mars.
    -- Zenin, comp.lang.perl.misc


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

Date: Tue, 21 Aug 2001 22:04:16 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Last index of array referenced in a scalar??
Message-Id: <MPG.15ec7f5478d2cd5989787@news.edmonton.telusplanet.net>

Hi everyone,

Is this the right way to obtain the last index of the @data array 
referenced by $new?  Seems to work okay....

The code:

#!/usr/bin/perl -W

use diagnostics;
use strict;

my @data = ("jack\@ardvark.com,Jack,020010812 18:34,Canada,Kissimee,Yes",
  "tammy\@kangaroo.com,Tammy,20010812 18:34,United States,Chicago,Yes",);

my $new = \@data;

print "Last element index: [ $#$new ]\n";

Is there a way to rewrite [ $#$new ] so that it doesn't look like so much 
gibberish?  Also although this code is producing the right output is it 
doing what I want it to do or is the 1 index produced a byproduct of 
something else?  

I just spent fifteen minutes trying different combinations of squiggly 
things =:) until I found one that worked. Can someone correct or check my 
understanding of what I did?  

I think "[ $#$new ]" means something like.....

Return the last element "$#" of the array referenced by $new.  

If the "[]" were not there it would mean...return the last element "$#" 
of the reference value.  Which would just produce an error or invalid 
index value.  

Thanks.

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so please don't 
subscribe.  Thanks.


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 1580
***************************************


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