[9609] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3203 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 20 11:17:29 1998

Date: Mon, 20 Jul 98 08:00:36 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 20 Jul 1998     Volume: 8 Number: 3203

Today's topics:
    Re: (Semi-)Repeatable SDBM problem in v5.004_04 and Sun <jdporter@min.net>
    Re: /^[a-z0-9]/ <jdf@pobox.com>
    Re: A simple question about sub routines <chris.wareham@blackwell.co.uk>
    Re: A simple question about sub routines (Larry Rosler)
    Re: a simple search algorithm <quednauf@nortel.co.uk>
    Re: Annoying warning : Variable %s will not stay shared (Greg Bacon)
    Re: compare arrays (Larry Rosler)
    Re: efficiency: print<<"xxx" vs. print (Stefaan A Eeckels)
        Grepping/Comparing two-dimentional arrays? (Brian Reilly)
    Re: Grepping/Comparing two-dimentional arrays? <quednauf@nortel.co.uk>
    Re: Grepping/Comparing two-dimentional arrays? <quednauf@nortel.co.uk>
    Re: HELP - MS personal web server and cgi <dtbaker_@flash.net>
    Re: Help!!: using foreach in 2 Dimension Hash... <quednauf@nortel.co.uk>
    Re: Help!!: using foreach in 2 Dimension Hash... <ged@fortec.tuwien.ac.at>
        How to define a structure in PERL? <cmeena@hotmail.com>
    Re: How to define a structure in PERL? (Juergen Heinzl)
    Re: How to define a structure in PERL? (Chris Hamilton)
    Re: How to define a structure in PERL? <jdf@pobox.com>
    Re: I'm baffled.. (and an amateur:) <jdporter@min.net>
    Re: join and warnings on undef values <uri@sysarch.com>
    Re: open (IN, "foo.txt") works, open (IN, "$foo") does  <jdf@pobox.com>
    Re: Perl Beautifier Home Page <uri@sysarch.com>
    Re: Perl Beautifier Home Page <uri@sysarch.com>
    Re: Perl Beautifier Home Page <jdporter@min.net>
    Re: Perl Beautifier Home Page <jdporter@min.net>
    Re: Perl Beautifier Home Page (Snowhare)
    Re: Perl commands in NT Q's:  (was Re: Win32 install pr <markstang@ncgroup.com>
    Re: Reading in an email message into a Perl program (Sitaram Chamarty)
    Re: Recommend me Perl! (John Klassa)
    Re: Regex: operand could be empty (Larry Rosler)
    Re: search string <jdf@pobox.com>
        sort function (CGI-Perl) <431854@cienz.unizar.es>
    Re: sort function (CGI-Perl) <quednauf@nortel.co.uk>
    Re: system() return values <gcoulomb@gpu.srv.ualberta.ca>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Mon, 20 Jul 1998 14:35:45 GMT
From: John Porter <jdporter@min.net>
Subject: Re: (Semi-)Repeatable SDBM problem in v5.004_04 and SunOS 5.5.1
Message-Id: <35B35743.156C@min.net>

Scott Maxwell wrote:
> 
> I'm getting a semi-repeatable error (happens almost always, but not
> always) using SDBM_File with Perl 5.004_04 and SunOS 5.5.1.
>[...]

Looks o.k. to me, and running it on my machine (SunOS 2.4) had
no problems.


> sub CountKeys {
>     return scalar(@{ [ keys %Db ] });
> }

That's horrible.  It returns a list of all the keys, then gets
the length of that array.  

Since the number of keys is stored in the hash structure, you 
can do this to retrieve it directly:

sub CountKeys {
	scalar keys %Db;
}


-- 
John Porter


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

Date: 20 Jul 1998 09:58:12 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: abigail@fnx.com
Subject: Re: /^[a-z0-9]/
Message-Id: <hg0cwovv.fsf@mailhost.panix.com>

abigail@fnx.com (Abigail) writes:

> Jonathan Feinberg (jdf@pobox.com) wrote on MDCCLXXXIII September MCMXCIII
> in <URL: news:7m19er3d.fsf@mailhost.panix.com>:
> ++ abigail@fnx.com (Abigail) writes:
> ++ 
> ++ >    /[^a-z0-9]/
> ++ > 
> ++ > But that disallowes A-Z and accented letters as well. Perhaps
> ++ > you want /\W/.
> ++ 
> ++ Huh?
> ++ 
> ++    print join "\n", grep /^[^a-z0-9]/, qw(apple Brown betty Delight);
> ++ 
> ++ Does that not print "Brown\nDelight" on your box?
> 
> Yes. And
> 
>      print join "\n", grep /^[^a-z0-9]/, qw /a::: b;;; s[][]/
> 
> prints
> 
>      a:::
>      b;;;
>      s[][]

Not in perl 5.004_04.  What version are you using?

> Your point being?

That you seemed to be saying that the regex [^a-z0-9] "disallows A-Z",
whereas my program demonstrated otherwise.  I was hoping that I'd
misunderstood you.  What's going on here?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: Mon, 20 Jul 1998 13:09:47 GMT
From: Chris Wareham <chris.wareham@blackwell.co.uk>
Subject: Re: A simple question about sub routines
Message-Id: <35B34235.C0DB3850@blackwell.co.uk>

Tom Christiansen wrote:
> 
> In comp.lang.perl.misc, Chris Wareham <chris.wareham@blackwell.co.uk> writes:
> :The interpreter parses and compiles all the code in your program prior to
> :running it.
> 
> Why do people keep saying this?  Don't you know a compiler
> from an interpeter?  Sheesh. :-(
> 

The fact that Perl is a `scripting' langauge still implies ``interpreted'' to
the more primitive part of my brain. Oh well, I'll evolve someday.

Chris
-- 
chris.wareham@blackwell.co.uk
+44 (0)1865 792792 ext. 3381
http://www.killingmiranda.pair.com/


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

Date: Mon, 20 Jul 1998 07:46:44 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: A simple question about sub routines
Message-Id: <MPG.101cf82d94f03c5498976b@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <35B34235.C0DB3850@blackwell.co.uk> on Mon, 20 Jul 1998 
13:09:47 GMT, Chris Wareham <chris.wareham@blackwell.co.uk> says...
> Tom Christiansen wrote:
> > 
> > In comp.lang.perl.misc, Chris Wareham <chris.wareham@blackwell.co.uk> writes:
> > :The interpreter parses and compiles all the code in your program prior to
> > :running it.
> > 
> > Why do people keep saying this?  Don't you know a compiler
> > from an interpeter?  Sheesh. :-(
> > 
> 
> The fact that Perl is a `scripting' langauge still implies ``interpreted'' to
> the more primitive part of my brain. Oh well, I'll evolve someday.

Perl is a 'programming' language.  'script' is to 'program' as 'square' 
is to 'rectangle' (or whatever; it's been a long time since my SATs).

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 20 Jul 1998 14:15:13 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: a simple search algorithm
Message-Id: <35B342E1.B791A597@nortel.co.uk>

Sascha Kerschhofer wrote:
> 
> sub search {
>   local($lien, $name, $found);
>   $name = "any_string";
>   $found = 0;
>   open(FILE, "orte2.txt");
>   while (($found == 0) && ($line = <FILE>)) {
>     chop($line);
>     if ($name eq $line) {
>      $found = 1;
>      print $name." was found\n";
>      } else {
>      print $name." was not found but ".$line."\n";
>      }
>   }
>   close(FILE);
> }
> 
I can't reproduce anys mistake you might be finding, so it could be
because you're using an older version of Perl. I have also been trying a
simplified version of your script, maybe you'll have more luck with that
:)

$name = "any_string";
open FILE, "orte2.txt" or die "Nothing there to work on : $!";
LOOP: while (<FILE>) {
        chomp;
        if ($name eq $_) {
          print "$name was found\n";
          last LOOP;
        } 
        print "$name was not found but *$_*\n";
      }
close(FILE);


-- 
____________________________________________________________
Frank Quednau               
http://www.surrey.ac.uk/~me51fq
________________________________________________


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

Date: 20 Jul 1998 14:55:54 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Annoying warning : Variable %s will not stay shared ...
Message-Id: <6ovlpq$lq4$5@info.uah.edu>

In article <6opfoh$r6o@fohnix.metronet.com>,
	tye@fohnix.metronet.com (Tye McQueen) writes:
:     { my( $user, $passwd );
: 	sub checkUrl {
: 	    my $url;
: 		($url, $user, $passwd) = @_;
: 		    sub get_basic_credentials {
: 			    return($user, $passwd); # line 118
: 		    }
: 	}
:     }

I believe the point of Chris's get_basic_credentials() is that he
wanted to return the same values that were passed to checkUrl().  This
is what closures are all about.  Your version doesn't have that feature.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Mon, 20 Jul 1998 07:25:34 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: compare arrays
Message-Id: <MPG.101cf33d5b9c6a20989769@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <1dcgl3r.1phnkhx1dygi6aN@ppp82.vo.lu> on Mon, 20 Jul 1998 
09:57:51 +0000, Dominic Dunlop <domo@tcp.ip.lu> says...
> Stale thread, but WTH, I'll jump in anyway...

You should have read more of the thread!  See the DejaNews ref below.

> Craig Berry <cberry@cinenet.net> wrote in respose to a question from
> Alberto Brosich <brosich@univ.trieste.it>:
> > 
> > : How can i compare two arrays other then with a loop?
> > 
> > Short answer: You can't do it without looping.
> 
> Umm, yes you can.  For a straight equality check of two arrays, @x and
> @y, 
> 
>         "@x" eq "@y"

That contains two loops, in "join(' ', ...)".  They're 'under the rug' 
(to quote from the stale thread).

> works fine -- provided that you consider the two arrays to be equal if
> their joined stringified values are equal.

@x = ('a b', 'c');
@y = ('a', 'b c');

<SNIP>

See the following for a correct use of this approach, with benchmark 
data.  (Fold the URL back together first, of course.)

http://x1.dejanews.com/getdoc.xp?AN=371486527&CONTEXT=900943372.203718665
9&hitnum=0

There is more discussion in followups to that subthread.

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 20 Jul 1998 13:09:04 GMT
From: Stefaan.Eeckels@ecc.lu (Stefaan A Eeckels)
Subject: Re: efficiency: print<<"xxx" vs. print
Message-Id: <6ovfhg$ffh$2@justus.ecc.lu>

In article <FGKr1.144471$on1.7747285@news2.voicenet.com>,
	hex@voicenet.com (Matt Knecht) writes:
> Tom Christiansen <tchrist@mox.perl.com> wrote:
>>Why is it that so few programmers ever figure this out?  Even the
>>millionth time you see an "add one to i" comment, it doesn't help.
>>
>>--tom
>>
>>    Basically, avoid comments. If your code needs a comment to be
>>    understood, it would be better to rewrite it so it's easier to
>>    understand.  --Rob Pike
> 
> In my experience, it's been that few programmers ever comment, not the
> inverse.
> 
> I don't comment for the code I'm writing, I comment for the logic I'm
> using.  Even if nobody ever sees it except me, it can be a useful map to
> follow a program by.  This is especially true when you get deeply
> nested, and are dealing with many variables or states.
> 
> They are also useful to explain why a particular contstruct was chosen.  I
> often quantify something with:
> 
> # X would be a good deal faster if it was Y, but not nearly as
> # bullet-proof.
> 
> All this and the fact that my employers love comments works for me
> (Although, I think we can all safely say: '$i++; # increment $i' is a
> pointless waste of time).
The worst program I ever encountered was in assembler. It 
had a comment for each and every line of code:

	inc	A	; increment A
	jnz	foo	; goto foo if A non zero

etc, etc.
The program was in excess of 20,000 lines of code, IIRC, and each
line had a similar comment. If there was one comment discussing
what the program did, I must have overlooked it. 

The worst was that the author scolded me for the lack of comments
in my own program. No, the worst was that when my program worked
3 months later no-one said anything, and when his finally worked
a year later, he got a bonus from the company. 

The company has gone bust since.

-- 
Stefaan
-- 

PGP key available from PGP key servers (http://www.pgp.net/pgpnet/)
___________________________________________________________________
Perfection is reached, not when there is no longer anything to add,
but when there is no longer anything to take away. -- Saint-Exupery



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

Date: 20 Jul 98 13:24:16 GMT
From: reillyb@gusun.georgetown.edu (Brian Reilly)
Subject: Grepping/Comparing two-dimentional arrays?
Message-Id: <35b34500.0@bandit>

Hi all, I'm trying to compare an item [x,3] in two two-dimensional arrays,
to see if there are any intersections or new items.  
I've look at old usenet posts and a lot of the perl faqs and man pages,
but haven't found anything relevant.

Thanks in advance for any help.

Brian 
<reillyb@gusun.georgetown.edu>

###########################
$old = `cat data.old`;
$data = `cat data`;

@oldlist =  split (/\n/, $old);
@datalist = split (/\n/, $data);


foreach $oldie (@oldlist)
	{
	@tmp2  = split (/,/, $oldie);
	push @olduser, [ @tmp2 ];
	}

print ("\n");
foreach $datum (@datalist)
	{
	@tmp = split (/,/, $datum);
	push @user, [ @tmp ];
	}
	

###Will print all of the elements#####
#for $i ( 0 .. $#user )
#	{
#	$aref = $user[$i];
#	$n = @$aref - 1;
#	for $j ( 0 .. $n)
#		{
#		print "elt $i $j is $user[$i][$j]\n";
#	}
#	}


#Here's where I have trouble--I know I can compare one-dimensional
#arrays like this, but I can't figure out how to do it with two-
#dimentional arrays.  
for $bref (@olduser, @user) {$count{$bref}++ }
for $bref (keys %count) {
	push @union, $bref;
	push @{ $count{$element} > 1 ? \@intersection : \@difference }, $bref;
}


print ("Intersection: @intersection\nDifference: @difference\n");

##############



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

Date: Mon, 20 Jul 1998 14:45:08 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Grepping/Comparing two-dimentional arrays?
Message-Id: <35B349E4.9F9D2754@nortel.co.uk>

Brian Reilly wrote:
> 
> Hi all, I'm trying to compare an item [x,3] in two two-dimensional arrays,
> to see if there are any intersections or new items.
> I've look at old usenet posts and a lot of the perl faqs and man pages,
> but haven't found anything relevant.
> 
> Thanks in advance for any help.
> 
> Brian
> <reillyb@gusun.georgetown.edu>
> 

Actually I am not quite sure what you want, but the following construct
should walk through all elements by dereferencing $bref, which is an
array reference, and do the same stuff with %count. I don't really have
the data to test it, but it parses without any errors :)

foreach $oldie (@{[split (/\n/, $old)]}) {
   push @olduser, [ split (/,/, $oldie) ];
}

foreach $datum (@{[split (/\n/, $data)]}) {
   push @user, [ split (/,/, $datum) ];
}
        
for $bref (@olduser, @user) {
  for $elem (@{$bref}) { $count{$elem}++ }
}

for $bref (keys %count) {
        push @union, $bref;
        push @{ $count{$element} > 1 ? \@intersection : \@difference },
$bref;
}


print "Intersection: @intersection\nDifference: @difference\n";


-- 
____________________________________________________________
Frank Quednau               
http://www.surrey.ac.uk/~me51fq
________________________________________________


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

Date: Mon, 20 Jul 1998 14:49:50 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Grepping/Comparing two-dimentional arrays?
Message-Id: <35B34AFE.CD382D77@nortel.co.uk>

F.Quednau wrote:
> 
> for $bref (keys %count) {
>         push @union, $bref;
>         push @{ $count{$element} > 1 ? \@intersection : \@difference },
> $bref;
> }

*sigh*, never copy code without looking at it.

for $elem (keys %count) {
   push @union, $elem;
   push @{ $count{$elem} > 1 ? \@intersection : \@difference }, $bref;
}

-- 
____________________________________________________________
Frank Quednau               
http://www.surrey.ac.uk/~me51fq
________________________________________________


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

Date: Mon, 20 Jul 1998 08:44:03 -0500
From: Dan Baker <dtbaker_@flash.net>
Subject: Re: HELP - MS personal web server and cgi
Message-Id: <35B349A3.B3C@flash.net>

Dale Sutcliffe wrote:
> 
> How do I configure personal web server to accept cgi scripts?
-----------
This isn't really a perl issue.... for cgi type questions, you might
want to check out news:comp.infosystems.www.authoring.cgi


but try the xitami server instead, it is small, fast, and works right
out of the box. http://www.imatix.com/ 
-- 
Thanx, Dan

# If you would like to reply-to directly, remove the _ from my username
* Use of my email address regulated by US Code Title 47,
Sec.227(a)(2)(B)  *


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

Date: Mon, 20 Jul 1998 13:52:27 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Help!!: using foreach in 2 Dimension Hash...
Message-Id: <35B33D8B.45E5EAFD@nortel.co.uk>

yroh wrote:
> 
> See below code...
> 
> foreach $i (keys %B) {
>         foreach $j (keys %B{"$i"} ) {
>         .....
>         }
> }
> 
> It has syntax error...

$B{"QQQ"}{"QE"} = 11.23;
$B{"QQQ"}{"QR"} = 33.33;
$B{"AAA"}{"AW"} = 23.1;
$B{"AAA"}{"AE"} = 23.2;
$B{"AAA"}{"AR"} = 23.3;

foreach $i (keys %B) {
  foreach $j (keys %{$B{$i}} ) {
    print "$i: $j=$B{$i}{$j}\n";
  }
}

What is happening? Your code tries to look up a hash in the foreach $j
loop. There isn't a hash, but a reference to a hash, though. And, as
always, if you want to see the value of a reference, DEREFERENCE. So
$B{$i} is dereferenced, and now $j will hold the keys of the
dereferenced hash reference.
However, you should definitely check the perldsc documentation, which
explains all about hashes of hashes of arrays of hashes.

-- 
____________________________________________________________
Frank Quednau               
http://www.surrey.ac.uk/~me51fq
________________________________________________


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

Date: Mon, 20 Jul 1998 15:14:38 +0200
From: Georg Edelmayer <ged@fortec.tuwien.ac.at>
Subject: Re: Help!!: using foreach in 2 Dimension Hash...
Message-Id: <35B342BE.5AFA6F39@fortec.tuwien.ac.at>

yroh wrote:
> 
> See below code...
> 
> $B{"QQQ"}{"QE"} = 11.23;
> $B{"QQQ"}{"QR"} = 33.33;
> $B{"AAA"}{"AW"} = 23.1;
> $B{"AAA"}{"AE"} = 23.2;
> $B{"AAA"}{"AR"} = 23.3;
> 
> foreach $i (keys %B) {
>         foreach $j (keys %B{"$i"} ) {
>         .....
>         }
> }
> 
> It has syntax error...
> How do I look up values from 2 dim hash???
> Please Help me!!!!

Perl core documentation
perldsc (Perl Data Structures Cookbook )
 - Access and Printing of a HASH OF HASHES 

i know that you thought of getting some more detailed answer, but you really
should read the proper documentation first. If you still don't understand there
sure will be specific help, but the whole Hash of Hash thingie and complex list
stuff is explained quite fine in the doc's

> Thanks.
You're Welcome

Georg


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

Date: Mon, 20 Jul 1998 08:28:14 -0500
From: Meena Chockalingam <cmeena@hotmail.com>
Subject: How to define a structure in PERL?
Message-Id: <35B345EE.31DE9469@hotmail.com>

Hi All,

I have the following structure defined in C.

typedef struct
{
  int    i_name;
  char   slot0[20];
  char   slot1[20];
  ....   ......
  char   slot23[20];
 }iNameSlot;
;
iNameSlot   interface[80]

How can I do this in PERL?

Any help would be appreciated.

Thanks,
Meena Chockalingam


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

Date: 20 Jul 1998 13:42:03 GMT
From: juergen@lth330dn.sbs.de (Juergen Heinzl)
Subject: Re: How to define a structure in PERL?
Message-Id: <slrn6r6ifl.hnr.juergen@lth330dn.sbs.de>

In article <35B345EE.31DE9469@hotmail.com>, Meena Chockalingam wrote:
[...]
>I have the following structure defined in C.
>
>typedef struct
>{
>  int    i_name;
>  char   slot0[20];
>  char   slot1[20];
>  ....   ......
>  char   slot23[20];
> }iNameSlot;

you might take a look here ...
man Class::Struct
 ... 

Cheers,
Juergen

-- 
\ Real name	  : J|rgen Heinzl     \
 \ Email (office ) : idoinet@sbs.de    \
  \ Email (private) : unicorn@noris.de  \
   \ Phone (private) : +49 911-4501186   \


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

Date: Mon, 20 Jul 1998 13:49:21 GMT
From: chrish@squonk.net (Chris Hamilton)
Subject: Re: How to define a structure in PERL?
Message-Id: <900942542.960403@firth.squonk.net>

Meena Chockalingam (cmeena@hotmail.com) wrote:

: typedef struct
: {
:   int    i_name;
:   char   slot0[20];
:   char   slot1[20];
:   ....   ......
:   char   slot23[20];
:  }iNameSlot;
: ;
: iNameSlot   interface[80]
: 
: How can I do this in PERL?
: 
: Any help would be appreciated.
: 

Use Perl objects:

sub newiNameSlot
{
   my($self) = {};

   $self->{'i_name'} = shift;
   $self->{'slot0'} = shift;
   $self->{'slot1'} = shift;
   ...
   $self->{'slot23'} = shift;
 
   bless($self);
}

Then, you can do:

$iNameSlot = newiNameSlot('9', 'foo', 'foo2') .. basically, the arguments
will be used to populate the "structure". For more information on perl
objects, try: man perlobj  

---
Chris Hamilton                 C7 F9 1E FF 4F D8 F8 87  
chrish(at)squonk.net           F8 13 5F 69 63 B5 EB A8

"You're just jealous because the 'voices' talk to me."



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

Date: 20 Jul 1998 10:17:43 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: cmeena@hotmail.com
Subject: Re: How to define a structure in PERL?
Message-Id: <btqkwnzc.fsf@mailhost.panix.com>

Meena Chockalingam <cmeena@hotmail.com> writes:

> typedef struct

> How can I do this in PERL?

Exhaustive documentation on Perl data structures is supplied in the
following documents, which accompany every distribution of perl:

  perldata
  perllol
  perldsc
  perlfaq4

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: Mon, 20 Jul 1998 14:50:25 GMT
From: John Porter <jdporter@min.net>
Subject: Re: I'm baffled.. (and an amateur:)
Message-Id: <35B35AB4.90F@min.net>

Larry Rosler wrote:
> 
> print <<HERE;
> The sum of \$x and \$x is ${\($x + $x)}.
> The value of the list is {[qw(whatever creates the list)]}.
> HERE

Typo?  Should be
  The value of the list is @{[qw(whatever creates the list)]}.
???                        ^

-- 
John Porter


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

Date: 20 Jul 1998 09:28:31 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: join and warnings on undef values
Message-Id: <x7emvgmz28.fsf@sysarch.com>

>>>>> "RJK" == Ronald J Kimball <rjk@coos.dartmouth.edu> writes:

  RJK> Uri Guttman <uri@sysarch.com> wrote:
  >> i am using dbi/dbd and fetching rows of records, some of which have
  >> null fields. these are converted to undef by dbi/dbd. i then join
  >> them for printing to a file. if i have warnings enabled (which i do
  >> as a standard matter, tom c) i of course get warnings with the join
  >> of undef values. i currently disable warnings around that join with
  >> $^W=0. i don't want to do a
  >> 
  >> @row = map { defined( $_ ) ? $_ : '' ) @row ;

  RJK> Why not?  That's probably how I'd do it.  :-)

i am being lazy and don't want to burn any extra electrons :-)

  RJK> Assuming that $foo is undefined, then join('', 'abc', $foo,
  RJK> 'def') is pretty much equivalent to "abc${foo}def", and I would
  RJK> expect both of them to give a 'Use of unitialized value' warning
  RJK> - that's what the warning is for, after all.

but it is an array, not a set of scalar vars, so it is different in my
book. i would think that having undef's in an aray would be a more
conscious choice than just forgetting to initialize a scalar.

  RJK> Perhaps it's a bug in dbi/dbd that it returns undef instead of
  RJK> the null string for null fields...

not possible since you could have a char var with no text and that is
different than a null string in rdbms's. in my case in doesn't make much
difference (so far) but in other systems it could.


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: 20 Jul 1998 10:13:04 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Juergen.Puenter@materna.de (J|rgen P|nter)
Subject: Re: open (IN, "foo.txt") works, open (IN, "$foo") does not???
Message-Id: <emvgwo73.fsf@mailhost.panix.com>

Juergen.Puenter@materna.de (J|rgen P|nter) writes:

> #!/usr/local/bin/perl -w   # perl 5.001 BTW

Okay, well, you're not going to get very meaningful support when you
use a very old version of perl.

> if ($ENV{'REQUEST_METHOD'} eq "POST") {
>   read (STDIN, $ENV{'QUERY_STRING'}, $ENV{'CONTENT_LENGTH'});
> }

This is not a complete or correct means of using the CGI.  You ought
to use CGI.pm.

> $path3 = "/a/b/c/this_is_My.fIle.001.001";		# this works
> 
> # $path1 = "/a/b/c/";					# this does not work
> # $path2 = "this_is_My.fIle.001.001";
> # $path3 = $path1.$path2;

That's quite simply impossible.  There is no way on earth for any
entity to tell the difference between the first $path3 and the second.
They will look identical under the debugger, etc.  When I suggested
that you post a "brief, complete" program that demonstrates the
behavior you're experiencing, I meant just that.  You posted program
is neither brief nor complete.  Try this:

  $ echo 'Jane! Stop this crazy thing!' > foo

Then run this: 

  #!/usr/local/bin/perl -w
  my $path_a = './';
  my $path_b = 'foo';
  my $complete_path = $path_a . $path_b;
  open(F,"<$complete_path") or die "$!";
  print <F>;
  close F;

> # $path3 = "$path1.$path2";				# is what it should be

That shouldn't work, since you've added a literal dot character to the
filename.

> # chdir ($path1);	# puts me into/a/b/c

How do you know? You didn't check the success of the chdir() op.

> print STDERR "\n\n|$path3|\n\n";			# is $path3 correct and
> 							# without \n, \t...
> 							# Yes, every time.

Every time?  Even when you've put that dot in it?  Strange.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: 20 Jul 1998 09:53:27 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl Beautifier Home Page
Message-Id: <x7d8b0mxwo.fsf@sysarch.com>

>>>>> "RA" == Russ Allbery <rra@stanford.edu> writes:

  RA> Tom Christiansen <tchrist@mox.perl.com> writes:
  >> DB<1> print 1.1.1.1
  >> 1.11.1
  >> DB<2> print 1.1.1.1 + 0
  >> 1.11

  RA> That's... um... weird.

parse it as '1.1' . '1.1' which is 1.11.1 which converts to 1.11 as a
number. it is what perl should do with it.

maybe you need to create an overloaded object to handle incrementing and
managing multipart version numbers. it could do the comparisons and
other numeric related ops including magic autoincrement which can recognize
this form. but how do you designate when to carry over to the next
higher sub-version?

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: 20 Jul 1998 09:54:29 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl Beautifier Home Page
Message-Id: <x7btqkmxuy.fsf@sysarch.com>

>>>>> "RA" == Russ Allbery <rra@stanford.edu> writes:

  RA> Tom Christiansen <tchrist@mox.perl.com> writes:
  >> DB<1> print 1.1.1.1
  >> 1.11.1
  >> DB<2> print 1.1.1.1 + 0
  >> 1.11

  RA> That's... um... weird.

parse it as '1.1' . '1.1' which is 1.11.1 which converts to 1.11 as a
number. it is what perl should do with it.

maybe you need to create an overloaded object to handle incrementing and
managing multipart version numbers. it could do the comparisons and
other numeric related ops including magic autoincrement which can recognize
this form. but how do you designate when to carry over to the next
higher sub-version?

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: Mon, 20 Jul 1998 14:21:46 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl Beautifier Home Page
Message-Id: <35B353FD.5E6B@min.net>

Tim Maher wrote:
> 
> Andrew Ward wrote:
> > it turned
> > split(/;/);
> > into
> > ($_, $null) = split(/;
> > which is noticeably wrong.
> 
> If you had left out the () in the first place, and inserted a space after
> split,
> all would have been fine.  Why did you use parentheses?

Why not?  Do you seriously mean to disallow valid -- and quite 
common -- perl code?
Besides, how difficult could it have been to make the beautifier 
handle simple parens like these?

-- 
John Porter


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

Date: Mon, 20 Jul 1998 14:29:34 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl Beautifier Home Page
Message-Id: <35B355D1.16EC@min.net>

Bart Lateur wrote:
> 
> Only if you use a fixed pitch font. I don't.

I know you're hoping someone will bite, and ask what your 
rationale is. So I'll do the honors.

Care to justify the use of variable width fonts for coding?

-- 
John Porter


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

Date: 20 Jul 1998 14:52:47 GMT
From: snowhare@devilbunnies.org (Snowhare)
Subject: Re: Perl Beautifier Home Page
Message-Id: <6ovljv$5p5$1@supernews.com>



Nothing above this line is part of the signed message.

In article <m3g1g1upyn.fsf@windlord.Stanford.EDU>,
Russ Allbery  <rra@stanford.edu> wrote:
>
>Anything that's nested more than four levels needs rewriting.

Oh?

    while ($#parm_list > -1) {
        my ($start_dow)= shift @parm_list;
        my ($end_dow)  = shift @parm_list;
        my ($hour)     = shift @parm_list;
        $hour          = "0$hour" if (length($hour) < 2);
        my ($minute)   = shift @parm_list;
        $minute        = "0$minute" if (length($minute) < 2);
        for (my $year=$start_year;$year<=$stop_year;$year++) {
            for (my $month='01';$month<=12;$month++) {
                next if (($year == $start_year) && ($month < $start_month));
                next if (($year == $end_year) && ($month > $stop_month));
                my ($maxday) = (0,31,28,31,30,31,30,31,31,30,31,30,31)[$month];
                $maxday++ if ((($year % 4) == 0) && ($month == 2));
                for (my $day='01';$day<=$maxday;$day++) {
                    my ($date_string) = "$year$month$day$hour$minute";
                    next if (($date_string lt $starting_date) || ($date_string gt $ending_date));
                    $daycode->set_timecode($date_string);
                    my ($dow) = $daycode->day_of_week + 1;
                    next if (($dow < $start_dow) || ($dow > $end_dow));
                    push (@recurrences,$date_string);
                }
            }
        }
    }

That is five levels including the surrounding method I yanked it 
from.  Six if you count the 'if's in the innermost loop.
And yes - I *meant* to use 'gt' and 'lt' in this context rather
than '>' and '<' in the innermost loop.

>I've encountered *very, very* few exceptions to that principle that can be
>justified.  If you use a four-space indent, you should be able to handle
>four level nesting without continuation with very little difficulty.

Maybe. If you don't have any substantial logic conditions or
long variable/method names.

Benjamin Franz


Version: 2.6.2

iQCVAwUBNbNf8+jpikN3V52xAQEJpQQAlCAmgobmqZ5g71POFyESaJbityoaJufo
pLplr0yp7S/UBlMP5XB61YoROapYQWKXhr3SJBqO5Kf8bN6pRSH4HfcXfdYtikFi
y6TZNbsZUVpPdAnXGqnxNS+KlLcpmi+3rPli9AMsFpSjVWkfGmaIydW20Z6Pe6ey
tQ4ArKjtRC8=
=xDuG
-----END PGP SIGNATURE-----


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

Date: Mon, 20 Jul 1998 09:08:25 -0400
From: "Mark Stang" <markstang@ncgroup.com>
Subject: Re: Perl commands in NT Q's:  (was Re: Win32 install prob--another idiot)
Message-Id: <6ovfh2$n2$1@usenet1.interramp.com>


Neal Miyake wrote in message <01bdb36f$0498b3a0$680918cf@default>...
>3.  What about "pwd"?  Any NT command line equivalent?
>


try using cd without any parameters.  That will return the current directory
on the drive
to specify drive use:

cd x:

where x is your drive letter




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

Date: 20 Jul 1998 14:15:30 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: Reading in an email message into a Perl program
Message-Id: <slrn6r4cj3.2sd.sitaram@ltusitaram.diac.com>

On 18 Jul 1998 00:23:08 GMT, George H <george@tapestry.net> wrote:
>I am trying to write a program to parse email messages as they arrive and
>extract certain headers.  Right now, I am trying to write the simplest of
>programs to just test that I can even do anything with an e-mail message.

I normally don't go about recommedning non-Perl solutions on a
perl ng, but have you considered the procmail package?  It
includes a program called formail which does pretty much what you
describe.

Since you posted very simple code, I'm not sure if your final aim
is for something far more complex than procmail/formail can
handle.  But IMHO it's definitely worth a shot.


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

Date: 20 Jul 1998 14:25:39 GMT
From: klassa@aursgh.aur.alcatel.com (John Klassa)
Subject: Re: Recommend me Perl!
Message-Id: <6ovk13$9ln$1@aurwww.aur.alcatel.com>

On 14 Jul 1998 04:11:00 GMT, Tom Christiansen <tchrist@mox.perl.com> wrote:
  > Don't go there.  
  > 
  > Just
  > 
  > don't.

I'm thoroughly confused...  I wouldn't have given this a second thought
except for your strong reaction, Tom.  Stephen's name appears on the title
page -- should it not?

Genuinely confused and not trying to be a pain in the butt,
John

-- 
John Klassa / Alcatel Telecom / Raleigh, NC, USA <><


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

Date: Mon, 20 Jul 1998 07:40:19 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Regex: operand could be empty
Message-Id: <MPG.101cf6b18aba61cc98976a@nntp.hpl.hp.com>

In article <35b311ff.13629015@news2.nyct.net> on Mon, 20 Jul 1998 
09:47:52 GMT, dan@nospam.org <dan@nospam.org> says...
> Hi,
> 
> I'm string to read in a text file, and split it into paragraphs - i.e.
> text separated by one or more blank lines.
> 
> Here's a quick test program I wrote:
> 
> #!/usr/local/bin/perl
> 
> #
> # Test of splitting input file by one or more blank lines
> #
> 
> $i=0; @para=();
> undef $/;	# so files are read in as one string

If you use instead:

  local $/ = "\n\n";

each read of a 'line' from the file will yield a complete paragraph.

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 20 Jul 1998 09:51:20 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: darrensw@pacbell.net
Subject: Re: search string
Message-Id: <lnpowp7b.fsf@mailhost.panix.com>

darrensw@pacbell.net writes:

> How can I lock a search so that it only returns exact matches?
> 
> e.g. if I type car I would want the results to be for car and not
> carton

To learn how to use the text-matching features of Perl, you must read
some of the documents that accompany perl.  The most important is
called perlre.  You would do this:

   C:\> perldoc perl

   C:\> perldoc perlre

   C:\> perldoc perlfaq6


-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: Mon, 20 Jul 1998 12:38:43 +0200
From: miedo <431854@cienz.unizar.es>
Subject: sort function (CGI-Perl)
Message-Id: <35B31E33.5B04DDAA@cienz.unizar.es>

How i can use the sort function to introduce a series of strings by
alphabethical order in a file?
Thanks.




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

Date: Mon, 20 Jul 1998 15:38:21 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: sort function (CGI-Perl)
Message-Id: <35B3565D.92EAEF24@nortel.co.uk>

miedo wrote:
> 
> How i can use the sort function to introduce a series of strings by
> alphabethical order in a file?
> Thanks.

Are you AFRAID to try it out, miedo :) ?


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

Date: Mon, 20 Jul 1998 08:23:24 -0600
From: Greg Coulombe <gcoulomb@gpu.srv.ualberta.ca>
Subject: Re: system() return values
Message-Id: <35B352DC.D24CC4C3@gpu.srv.ualberta.ca>

Okay, perhaps I need to be more literal: I was looking for advice that
was NOT in the manpages because the procedure recommended in the manpage
gives me the same result whether the external program succeeded or
failed. I was wondering whether anyone had ever seen this kind of
behavior before and could recommend a course of action. In case it
matters to anyone, the scripts are running on an AIX/RS6000 as CGI
scripts.

Mishra Aditya wrote:
> 
> perdoc -f system
> 
> Adi

-- 
Greg Coulombe
Programmer, Orlando Project
Faculty of Arts
coulombe@cs.ualberta.ca

"It is easier to port a shell than a shell script."
			-- Larry Wall


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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