[9862] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3455 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 15 21:07:11 1998

Date: Sat, 15 Aug 98 18:00:22 -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           Sat, 15 Aug 1998     Volume: 8 Number: 3455

Today's topics:
    Re: Compile Perl Script <ccc@dataram-inc.com>
        eq and == difference <peter@richmd.demon.co.uk>
    Re: eq and == difference (Mike Stok)
    Re: File updating question (Mike Stok)
    Re: file upload problem <rick.delaney@shaw.wave.ca>
    Re: here's an implementation of diff in perl (Abigail)
    Re: here's an implementation of diff in perl (Abigail)
    Re: here's an implementation of diff in perl (Ilya Zakharevich)
    Re: here's an implementation of diff in perl (Mark-Jason Dominus)
    Re: how can I use databases in perl? (Larry Hunter)
    Re: How to read multiline variable? (Ken Williams)
        New, Improved Perl Beautifier! (Tim Maher)
        newbie question : format of first line <i_am_brick@hotmail.com>
    Re: NT redirect to file (Ken Irving)
        Outputting Images & Links in HTML <TOWER_DENE_EDU@email.msn.com>
    Re: pangrams in Perl --- randomized Robisonizing (Tomoyuki Tanaka)
    Re: Perl Beautifier Home Page (Tim Maher)
    Re: Q: How to read all the file name in a directory <grant.griffin@iowegian.com>
    Re: Q: How to read all the file name in a directory (I R A Aggie)
    Re: Q: How to read all the file name in a directory <ljz@asfast.com>
        Q: Missing first user (Ollie Cook)
    Re: Q: Missing first user (Larry Rosler)
    Re: Q: Missing first user <rick.delaney@shaw.wave.ca>
        Quickie encapsulation question nick@imationstudio.com
    Re: Randal-addnl help <rick.delaney@shaw.wave.ca>
        Strange behavior with 'use' <sysadmin@thegrid.net>
        URGENT! Perlscript + Asp - multiple database queries?? <mkruse@rens.com>
    Re: What about $/... was help parsing mail file <r_larsen@image.dk>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Sat, 15 Aug 1998 15:03:49 -0500
From: "Chris C. Curwood" <ccc@dataram-inc.com>
To: "news.space.ru" <gzhel@space.ru>
Subject: Re: Compile Perl Script
Message-Id: <35D5E9A5.9B1DEF5E@dataram-inc.com>

Perl Builder v1.0a  http://www.solutionsoft.com/perl.htm

news.space.ru wrote:

> What  can I do to compile perl script? What software I can use?
>
> Thank You, Yurin Andrew from Russia





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

Date: Sun, 16 Aug 1998 00:42:41 +0100
From: Peter Richmond <peter@richmd.demon.co.uk>
Subject: eq and == difference
Message-Id: <35D61CF1.B61DB8A4@richmd.demon.co.uk>

Hi,

Is there a difference between eq and == ?

Ive noticed that in some if statements eq works but == does not.

Could someone shine some light on this?
-- 
Peter Richmond.
--
Home : Sunderland, United Kingdom
Web  : www.richmd.demon.co.uk
Pager: 01426 281 367


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

Date: 15 Aug 1998 23:57:24 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: eq and == difference
Message-Id: <6r5794$6a1@news-central.tiac.net>

In article <35D61CF1.B61DB8A4@richmd.demon.co.uk>,
Peter Richmond  <peter@richmd.demon.co.uk> wrote:
>Hi,
>
>Is there a difference between eq and == ?
>
>Ive noticed that in some if statements eq works but == does not.
>
>Could someone shine some light on this?

== compares things as numbers, eq as strings.  As perl scalars aren't
typed they get treated according to context e.g.

  $x = '1' . '0';		# string 10
  $x *= 2;			# number 20
  $x .= ' lbs';			# string '20 lbs'

(that's quich, dirty & incomplete, but you get my drift - behind the
scenes perl caches string and number representations and other tricks...)

So when you're comparing values like '0123' and '123' you need to tell
perl how to compare them - sa strings they're different, but as numbers
they are the same (assuming the leading 0 isn't meant to tell you to
interpret the number as octal...)

Sometimes using == to compare floating point numbers seems to go wrong.
This is 'cos of the way computers usually represent floating point numbers
internally.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 15 Aug 1998 23:28:22 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: File updating question
Message-Id: <6r55im$553@news-central.tiac.net>

In article <35D4B076.3EE3@min.net>, John Porter  <jdporter@min.net> wrote:

>C *is* assembly language, with a sweeter syntax.

How bizarre.  My C went from x86 to 68k to T414 quite happily, but my x86
assembler didn't seem to work that well on a T414.

I think the parallels Tom draws are reasonable.

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Sat, 15 Aug 1998 21:33:57 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: file upload problem
Message-Id: <35D6003E.ADC64A15@shaw.wave.ca>

wings wrote:
> 
> well, here is my code.. true that "cant write xxx" is what i put there,
> not the system error. (actually i dont know how to debug cgi.. have to 
> do this awkwardly).

If you 'use CGI', debugging is a lot easier.  You can easily run your
script from the command line and better see what is going on.  Also check
out CGI::Carp which lets you direct error messages to your browser.  And
there is always the error log.  Ask your sysadmin where it is so you can
view it.

>         unless (open (FP,
> ">/home/course/cs2104/admin/assignment/test.dat")) {
>                 &fail("cant write xxx");
>                 exit;
>         }

You have probably seen the common idiom:

   open(FP, ">yourfile") || die "Can't open:  $!\n";

The $! gives you a more useful error message.  See perlvar.  You should try 
    fail("can't write xxx:  $!");

>         $file = param('file');

Maybe you are using CGI.pm.  But does $file contain a file name or a
reference to a filehandle?  If it's a file name, then you'd better open the
file and change the following code to reference the corresponding file
handle.

>         while (<$file>) {
>                 print FP $_;
>         }
>         close $file;
>         close FP;


-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: 15 Aug 1998 22:19:56 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: here's an implementation of diff in perl
Message-Id: <6r51ic$s82$1@client3.news.psi.net>

Tushar Samant (scribble@pobox.com) wrote on MDCCCX September MCMXCIII in
<URL: news:6r3acj$m7v@tako.wwa.com>:
++ mjd@op.net writes:
++ >This extreme example shows that one important measure of the quality
++ >of a diff program is whether it finds a small set of differences.
++ >The example program I showed was not useful because the differences it
++ >found were too large, and there is a smooth continuum of quality here.
++ 
++ Is the running time for "common subsequence" O(mn)? Then one way to
++ implement a "quality" parameter would be to consider k lines as a
++ "line". Cuts the time by k**2, and then you may or may not decide
++ to burrow into each cluster of lines.

Not really. First of all, the time to compare two lines increases.
Secondly, the program becomes a lot less accurate.

Consider the files:

     ABCDEFG
      BCDEFG

Only for k = 1 will it report anything other than "all lines differ".



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


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

Date: 15 Aug 1998 22:23:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: here's an implementation of diff in perl
Message-Id: <6r51oa$s82$2@client3.news.psi.net>

Ilya Zakharevich (ilya@math.ohio-state.edu) wrote on MDCCCX September
MCMXCIII in <URL: news:6r4lus$2as$1@mathserv.mps.ohio-state.edu>:
++ 
++ Sure not.  Time to compare strings depends logarithmically on the
++ length (if strings are randomly distributed, obviously this should be
++ modified if there are common prefixes).

Eh? If the time is sublinear, there must be characters not involved
in the comparison. And if those characters are not involved - you
don't know whether they are different.

Of course, it might be true that the expected time to compare randomly
generated strings is logarithmic, but one hardly applies diff on
randomly generated files.

++ But this is irrelevant, since the algorithm would not work.  Consider
++ k=2, and two files which differ by deletion of the first row.


Indeed.


Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: 15 Aug 1998 23:22:29 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: here's an implementation of diff in perl
Message-Id: <6r557l$2au$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Abigail
<abigail@fnx.com>],
who wrote in article <6r51oa$s82$2@client3.news.psi.net>:
> Ilya Zakharevich (ilya@math.ohio-state.edu) wrote on MDCCCX September
> MCMXCIII in <URL: news:6r4lus$2as$1@mathserv.mps.ohio-state.edu>:
> ++ 
> ++ Sure not.  Time to compare strings depends logarithmically on the
> ++ length (if strings are randomly distributed, obviously this should be
> ++ modified if there are common prefixes).
> 
> Eh? If the time is sublinear, there must be characters not involved
> in the comparison. And if those characters are not involved - you
> don't know whether they are different.

Correct, but irrelevant.  I do not need to know the degree of
difference, only the fact that the lines are different.

> 
> Of course, it might be true that the expected time to compare randomly
> generated strings is logarithmic, but one hardly applies diff on
> randomly generated files.

Correct, but irrelevant.  Note that for the proposed algorithm the
elementary unit (char of the alphabet) is a line of the files.

Ilya


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

Date: 15 Aug 1998 20:00:08 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: here's an implementation of diff in perl
Message-Id: <6r57e8$1h6$1@monet.op.net>


In article <6r51oa$s82$2@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>Of course, it might be true that the expected time to compare randomly
>generated strings is logarithmic, but one hardly applies diff on
>randomly generated files.

I think Ilya's point was that although the worst-case time is linear
in the length of the string, this worst case is only achieved when the
strings have a long common prefix.

He was responding to my remark that this proposed divide-and-conquer
method would have to compare and re-compare parts of the files
repeatedly, and that that would make it slow.  His observation that it
is speedy to test for steing inequality is to the point here.  This is
because if two parts of the file are identical, it takes a long time
to compare them, but you only have to do it once; it is only if they
are different that you need to recompare them repeatedly, and in this
case the comparison time is likely to be sublinear.

>++ But this is irrelevant, since the algorithm would not work. 
>
>Indeed.

Indeed.



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

Date: 15 Aug 1998 20:09:55 GMT
From: lhunter@acm.org (Larry Hunter)
Subject: Re: how can I use databases in perl?
Message-Id: <6r4puj$3j3$1@hiram.io.com>

In article <35D56A92.434D@hotmail.com>, ms9x6sts@hotmail.com says...
>I have the problem that I would need a database interface, but
>the serve I use (hypermart.net) has no modules installed.
>Any suggestions?

Get the database interface modules you need from CPAN. If they are
plain Perl modules you can access them from any directory. The
easiest way is to have the statement    use lib "path";    before
any other use  statements, where  path  is the directory where you
put the modules.
------------------------------------------------------------------------
Larry Hunter         lhunter@acm.org         http://www.io.com/~lhunter/



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

Date: Sat, 15 Aug 1998 22:43:48 GMT
From: tekkin@hotmail.com (Ken Williams)
Subject: Re: How to read multiline variable?
Message-Id: <6r52v8$48r@cabernet.niagara.com>

In article <35D5D7DF.3933F582@negia.net>, Dan Boorstein <danboo@negia.net> wrote:
>@output = `/bin/ls -l'`;
>for (@output) {
>  print;
>}

Thanks.



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

Date: 15 Aug 1998 23:59:46 GMT
From: yumpy@halcyon.com (Tim Maher)
Subject: New, Improved Perl Beautifier!
Message-Id: <6r57di$4ua$1@brokaw.wa.com>
Keywords: perl beautifier


Announcing pbeaut v0.85!

Thanks to the hundreds of deranged Perlers out there who submitted code
samples to the Perl Beautifier Web Pages <= v0.65, I have been able to
identify several deficiencies and make many improvements, which are now
incorporated in the 0.85 version.

Specifically, this version, now on the web page, has much better
formatting of hash expressions, output formats, logical and/or,
dangling modifiers, and in-line subs and evals.

Also, the web page now gives you access to the 3 most important
user-adjustable beautification parameters (out of 51 total), so you can
see the results of using different options.

In addition, the statement of Current Limitations, Tips, and Bugs is
available from that same page.  This is important because if a program
comes out "uglier" after beautification, a few small adjustments
described in the Limitations and Tips will usually allow it to be
successfully beautified.

This is my last chance to find any additional problems before I present
my beautifier to the World of Perl next Thursday at the O'Reilly Perl
Conference, so I'd be grateful if some of you could try it out (I'll
get a chance to see the results of your beautification, and learn from
them).

P.S. Please read and agree to the "fine print" on the web page before
submitting any code.

Regards,
+---------------------------------------------------------------------+
| Tim Maher, Ph.D., JAPB         Head UNIX Guru & CEO, CONSULTIX      |
| "Just Another Perl Beautician" Email: tim@consultix.wa.com          |
| Leader,  Seattle Perl Group:   http://www.halcyon.com/spug/         |
| Try my Perl Beautifier  ---->  http://www.consultix.wa.com/yumpy/   |
+---------------------------------------------------------------------+


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

Date: Sat, 15 Aug 1998 16:32:12 -0500
From: "brick" <i_am_brick@hotmail.com>
Subject: newbie question : format of first line
Message-Id: <6r4u8h$o78$1@roadrunner.micro-net.net>

I am trying to convert a Perl 4 for Unix program to Perl 5.003 for NT and I
am not sure if I have the format of the first line correct.  Can someone
tell me of a site or just give me the info on what the first line of the
program should look like.  Everything I have found so far look like the unix
program and it does not work...say it can't find the application....(I
assume it is talking about Perl).  I can run my script in the
debugger......Please help!




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

Date: Sat, 15 Aug 1998 23:32:33 GMT
From: jkirving@mosquitonet.com (Ken Irving)
Subject: Re: NT redirect to file
Message-Id: <35d5fc79.15825135@news.mosquitonet.com>

On Sat, 15 Aug 1998 19:46:04 GMT, ncarey@harlequin.com (Nicholas
Carey) wrote:

>> >Now try the following and it should give you *exactly* what you want:
>> >
>> >  processor.pl detail.txt > summary.txt
>> >
>> I've tried this in the past, got simple redirection to work, but then
>> it didn't work in a pipe.  I'd try again if the following actually
>> works:
>> 
>>    type detail.txt | processor.pl > summary.txt
>
>You may have to use parentheses to get the grouping your want
>(operator precedence, you know). You may have to do this as on of:
>
>  (type detail.txt |  processor.pl) >summary.txt
>   type detail.txt | (processor.pl  >summary.txt)
>
>or even more simply
>
>  processor.pl <detail.txt >summary.txt

I've long since given up on these shenanigans under windos, and use
only the most basic constructs, rather than be forced to use such
oddities (e.g., using parentheses for grouping). I know the latter
example can work, but it requires a file to read input from.  Instead
of something like:

  dir *.html | grep something | aperlscript.pl

I just forget about trying to use (window's broken) associations and
use:

  dir *.html | grep something | perl -S aperlscript.pl

which works without a lot of obscure configuration. But I would like
to be proved wrong, and shown that the former example can work.

Ken



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

Date: Sat, 15 Aug 1998 21:36:58 +0100
From: "bon" <TOWER_DENE_EDU@email.msn.com>
Subject: Outputting Images & Links in HTML
Message-Id: <e2yuy2Iy9GA.306@upnetnews05>

Can anyone please show me how I can include images and links in a script
that I have found?
Also, is it possible to have dynamically generated images in CGI output?

All help greatly appreciated

Kind regards,

Bruce
__________________________________________
webmaster@tradingtactics.com
www.tradingtactics.com - subscribe for 5 FREE indicators




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

Date: 15 Aug 1998 21:14:13 GMT
From: ez074520@dilbert.ucdavis.edu (Tomoyuki Tanaka)
Subject: Re: pangrams in Perl --- randomized Robisonizing
Message-Id: <6r4tn5$1f8$1@mark.ucdavis.edu>

>
> this is the 1st Perl program i've written.
>
> pls tell me how to clean it up (e.g. get rid of goto).
> and how to make it faster (without sacrificing readability).
>

 let me know if you find a bug in this.  thanks.

#--------------------------------------------------------------------
# rrob.pl  --- randomized Robisonizing
#	   --- just counts the 26 chars A-Z
#--------------------------------------------------------------------

$debug = 0;

# snum --- spelled number

$snum{1} = "one" ;
$snum{2} = "two" ;
$snum{3} = "three" ;
$snum{4} = "four" ;
$snum{5} = "five" ;
$snum{6} = "six" ;
$snum{7} = "seven" ;
$snum{8} = "eight" ;
$snum{9} = "nine" ;
$snum{10} = "ten" ;

$snum{11} = "eleven" ;
$snum{12} = "twelve" ;
$snum{13} = "thirteen" ;
$snum{14} = "fourteen" ;
$snum{15} = "fifteen" ;
$snum{16} = "sixteen" ;
$snum{17} = "seventeen" ;
$snum{18} = "eighteen" ;
$snum{19} = "nineteen" ;
$snum{20} = "twenty" ;

$snum{30} = "thirty" ;
$snum{40} = "forty" ;
$snum{50} = "fifty" ;
$snum{60} = "sixty" ;
$snum{70} = "seventy" ;
$snum{80} = "eighty" ;
$snum{90} = "ninety" ;

$AtoZ = "abcdefghijklmnopqrstuvwxyz" ;

@AtoZsplit = split(//,$AtoZ) ;

#--------------------------------------------------------------------

$seed="this sentence contains exactly  and  ";

for( @AtoZsplit ) { $old_c{$_} = 1 ; $c{$_} = 0 ; }
$s = $seed;
for( @AtoZsplit ) { $s = $s . sn( $old_c{$_} ) .
		"`" .  $_ . "'" .  s_if_plural( $old_c{$_} ) }

while (1) {
	# given:  S,  old_c (which tallies S),  C is cleared

	for(split(//,$s)) { $c{$_}++; }
	for( @AtoZsplit ) { if ( $c{$_} != $old_c{$_} )
			{goto keeplooping ; } }

	print "-----------------------------------------\n";
	print " the pangram found \n";
	for( @AtoZsplit ) { print"$_"."=".$c{$_}."   "; }
	print "\n".$s."\n" ;
	exit 0;

    keeplooping:
	if ( $debug ) {
		print "-----------------------------------------\n";
		print $s."\n" ;
		print "-----------------------------------------";
		print " TALLY OF THE ABOVE IS \n";
		for( @AtoZsplit ) { print"$_"."=".$c{$_}."  "; }
		print "\n"; }

	for( @AtoZsplit )  { $new_c{$_} = rpick( $old_c{$_} , $c{$_} ) ;
				$old_c{$_} = $c{$_} ; 
				$c{$_} = 0 ; }
	if ( $debug ) {
		print "-----------------------------------------";
		print " NEW TALLY IS \n";
		for( @AtoZsplit ) { print"$_"."=".$new_c{$_}."  "; }
		print "\n"; }

	$s = $seed;
	for( @AtoZsplit ) { $s = $s . sn( $new_c{$_} ) .
		"`" .  $_ . "'" .  s_if_plural( $new_c{$_} ) }
	}

sub s_if_plural {
	if ( $_[0] >= 2 ) { "s, " } else { ", " } }
	

sub sn {
	$x = $_[0] ;
	if ($x >= 100) { print "must be 99 or less" ; exit 1; }
	if ($x <= 20) { $snum{ $x } }
		else {
			$tens = int($x / 10) * 10 ;
			$snum{ $tens } ."-". $snum{ $x - $tens } } }
	
sub rpick {
	$x = $_[0] ; $y = $_[1] ;
	if ( $x > $y ) { $old_x = $x ; $x = $y ; $y = $old_x ; }
	int( $x + rand( $y - $x ) + 0.5) ; }



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

Date: 16 Aug 1998 00:06:03 GMT
From: yumpy@halcyon.com (Tim Maher)
Subject: Re: Perl Beautifier Home Page
Message-Id: <6r57pb$4ua$2@brokaw.wa.com>

F.Quednau (quednauf@nortel.co.uk) wrote:
: Tim Moher wrote:
: > 
: > Todd Lehman wrote:
: > 
: > > > http://www.consultix.wa.com/yumpy/cgi-pvt/pbeaut.cgi.
: > >
: 
: > Thanks!  And please try the new version!
: > 
: 
: tried it on a code snippet that was lying around there:
: 
: Beautifier error, code "14"
: 
: pbeaut: /www1/yumpy/cgi-pvt/pub/pb.in.32568:    new version failed
: syntax check (/www1/yumpy/cgi-pvt/pub/stdin.pb.32568)
: -- 
: ____________________________________________________________
: Frank Quednau               
: http://www.surrey.ac.uk/~me51fq
: ________________________________________________


Frank,

Thanks for bringing this to my attention!  I think you'll find that it
works okay on the new version, just released today, 8/15/98.  If it
doesn't, I'll fix it!

-- 
====================================================================
|  Tim Maher, Ph.D.             Tel/Fax: (206)781-UNIX             |
|  Head UNIX Guru, CONSULTIX    Email: tim@consultix.wa.com        |
|  *The UNIX Training Experts*  http://www.consultix.wa.com/yumpy/ |
====================================================================


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

Date: Sat, 15 Aug 1998 15:05:03 +0100
From: Grant Griffin <grant.griffin@iowegian.com>
Subject: Re: Q: How to read all the file name in a directory
Message-Id: <35D5958F.7AC9@iowegian.com>

Ollie Cook wrote:
> 
> On 14 Aug 1998 13:48:05 GMT, Tom Christiansen <tchrist@mox.perl.com>
> wrote:
> >Let me guess: you're a Windows ``programmer'', aren't you?  Do you
> >know why Unix programmers make more money than Windows ``programmers''?
> >Because we Unix people know how to read the manual -- and you don't.
> 
> Actually, Perl is the only language, apart from DOS Basic that I've
> ever programmed in.
> 

I still can't figure out why Tom C., who is the World's Greatest
Advocate of The World's Most Portable Language regrets it so much when
somebody runs it on something other than Unix!

In an ideal world, any given gizmo would be so easy to use that nobody
would _have to_ read the manual!  (Not that Windows is even remotly
_close_ to that goal.)  For example, I just bought a new car.  Do I want
to read the manual?  No.  Did I have to?  Yes.  The people who designed
the car screwed up.

As a general principle, I would like to see things brought _down_ from
The Mountain, rather than pushed _up_ it!

=g2

-- 

while  -- Larry Wall, comment in hash.c


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

Date: Sat, 15 Aug 1998 16:09:27 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Q: How to read all the file name in a directory
Message-Id: <fl_aggie-1508981609280001@aggie.coaps.fsu.edu>

In article <35D59369.3AB3@iowegian.com>, grant.griffin@iowegian.com wrote:

+ I guess I'm still not wise enough to understand how hurting people...er,
+ excuse me...hurting "idiots" is ever helpful.  It might be OK to squash
+ a bug, but remember that behind every "idiot" there is a "person" who
+ has feelings.

That's nice. That and a $1.07 will get you a cup of hot tea at Barnes and
Noble. Every decent distribution of perl comes with a set of documentation.

There are many reasons to consult the docset before posting to Usenet:

1. timeliness. An answer from Usenet may take hours or days to arrive.

2. correctness. An answer from Usenet may or may not be correct. The ones
   in the FAQs are about as close to perfection as any thing dervived by
   humans.

3. a source of pride. You where able to solve your own problem by yourself.
   Which in turn builds confidence.

Patting a kid on the head is nice, but that' don't teach him how to ride
a bike...

+         Silence is the most perfect expression of scorn.
+                 -- George Bernard Shaw

GBS never met Usenet.

+ I hereby pledge to use Shaw's approach to your postings in the future.

So, you're scorning TomC, eh? Ever consider the possiblity that Tom has
feelings, too?

James


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

Date: 15 Aug 1998 20:27:16 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Q: How to read all the file name in a directory
Message-Id: <ltd8a1db4r.fsf@asfast.com>

To Tom:

I know that you and many others will disagree with me on some, or even
all of the points I'm raising in this post.  But please know that I am
presenting my arguments with a feeling of deep respect for you as an
individual, and in the hopes that at worst, we can "agree to
disagree" ...

Tom Christiansen <tchrist@mox.perl.com> writes:

> [ ... ]

> Now that the helpless Prisoners of the Evil One have inundated us,
> it's Forever September here on the net, a time of sempiternal ignorance
> and incompetence.  It can only get worse.  Stamping out these selfish
> leeches has nothing to do with ego.

You seem to be making an unfounded generalization here, Tom: you seem
to think that most novices who come here asking questions are "selfish
leeches".  I think that you are making an unsupported
characterization, and that you're lumping all these people into one,
monolithic category.

It may be the path of least resistance for you to generalize and
project in this way, but I do not believe that it's fair for you to do
so.

I'm sure that there are selfish people who come here asking questions,
and I agree that there are a few of them who demandingly expect to be
spoon-fed knowledge that others have worked hard to acquire.  However,
I do not believe that this is true for the majority of novices who
show up here.  Most of them show up and innocently ask a question
without knowing the first thing about FAQ's, news.announce.newusers,
netiquette, etc.

To point these novices to the various usenet and Perl resources with
patience and politeness is the mark of a civilized, mature individual.
To do so with abusive condescension is unnecessary and, in my opinion,
rather immature.

Once told about these resources, most of these novices happily and
gratefully move on and start reading and learning from them.  And most
do so in a very self-motivated, responsible, and non-leech-like
manner.

> [ ... ] It has everything to do with what
> is expected and acceptable social behaviour, and with what is scalable.
> A million sloppering programmer-wannabes from CP/M hell who cannot or
> will not read the standard docs is simply not scalable, and thus not
> tolerable.  Not looking first to one's own manuals is unacceptable --
> because it will soon drown out everything else.

And yet, like it or not, more and more people are coming together over
the "net" and wanting to participate in this new, global communication
medium.  Many of these people are discovering all the wonderful tools
and resources that you and others have created, and they are coming
here to c.l.p.misc in ever increasing numbers.  And more and more of
them do so without seeing news.announce.newusers and without any prior
knowledge of netiquette.

You do not find this tolerable, but this will not change the reality
of the existence of all these people.  Therefore, your lack of
toleration can only cause you increasing frustration, grief, anger,
and pain as the nature of the world changes and you engage in an ever
more futile battle to stem this tide of change.

All it takes is the awareness that each "newbie" is a new person and
not the representative of some sort of amorphous mass of hungry,
leech-like stupidity.  A short, polite pointer to
news.announce.newusers and the Perl documentation is all that's
needed, in most cases, to bring "newbies" into the fold of responsible
net users.

But to hope against hope that these people will magically learn all
this on their own before even showing up here is a bit naive.

> So we must be harsh.

I don't see how this conclusion follows from your premises.  You talk
about a million "wannabes" coming here, and you somehow conclude that
these people must therefore deserve harshness.  Would you be willing
to explain in more detail the logical progression from your premises
to this conclusion that harshness "must be" the way to go?

> [ ... ] Call it tough love.  If they insist on remaining forever an
> illerate leech, then they have no business here.

How can you assume that everyone who comes here asking their first
"newbie" question is trying to "insist on remaining forever an
illerate leech"?  If you really believe this, then I ask you to make a
serious reality check.

In my experience, that characterization applies to a small minority of
those who come here asking "newbie" questions.  The vast majority of
them will just as readily (if not more so) go to the doc's when told
to do so politely as those who will do so after being abusively dumped
on.

I repectfully request of you to please save your harshness for the
small minority of "repeat offenders" who refuse to do this even after
being pointed to the FAQ's and doc's.  *These* are the only people who
might fit into your category of those who "insist on remaining forever
an illerate leech".

> [ ... ] If they learn from chastisement, then the problem is cured.
> Thus it has been on USENET for the last fifteen years that I've been
> reading and posting regularly.

In my experience over the past 11-12 years on usenet, most novices who
show up in technical newsgroups with frequently asked questions at
worst have received terse pointers to documentation, *not* gratuitous
abuse.

As I have stated elsewhere, I am *in* *favor* of sending novices to
the documentation and of educating them about proper netiquette.  But
I am *opposed* to doing that abusively.  It is just effective for you
to be terse and polite than for you to dump on people.

As for learning from chastisement, I wonder if you can show that these
"newbies" learn better from your chastisement than they would learn
from short, polite pointers to the FAQ's and doc's?  Do you really
believe that chastisement is more effective than politeness?

Your defense of harsh chastisement almost sounds like an instance of
"if you want to make an omelet, you have to break a few eggs".  But as
I mentioned above, I don't see a consistent logical chain of reasoning
from your premises to your conclusion about the necessity of using
harshness instead of politeness.  Therefore, I wonder if your
arguments are perhaps just rationalizations that you have come up with
after the fact to defend a habit of harsh condescension that you
already posessed long before the droves of "newbies" appeared on the
scene.  I honestly and truly hope that this is not the case.

> I used to be on the other end, but I was apparently gifted with a lost
> art: I knew how to read and learn from documentation and source code.
> Anyone who is going to get anywhere does.

I contend that most "newbies" believe the same thing that you do about
the value of reading and learning from documentation and other extant
resources.  I truly believe that you are being quite unfair in
categorizing all "newbies" in this manner.  Only a small number of
people ("newbies" or otherwise) behave as the "leeches" you describe.

> We'll put you on idiot-answering service for a few years and we'll
> see how sweet you remain.

No one is forcing you to be "on idiot-answering service", Tom.  You
are voluntarily exercising your own free will if you choose to take on
this role ... and you are just as free to refuse this role at any
time.  If a person makes the conscious choice to take on this role, I
believe that it is part of the responsibility of the task to exercise
the duties as a mature adult who is (at least mostly) in control of
his or her emotional reactions.  If one cannot or does not want to do
that, then I believe that this person should re-think his or her
conscious choice in taking on this particular role.

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: Sat, 15 Aug 1998 22:20:09 GMT
From: oliver.REMOVE.cook@bigfoot.DELETE.com (Ollie Cook)
Subject: Q: Missing first user
Message-Id: <35d60930.3133852@news.ukonline.co.uk>

I'm writing a script that tells me which users are telnetted into my
server. I came up with this script, the thing is it misses out the
first user and I can't work out why. If anyone can help I'd really
appreciate your suggestions. here's the script:

You can access it at http://www.premiere.uk.com/cgi-bin/who.pl if you
want to see it in action.

#!/usr/bin/perl
# Get Date & Time
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
if ($sec < 10)  { $sec = "0$sec";   }
if ($min < 10)  { $min = "0$min";   }
if ($hour < 10) { $hour = "0$hour"; }
if ($mday < 10) { $mday = "0$mday"; }
if ($mon < 10)  { $monc = "0$mon";  }
$date = "$hour\:$min\:$sec $mday/$mon/$year";
# Print Top HTML
print "Content-type: text/html\n\n";
print '<HTML><BODY><CODE>';
print '<H1><U>Who\'s Logged In On ';
print $ENV{'SERVER_NAME'};
print '?</U></H1>';
print 'These users are logged in as at ';
print $date;
print '<BR><BR>';
print '<OL>';
# Print Users
while (<`users`>) {
 print '<LI>';
 print "$_";
}
# Print Bottom HTML
print '</OL>';
print '</CODE></BODY></HTML>';

Thanks, Ollie
----
Oliver COOK, Web Site Designer for
Premiere Web Designs - Http://Www.Premiere.Uk.Com/
+
Webmaster of The Audio-Visual Archive 
 * over 900 images and 700 sounds, free
 * Http://Www.Premiere.Uk.Com/ava/ 


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

Date: Sat, 15 Aug 1998 17:36:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Q: Missing first user
Message-Id: <MPG.103fc97bda13200d9897cd@nntp.hpl.hp.com>

In article <35d60930.3133852@news.ukonline.co.uk> on Sat, 15 Aug 1998 
22:20:09 GMT, Ollie Cook <oliver.REMOVE.cook@bigfoot.DELETE.com> says...
 ... 
> #!/usr/bin/perl

No -w; no 'use strict;'

> # Get Date & Time
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
> localtime(time);
> if ($sec < 10)  { $sec = "0$sec";   }
> if ($min < 10)  { $min = "0$min";   }
> if ($hour < 10) { $hour = "0$hour"; }
> if ($mday < 10) { $mday = "0$mday"; }
> if ($mon < 10)  { $monc = "0$mon";  }
> $date = "$hour\:$min\:$sec $mday/$mon/$year";

See below for three lines of code that do this correctly.

> # Print Top HTML
> print "Content-type: text/html\n\n";
> print '<HTML><BODY><CODE>';
> print '<H1><U>Who\'s Logged In On ';
> print $ENV{'SERVER_NAME'};
> print '?</U></H1>';
> print 'These users are logged in as at ';
> print $date;
> print '<BR><BR>';
> print '<OL>';

Use a 'here' document instead of a list of prints.

> # Print Users
> while (<`users`>) {
>  print '<LI>';
>  print "$_";

Why quotes around $_, or why not just 'print;' for that matter?

> }
> # Print Bottom HTML
> print '</OL>';
> print '</CODE></BODY></HTML>';

 ...

#!/usr/bin/perl -w
use strict;

# Get Date & Time
my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
my $date = sprintf '%.2d:%.2d:%.2d %.2d/%.2d/%.2d',
    $hour, $min, $sec, $mday, $mon + 1, $year % 100;

# Print Top HTML
print <<EOT;
Content-type: text/html

<HTML><BODY><CODE>
<H1><U>Who's Logged In On 
$ENV{SERVER_NAME}
?</U></H1>
These users are logged in as at 
$date
<BR><BR>
<OL>
EOT

# Print Users
foreach (split ' ', `users`) { print "<LI>$_\n" }
# Alternatively, for the braces-intolerant:
# print map "<LI>$_\n" => split ' ' => `users`;

# Print Bottom HTML
print "</OL></CODE></BODY></HTML>\n";
__END__

The principal bug is in your use of `users` (I'd never even noticed that 
command; always used `who`).  The second bug is in your printing of the 
date: off by one month always, and by 100 years in about 16 months from 
now.

The rest of the changes are stylistic -- others may disagree.  It 
preserves your line spacing, except for the list items.  This helps if 
you want to see the output with a text editor or as browser 'View 
Source'.

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


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

Date: Sun, 16 Aug 1998 00:45:57 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Q: Missing first user
Message-Id: <35D62D40.6DF0FD1@shaw.wave.ca>

Ollie Cook wrote:
> 
> #!/usr/bin/perl
> # Get Date & Time
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
> localtime(time);
> if ($sec < 10)  { $sec = "0$sec";   }
> if ($min < 10)  { $min = "0$min";   }
> if ($hour < 10) { $hour = "0$hour"; }
> if ($mday < 10) { $mday = "0$mday"; }
> if ($mon < 10)  { $monc = "0$mon";  }

That's a strange way of writing:
    for ($sec,$min,$hour,$mday,$mon) { $_ = sprintf "%02d", $_ }

Ansd what's wrong with the format that localtime gives in a scalar
context?  Oh well, that has nothing to do with your question.

> while (<`users`>) {

This is very odd.  You are using the output of the command 'users' as a
fileglob pattern.  Not sure why you miss the first user, though.  What you
probably want is:

    for (`users`) {

See the 'I/O Operators ' section of perlop.

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Sat, 15 Aug 1998 20:49:11 GMT
From: nick@imationstudio.com
Subject: Quickie encapsulation question
Message-Id: <6r4s88$1nd$1@nnrp1.dejanews.com>

This is really simple on for those of you who write a lot of OO perl. I'm
trying to be more conscious about reuse, here is a pathetic attempt.

Let's say I have a package:

package JobOrder;

In that package, I have several other classes "used" and instantiated. The one
in question is my own class, called Validate. I go and do a:

$val = new Validate;

I can assume this object now exists fully scoped as $main::JobOrder::val.

I've got it working now so that if any method in my $val object needs to
access a method in the JobOrder class, I can call it explicitly. But I don't
want to do that. (no reuse payoff) What I want to do is have the caller pass
name of the package it's in and have the method buried inside the class know
how to call methods in the calling class at invocation time, which can change
from invocation to invocation.

ie: doing $val->whatever("JobOrder", $whatnot, $foobar);

and having the method in $val calling a method in JobOrder by having this:

whatever(@) {
    my $package = shift;
    my $param1 = shift;
    my $param2 = shift;

    # call a method in the upstream class
    $$package::upstream_class_obj->upstream_class_meth();
}

perl complains and dies because it can't find the upstream package, $$package.
I've tried ${$package}, too. No go.

What am I not understanding? I've looked in the perl 2nd ed. Camel book at
chapters 4 and 5 and I don't see any examples of what I'm trying to do. Any
takers?

Anyway thanks for the bandwidth regardless.

-Nick

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Sat, 15 Aug 1998 21:02:11 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Randal-addnl help
Message-Id: <35D5F8CE.CADD991D@shaw.wave.ca>

[posted and mailed]

Alan Melton wrote:
> 
> You had written a short perl program to convert
> individual ascii files arranged vertically into
> a single database, comma delimited.

[snip original data and Randal's program that gives numerous examples of
extracting only the desired data]

So you now know how to get your data into an array and print only the
fields that you want.

> 
> I would like to do the same as before but only pull out the data
> after the @ sign and put that into one file
> and pull out the data after the * and put that into a different file.
> 

Open two files and print the fields (elements) that you want to them.

    print ATFILE   join (',', @vals1), "\n";
    print STARFILE join (',', @vals2), "\n";
   
where @vals1 contains the fields after the '@' field and @vals2 contains
the fields after the '*' field.

I'm assuming that the '@' and '*' are always in the same field.  If not,
you need to search the array and find out which element contains the
character and put all elements after it into the @vals arrays.  One way:

    for (@a) { push @vals1, $_ if $found;$found++ if $_ eq '@' }

> I appreciated your direct help before and made a lovely
> contribution to your legal fund. Could we try for this as well.

You could also help Randal out by buying "Learning Perl".  You will find
it helps you more.

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Sun, 16 Aug 1998 00:16:39 GMT
From: Casey Lee <sysadmin@thegrid.net>
Subject: Strange behavior with 'use'
Message-Id: <35D62559.8D3858DC@thegrid.net>

Got a wierd one here...

I have two files a.pm and b.pm, both are similar and
they use each other and call functions in each other.

I start the whole thing with this command:

% perl -e 'use a; &testa()'

and get output like this:

in sub testa
in sub testb
Undefined subroutine &b::testa called at b.pm line 11.

Why isn't it looping around and around forever??

Thanks in advance,

Casey

a.pm
----

package a;

require Exporter;
use b;

@ISA    = qw ( Exporter );
@EXPORT = qw ( testa );

sub testa {
        print "in sub testa\n";
        &testb();
}

b.pm
----

package b;

require Exporter;
use a;

@ISA = qw ( Exporter );
@EXPORT = qw(  testb );

sub testb {
        print "in sub testb\n";
        &testa();
}


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

Date: Sat, 15 Aug 1998 17:06:01 -0500
From: Matt Kruse <mkruse@rens.com>
Subject: URGENT! Perlscript + Asp - multiple database queries??
Message-Id: <35D60649.1509@rens.com>

I have an urgent problem:

Using the latest PerlScript within ASP, I am opening a database
connection and then trying to perform two separate queries.

THE PROBLEM: The second query always fails. No recordset is returned.
This happens for ANY query, and I've tested many.
Even if I close the connection and open a new one with a different 
name, only one query will ever work within an ASP page.

Is this a known problem?
Is there a work-around?
Has anyone else used PerlScript and performed multiple queries in one
page?

Thanks!

--
Matt Kruse
mkruse@rens.com
Renaissance Worldwide


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

Date: Sat, 15 Aug 1998 22:51:10 +0200
From: R. A. Larsen <r_larsen@image.dk>
Subject: Re: What about $/... was help parsing mail file
Message-Id: <VA.0000004f.0111b8dd@octo>

Charles Maier <maierc@chesco.com> wrote:
> 
> Abigail wrote:
[ use $/ = "" to read entire header ]
> 
> I tried this very same thing the other day to get the entire contents of
> a file into a single variable. Setting the $/ = "" DID NOT get the
> entire file. <SOMETHING>... which I did not pursue.. triggered the end
> of line sencing in the middle of the file. Since I only wanted to insure
> that all the data got in.. I filled the $/ with "known garbage" and it
> worked fine. 
> 
> Reading this responce has me revisiting this piece of trivia. What can
> "match" a record separator of "" ???

Nothing :) Actually an empty line. You use this to read paragraphs with empty 
lines in between.

I hope this helps.

Regards, Reni
-- 
Using Virtual Access
http://www.vamail.com



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

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

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