[9863] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3456 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 16 01:07:19 1998

Date: Sat, 15 Aug 98 22:00:16 -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: 3456

Today's topics:
        Benchmark: shift vs. multiply <ljz@asfast.com>
    Re: eq and == difference (Abigail)
    Re: File updating question <ketanp@NOSPAMxwebdesign.com>
    Re: here's an implementation of diff in perl (Abigail)
        installation problems on win95 <thierry.metoudi@hol.fr>
    Re: installation problems on win95 (Nathan V. Patwardhan)
        Multi-line regex w/ multi-file loop <ash0578@flash.net>
    Re: New, Improved Perl Beautifier! <tchrist@mox.perl.com>
    Re: Perl Style (Greg Andrews)
    Re: perl5 large integer conversion bug <tchrist@mox.perl.com>
    Re: PLEASE - SOMEONE (Rich)
        Pretty HTML-izing of Perl source? (Corbett J. Klempay)
    Re: Pretty HTML-izing of Perl source? <ash0578@flash.net>
    Re: Q: How to read all the file name in a directory (Michael J Gebis)
    Re: Q: How to read all the file name in a directory (Michael J Gebis)
    Re: Q: How to read all the file name in a directory <ljz@asfast.com>
    Re: Q: Missing first user (Larry Rosler)
    Re: Q: Missing first user (Craig Berry)
        sending variables with a hypertext link <dan@fearsome.net>
    Re: testing if file exists <dan@fearsome.net>
    Re: X-file (?=...), case postponed. <rick.delaney@shaw.wave.ca>
    Re: X-file (?=...), case postponed. (Patrick Timmins)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 15 Aug 1998 23:03:13 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Benchmark: shift vs. multiply
Message-Id: <lt4svdd3wu.fsf@asfast.com>

A couple weeks or so ago, there was a discussion about the use of bit
shifts as an alternative to multiplication or division by a power of
two.  During this discussion, it was pointed out that this technique
is a relic of the days of slow processors and non-optimizing
compilers.  At that time, I said that I'd run some benchmarks on this
to see if bit shifts in Perl are any faster these days than the
corresponding multiplications or divisions.  Well, I finally got
around to doing this.

I'm using Perl 5.004_04 under RedHat Linux 5.0 on a 200 MHz Pentium
Pro processor utilizing 128 Meg of memory.  As you can see, there is
no significant difference in this environment between the use of bit
shifts and multiplication/division by the corresponding power of 2:

 Benchmark: timing 1000000 iterations of Divide, Multiply,
                                         Shift Left, Shift Right...
     Divide:  9 secs ( 8.19 usr  0.00 sys =  8.19 cpu)
   Multiply:  8 secs ( 8.23 usr  0.00 sys =  8.23 cpu)
 Shift Left:  9 secs ( 8.25 usr  0.00 sys =  8.25 cpu)
 Shift Right:  8 secs ( 8.08 usr  0.00 sys =  8.08 cpu)


And here's the code ...

  #!/usr/bin/perl
  # -*- perl -*-
 
  (my $program = $0) =~ s:^.*/::;
 
  use Benchmark;
 
  Benchmark::timethese(1000000, {
        'Shift Left'  => sub {
                           use integer;
                           my $x = 0xffff;
                           $x <<= 10;
                         },
        'Multiply'    => sub {
                           use integer;
                           my $x = 0xffff;
                           $x *= 1024;
                         },
        'Shift Right' => sub {
                           use integer;
                           my $x = 0xffff;
                           $x >>= 10;
                         },
        'Divide'      => sub {
                           use integer;
                           my $x = 0xffff;
                           $x /= 1024;
                         },
  });
 
  exit(0);
 
  __END__


-- 
 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: 16 Aug 1998 04:48:57 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: eq and == difference
Message-Id: <6r5obp$au2$1@client3.news.psi.net>

Peter Richmond (peter@richmd.demon.co.uk) wrote on MDCCCX September
MCMXCIII in <URL: news:35D61CF1.B61DB8A4@richmd.demon.co.uk>:
++ Hi,
++ 
++ Is there a difference between eq and == ?

Which part of the documentation that explains 'eq' and '==' do
you fail to understand?

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

Does not work? In which sense? Does it demand more money? Is it
sitting on the couch and watching television? Is == on the beach
getting a suntan? 

Or is it that == is doing what it is supposed to do, and you haven't
read the documentation, nor did you turn on warnings?

++ Could someone shine some light on this?

*Batteries not included.



Abigail
-- 
Know why they put them little umbrellas in those tropical drinks? It's
so that when it rains it don't thin out the liquor!


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

Date: Sun, 16 Aug 1998 00:42:39 -0400
From: Ketan Patel <ketanp@NOSPAMxwebdesign.com>
Subject: Re: File updating question
Message-Id: <35D6633F.D2ADC3F5@NOSPAMxwebdesign.com>

M.J.T. Guy wrote:
> It's not a matter of stopping B from opening the file.   Rather it's
> a question of stopping B from updating the file.    So use a
> non-destructive form of open:
> 
>     open FH, "+<$fileB" or die "Couldn't open: $!\n";
>     flock ...
> 
> Then use seek() and truncate() as needed.

Thanks... this is the code I have now, and it seems to have solved the
problem I showed before in the before/after data files... 

#!/usr/local/bin/perl5
$file = "test.txt";
open(DATAX,"+<$file") or die "die!";
flock DATAX, 2;
seek DATAX, 0, 0;
$x = 0;
while(<DATAX>) {
	@array = split(/\|/,$_);
	$array[2] = int($array[2]);
	$array[2]++;
	$new = join("\|",@array);
	seek DATAX, ($x * 264), 0;
	print DATAX $new;
	$x++;
}
close(DATAX);

I realize using "$x" and "($x * 264)" is probably an unconventional way
of doing this... I don't full understand 'seek pointers' yet, so this is
what I came up with... Any suggestions on cleaning this up?  Should this
solve the problem of two processes accessing the same file and
corrupting it?

Thanks!


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

Date: 16 Aug 1998 01:21:04 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: here's an implementation of diff in perl
Message-Id: <6r5c60$5q8$2@client3.news.psi.net>

Ilya Zakharevich (ilya@math.ohio-state.edu) wrote on MDCCCX September
MCMXCIII in <URL: news: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.

Can you explain your algorithm? I fail to see how you can know two
lines the same without somehow involving all characters.

++ > 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.

I've no idea what you mean by this.



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: Sun, 16 Aug 1998 01:50:12 +0200
From: Thierry METOUDI <thierry.metoudi@hol.fr>
Subject: installation problems on win95
Message-Id: <35D61EB4.4B9C48A8@hol.fr>

Where can I find instructions to install properly
perl and some modules on a win95 system?

Thanks

-- 
Thierry METOUDI:  thierry.metoudi@hol.fr
PHP@ http://www.mygale.org/~tmetoudi



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

Date: 16 Aug 1998 01:17:50 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: installation problems on win95
Message-Id: <6r5bvu$8l0@fridge.shore.net>

Thierry METOUDI (thierry.metoudi@hol.fr) wrote:
: Where can I find instructions to install properly
: perl and some modules on a win95 system?

Sad to say, but this depends on your version of Perl for win32.  If
it's the "standard" port, you run an install script after you've
extracted from the zip file.  If it's the ActiveState 5.004_6x or
5.005_xx port, you run the .exe file to extract the files and run
InstallShield; then you'll have to reboot your machine (no kidding) so
that all the registry values take effect.

In any case, you should probably check out the INSTALL and README docs
which ship with the standard port and at www.activestate.com.

--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>


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

Date: Sat, 15 Aug 1998 20:57:19 -0500
From: Ashley Tingdale <ash0578@flash.net>
Subject: Multi-line regex w/ multi-file loop
Message-Id: <35D63C7E.DB82718D@flash.net>

I recently saw a solution posted to open one file and assign it to a
variable as one long string. This allows using a regular expression like
this --

{ local $/; $file = <FILE> }
$file =~ s/something/somethingelse/is;

This is just what I have been looking for to replace some HTML with a
server side include statement. But I need to do it on many files.

I don't understand just how the special variable $/ works and why it is
in a block by itself?. Can I just declare this $/ variable once at the
top of the program, and loop through my files like this:

local $/;
@file_list;  # list of files I search

for (i = 0; i < @file_list; i++) {
    $file_name = $file_list[i];
    system ("cp $file_name $file_name . '.bak'");    # backup file just
in case
    open (FILE, "< $file_name") || die "cannot open $file_name file:
$!\n;
    $file = <FILE>;          # read file as one string
    $file =~ s/html text/SSI statement/is;    # make switch
    print ($file OUTFILE);     # assume that I have opened this above to
shorten code
    close (FILE);
    close (OUTFILE);
}

Will this work okay?

Thanks,
Tom Tingdale



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

Date: 16 Aug 1998 01:18:57 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: New, Improved Perl Beautifier!
Message-Id: <6r5c21$8b2$2@csnews.cs.colorado.edu>
Keywords: perl beautifier

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    yumpy@halcyon.com (Tim Maher) writes:
:Announcing pbeaut v0.85!

Did you run this on everything in my scripts archive
on CPAN yet?

--tom
-- 
It's all magic.  :-)    --Larry Wall in <7282@jpl-devvax.JPL.NASA.GOV>


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

Date: 15 Aug 1998 20:40:06 -0700
From: gerg@shell1.ncal.verio.com (Greg Andrews)
Subject: Re: Perl Style
Message-Id: <6r5kam$5sm$1@shell1.ncal.verio.com>

tchrist@mox.perl.com (Tom Christiansen) writes:
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc, Scott.L.Erickson@HealthPartners.com (Scott Erickson) writes:
>:I, for one, believe
>:that using 'or' is much more readable than ||, 
>
>Do you also believe that `plus' is more readable than `+' comma
>or that `BEGIN' is more readable than `{' question mark
>

Didn't you mean " ... comma || that 'BEGIN' ..."  ?

  -Greg


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

Date: 16 Aug 1998 01:17:52 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: perl5 large integer conversion bug
Message-Id: <6r5c00$8b2$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
:Oh, stop this, Tom!  People expect that Perl numbers behave as, well,
:numbers.  

Bit patterns are not numbers.  What's 2 & 3.4?  What's -1 | 1?
What's O_RDWR|O_CREAT?

--tom
-- 
    "Don't wear rollerskates to a tug-of-war." --Larry Wall


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

Date: 16 Aug 1998 01:37:31 GMT
From: richm@ucesucks.mulveyr.roc.servtech.com (Rich)
Subject: Re: PLEASE - SOMEONE
Message-Id: <slrn6tcdu2.h4a.richm@ll.aa2ys.ampr.org>

On 12 Aug 1998 02:07:41 GMT, Alfredo Galebe <galebe@hotmail.com> wrote:
>I would like to find where i can get a developer ... fast and reliable ... 
>
>need it fast
>

   Any local photographic supplier will have a variety of developers
to choose from.  They'll even have fixers, and other interesting
chemicals.  Personally, I have to recommend Kodak products, since
I used to work for them, and live in Rochester, NY - their home office.

   Or, did you have something more specific in mind, in terms of both
geography and capabilities?  You might want to be more specific.

- Rich

--
Rich Mulvey                                         
My return address is my last name, 
   followed by my first initial, @mulveyr.roc.servtech.com        
http://mulveyr.roc.servtech.com
Amateur Radio: aa2ys@wb2wxq.#wny.ny.usa


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

Date: Sat, 15 Aug 1998 22:03:52 -0400
From: cklempay@acm.jhu.edu (Corbett J. Klempay)
Subject: Pretty HTML-izing of Perl source?
Message-Id: <MPG.104007add10e93a0989681@news.erols.com>

Hi there..I'm wondering if anyone is aware of (and can point me to) any 
tools (probably in Perl themselves, I'd assume) that, given Perl source, 
output pretty HTML files (syntax highlighted, basically).  I have seen a 
tool that does just this for Python, but I was wondering if there existed 
a Perl equivalent.

---

Corbett J. Klempay
http://www2.acm.jhu.edu/~cklempay


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

Date: Sat, 15 Aug 1998 21:28:01 -0500
From: Ashley Tingdale <ash0578@flash.net>
To: "Corbett J. Klempay" <cklempay@acm.jhu.edu>
Subject: Re: Pretty HTML-izing of Perl source?
Message-Id: <35D643B0.B1A41DFA@flash.net>

Try Lemmy for an inexpensive pretty-good editor with vi emulation at
http://www.softwareonline.org,
or for a high-end editor Visual Slick Edit at http://www.slickedit.com. Both
have color coding for several languages including Perl.

Tom Tingdale

Corbett J. Klempay wrote:

> Hi there..I'm wondering if anyone is aware of (and can point me to) any
> tools (probably in Perl themselves, I'd assume) that, given Perl source,
> output pretty HTML files (syntax highlighted, basically).  I have seen a
> tool that does just this for Python, but I was wondering if there existed
> a Perl equivalent.
>
> ---
>
> Corbett J. Klempay
> http://www2.acm.jhu.edu/~cklempay





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

Date: 16 Aug 1998 00:55:09 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Q: How to read all the file name in a directory
Message-Id: <6r5ald$lmr@mozo.cc.purdue.edu>

fl_aggie@thepentagon.com (I R A Aggie) writes:
}Patting a kid on the head is nice, but that' don't teach him how to ride
}a bike...

Let me guess.  You learned to ride a bike by consulting the
documentation.  

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: 16 Aug 1998 01:23:56 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Q: How to read all the file name in a directory
Message-Id: <6r5cbc$m69@mozo.cc.purdue.edu>

Lloyd Zusman <ljz@asfast.com> writes:

}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" ...

Don't you get it?  You're arguing with folks that LOVE the fact that
it is "eternally September."  It's a sweet deal--a newbie comes in and
asks what is admittedly a dumb question.  Now anybody can throw
netiquette away and flame away, all in the name of that same precious
netiquette.  

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

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

fl_aggie@thepentagon.com (I R A Aggie) writes:

> 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:
>
> [ ... reasons snipped to conserve bandwidth ... ]

And these are indeed excellent reasons.  And there are equally good
reasons to say something like this to a first-time "newbie" who
posts a FAQ:

"Your query is a frequently-asked-question in c.l.p.misc, and it is
 answered in the FAQ which can be found, among other places, at 
 ftp://ftp.orst.edu/pub/packages/CPAN/doc/FAQs/FAQ/PerlFAQ.html.
 In the interest of keeping the clutter in c.l.p.misc down to a
 manageable level, we ask you to please consult this excellent
 documentation before posting questions here.  Thank you."

However, I can't think of a good reason to for being abusive when
recommending that a first-time "newbie" consult the doc's.

Yes, it's a Good Thing to recommend the doc's to "newbies".  No one is
disputing that.  The point that is being argued here is whether or not
the "newbie" should be dealt with abusively or politely when being
steered to these excellent resources.

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

Telling a kid he or she is a "selfish leech" for asking a question
about riding a bike does not teach him anything worthwhile, either.
Nor does ranting at the kid about how he or she is one of "a million
sloppering bike-riding-wannabes" (replace "bike-riding" with
"programming" for an exact quote of Tom's), nor does going on about
how he or she is an example of "these energy-sucking lazy sorts", nor
is following all that up with how "we must be harsh" and this is
"tough love".  All this taken together (which is how it was presented)
borders on abuse.

Actually, I'm not sure that bike riding is a good example here,
because most kids can reasonably expect to ask for and receive
encouragement and help from their moms, dads, siblings, friends, and
other relatives when first learning to ride.

> +         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?

I'm sure that Tom has feelings.  However, if he or anyone else who has
feelings makes a point of deliberately insulting others, then he or
she can expect to sometimes get responses in return that he or she
might not like, no matter how justified he or she might feel in
delivering these insults.  However, Tom is neither naive nor thin
skinned, and I trust that he fully expects to get flames in response
to some of the inciteful [spelling deliberate] things that he posts.

> [ ... ]

-- 
 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 17:57:49 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Q: Missing first user
Message-Id: <MPG.103fce64f77d37a09897ce@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <35D62D40.6DF0FD1@shaw.wave.ca> on Sun, 16 Aug 1998 00:45:57 
GMT, Rick Delaney <rick.delaney@shaw.wave.ca> says...
> Ollie Cook wrote:
 ...
> Ansd what's wrong with the format that localtime gives in a scalar
> context?  Oh well, that has nothing to do with your question.

He is British and likes the date before the month.

>     for (`users`) {

>From `man 1 users`:  *users* lists the login names of the users currently 
on the system in a compact, one-line format. ...

It needs to be split.

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


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

Date: 16 Aug 1998 04:18:21 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Q: Missing first user
Message-Id: <6r5mid$eij$1@marina.cinenet.net>

Ollie Cook (oliver.REMOVE.cook@bigfoot.DELETE.com) wrote:
: 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.

Oh, my.  Look at it this way:  You have lots of room for optimization. :)
My rewrites of code fragments below are interspersed.

: #!/usr/bin/perl
: # Get Date & Time
: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =

Replace

: localtime(time);

with

  localtime;

 ...since time is the default argument, so to speak.

Replace

: 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";

with:

  my $date = sprintf '%02d:%02d:%02d %d/%d/%d',
                     $hour, $min, $sec,
                     $mday, $mon + 1, $year;

Note that I'd be tempted to use %02d formats for month and day as well, to
make them line up well, and also note that you need to add one to the
month to get the human-expected month number (localtime uses Jan=0, not
1).  Note also that I'd strongly recommend replacing $year with $year+1900
so as to ease your Y2K transition.

Or, unless you have some specific need for that date/time formatting, just
do

  my $date = localtime;

and take advantage of the rather nicely formatted date/time string
localtime produces when called in a scalar context.

: # Print Top HTML

Replace

: 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>';

with:

  print <<END_OF_HEADER;
  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>
  END_OF_HEADER

: # Print Users

Replace

: while (<`users`>) {
:  print '<LI>';
:  print "$_";
: }

with:

  my @users = `users`;

  foreach (@users) {
    print "<LI>$_\n";
  }

What you had above made no sense.  You were running the external command
'users' to (presumably) get a list of users, one per line, then...doing a
file glob on it?  Or was that intended as a handle read?  In either case,
you need to go back and reread the doc on the backtick operator.

: # Print Bottom HTML

: print '</OL>';
: print '</CODE></BODY></HTML>';

Hope this helps...

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Sun, 16 Aug 1998 04:37:58 +0100
From: "Daniel Adams" <dan@fearsome.net>
Subject: sending variables with a hypertext link
Message-Id: <903238708.27193.0.nnrp-07.c2deb1c5@news.demon.co.uk>

I need to call a perl script from within an html document. Normally, of
course, you would make a simple html link such as <a
href="foobar.cgi">click</a>.

However, I need to send some variables to the script when the hypertext link
is clicked. Is this possible? How do I do this?

My only thought is that there is some way of attaching variables at the end
of the filename, as you see in search engine scripts - i.e.
yahoo.com/search.cgi?XXX_XXX

If this is the right way to go about things, I would very much appreciate
somebody suggesting a link to a source of further information so that I can
learn about this. I have tried dejanews, altavista, the myriad of perlFAQ's
and even the (IMHO) unbearable man pages, but I can't find what I'm looking
for, mainly because I don't know what it is.

Any pointers welcome, but the URL of a webpage on this whole topic would be
especially welcome. Of course, if I am completely off track, notice of that
fact will be equally welcome ;-)

Thanks,

Dan Adams
dan@fearsome.net




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

Date: Sun, 16 Aug 1998 04:23:43 +0100
From: "Daniel Adams" <dan@fearsome.net>
Subject: Re: testing if file exists
Message-Id: <903237853.27060.0.nnrp-07.c2deb1c5@news.demon.co.uk>

Thanks to everyone who emailed a reply, or posted a response in the
newsgroup, I appreciate all your help and the -e test, as suggested by
everyone, does exactly what it says on the tin ;-)

Thanks,

Dan Adams
dan@fearsome.net

Andrew M. Langmead wrote in message ...
>"Daniel Adams" <dan@fearsome.net> writes:
>
>>The bit I am stuck on is the "foobar.htm exists" part, the rest I can do,
>>the if/then statements etc -but  how do I write "if foobar.htm exists" in
>>Perl?
>
>You might want to look at the -X tests in the perlfunc man
>page. The "-e" (exists) one might do what you want.





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

Date: Sat, 15 Aug 1998 10:58:11 -0400
From: "Rick Delaney" <rick.delaney@shaw.wave.ca>
Subject: Re: X-file (?=...), case postponed.
Message-Id: <35D5A203.BC2852D5.rraclpm@shaw.wave.ca>

[posted and mailed]

Patrick Timmins wrote:
> 
> In article <1ddq8gh.v883v81dpaqrqN@bay1-557.quincy.ziplink.net>,
>   rjk@coos.dartmouth.edu (Ronald J Kimball) wrote:
> [snip]
> > You really don't understand how a regex is applied.  With the above
> > example:
> >
> > /(?=(.*))/
> >

The part that is left out before this elegant explanation is

Regex sees ''
  Regex matches the null string at the first possible place.  

The part you fail to understand is that the first possible place is
*between* the 'J' and the 'u'.  This is a special case with split that
only applies to patterns that match the null string.  

This is not the case with m/(?=(.*))/g, for example, where the first
possible match would be befor the 'J'.

> > Regex engine sees '(?=' [or compiled equivalent]
> >   Regex engine begins a positive lookahead assertion.  Thus,
> >   anything matched while in the (?=) will not be saved to the
> >   potential $&.
> > Regex engine sees '('
> >   Regex engine begins parenthesized subexpression #1.  Anything
> >   matched while in the () will be saved to the potential $1.
> > Regex engine sees '.*'
> >   Regex engine matches a whole bunch of characters.  Potential $1
> >   now contains the string of characters.  Potential $& still
> >   contains the null string.
> > Regex engine sees ')'
> >   Regex engine ends parenthesized subexpression #1.  The value
> >   of potential $1 is now available as \1.
> 
> Stop right there Ronald (and thank you for illustrating my point).
> Would you please tell me what is in the potential $1 right now if
> the regex is applied to the string "Just another Perl Hacker" ?
> I'll bet you a nickel that what is in the potential $1 is 'Just
> another Perl Hacker', and not 'ust another Perl Hacker' ... Thanks!
> 

You just lost yourself a nickel.

> So, in the original split expression context, we have a matching
> substring in the delimiter (as you point out above) containing 'Just
> another Perl Hacker'. According to the split docs, and I quote:
> 

No, containing 'ust another Perl Hacker'.  You cannot look ahead from
behind the 'J' and expect the 'J' to be there.

> "If the PATTERN contains parentheses, additional array elements
> are created from each matching substring in the delimiter."
> 
> since the perldocs show the matching substring in the delimiter being
> thrown on to the array where it is encountered, and since we are
> encountering it right off the bat, it should be thrown on to the
> array. But instead it is discarded. This is curious, and illogical.

Nothing is being thrown out.  The first delimiter encountered is

"" . "ust another Perl Hacker"

I have added the "" to represent the place between the 'J' and the 'u'. 
Split returns the elements in the order (string, delimiter, string,
delimiter, ...) which is in the order that they were encountered.  

The first string in this example is 'J' and the first delimiter is 'ust
another Perl Hacker'.  Then 'u' and 'st another Perl Hacker'.

Please get off this craxy mathematical parenthetical precedence kick. 
It is completely at odds with left to right and backtracking.

Hopefully _this_ post will get through to the moderated group.

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


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

Date: Sat, 15 Aug 1998 20:54:55 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: X-file (?=...), case postponed.
Message-Id: <6r4siv$1r3$1@nnrp1.dejanews.com>

In article <35D5A203.BC2852D5@shaw.wave.ca>,
  Rick Delaney <rick.delaney@shaw.wave.ca> wrote:
> The part that is left out before this elegant explanation is
>
> Regex sees ''
>   Regex matches the null string at the first possible place.
>
> The part you fail to understand is that the first possible place is
> *between* the 'J' and the 'u'.  This is a special case with split that
> only applies to patterns that match the null string.

The part you fail to understand is that the first possible place is
*between* the first null and the 'J', as you can see here:

@arr = split/(?=J)/s, "Just another Perl Hacker\n";


> You just lost yourself a nickel.

No, I'm up 10 cents now. Thanks for your contribution! :)


> Nothing is being thrown out.  The first delimiter encountered is

Perl is throwing away the 'Just another Perl Hacker\n' element that should
be put on to the array just in front of the 'J' in:

@arr = split/(?=(.*))/s, "Just another Perl Hacker\n";


> Please get off this craxy mathematical parenthetical precedence kick.

I'd love to get off it. As I said before, I don't know how many times
I've said it, but apparently not enough: Regexes obey rules of
parenthetical precedence (I'll leave the 'mathematical' part off for you,
as that appears to throw others into a tizzy as well).


> It is completely at odds with left to right and backtracking.

It is completely harmonious with left to right processing and backtracking.
The proof is that Perl uses left to right processing and backtracking
to process regexes, and (sorry for this next bit) regexes in Perl obey
rules of parenthetical precedence.

Thanks again for the nickel! ;)

Patrick Timmins
U. Nebraska Medical Center

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


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

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

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