[13741] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1151 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 22 13:05:49 1999

Date: Fri, 22 Oct 1999 10:05:20 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940611919-v9-i1151@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 22 Oct 1999     Volume: 9 Number: 1151

Today's topics:
        A webbased mysql administration tools => Free download <gaoying@crosswinds.com>
        authentification with perl/cgi? <ak@dasburo.de>
    Re: bind invalid argument <tony@develop-help.com>
    Re: Card shuffling <andrew_lee@earthlink.net>
    Re: crypt function <ak@dasburo.de>
    Re: Displaying query results in a table format jdkronicz@my-deja.com
    Re: exiting non-zero at end of perl -[np] jrw32982@my-deja.com
    Re: Expr or block as 1st param: Compiler magic needed? <lr@hpl.hp.com>
    Re: Expr or block as 1st param: Compiler magic needed? <lr@hpl.hp.com>
    Re: file upload <lr@hpl.hp.com>
        How to cut away decimals <acacia@online.no>
    Re: How to round a number? (Tad McClellan)
    Re: Ignore the idiots <AgitatorsBand@yahoo.com>
    Re: Ignore the idiots (Greg Snow)
    Re: Ignore the idiots (Malcolm Ray)
    Re: in need of example... <AgitatorsBand@yahoo.com>
    Re: in need of example... <gellyfish@gellyfish.com>
    Re: in need of example... (Peter J. Kernan)
        Installation question (Henri Periat)
    Re: Is there a module to parse a HTML-file like this? <gellyfish@gellyfish.com>
    Re: Is there a module to parse a HTML-file like this? <MHasenoehrl@de.lhsgroup.de>
    Re: Mail::Send module doesn't work on NT <camerond@mail.uca.edu>
    Re: NEED URGENT HELP <kbandes@home.com>
    Re: New short cut assignment operators? <aqumsieh@matrox.com>
        Newbie needs help with script! Should be easy for an ex <CSRA@tci.telus.com>
    Re: Newbie: Chomp and Case Conversion on Input <kjetilskotheim@iname.com>
    Re: Passing function as parameter. <gellyfish@gellyfish.com>
    Re: Passing function as parameter. (Randal L. Schwartz)
    Re: Perl and NT IIS4 <tomd@istar.ca>
    Re: perl compile question - Solaris <james_peregrino@harvard.edu>
    Re: perl whith nt and schedular <c4jgurney@my-deja.com>
    Re: REFERENCE CHALLENGE: final (?) realref() test (Tramm Hudson)
    Re: stealing the news: how hard can it be? <camerond@mail.uca.edu>
    Re: Using "use strict" and "Getopt" together (Henri Periat)
    Re: Where is the c.l.p.m charter? <msalter@bestweb.net>
        XML::XSL (Kevin Scott)
    Re: XML::XSL <mamster@mamster.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 22 Oct 1999 11:54:08 -0700
From: Ying Gao <gaoying@crosswinds.com>
Subject: A webbased mysql administration tools => Free download
Message-Id: <3810B2D0.96503467@crosswinds.com>

Hi guys,
I have rewrite a webbased mysql administration tools.
You can download it from http://billow.cjb.net/
or(http://www.uwm.edu/~lqing/billow)

It is written in Perl. You can input your own sql command, create script
files and so on. Easy to install, easy to use.

Enjoy it.



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

Date: Fri, 22 Oct 1999 18:32:02 +0200
From: Alexander Knack <ak@dasburo.de>
Subject: authentification with perl/cgi?
Message-Id: <38109182.2D7C449A@dasburo.de>

hi,
i want a perl-CGI application to send an authorisationrequest to the
client.
i don't want to create a .htaccess file or something like this - the
perlscript
should handle the authentification. my problem is: i don't actually know
how
to do this. i've done something like this before in php3, but that
doesn't help
me much with perl/CGI/HTTP.
the code should look like:

use CGI;
my $uid = $ENV{REMOTE_USER};
my $passwd = $ENV{REMOTE_PASSWD};

if ($uid ne '' && $passwd ne '' && login($uid, $passwd) {
 print header(), start_html(), ....; # auth ok
}
else {
 print <the code that will induce the client(i.e. netscape) to popup the
authorisation-window>
}

Any ideas are highly appreciated
-- 
+--------------------------------------------------------------------+
| Alexander Knack  ........Entropie erfordert keine Wartung .........|
|  dasburo.de      ..................................................| 
+--------------------------------------------------------------------+


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

Date: Sat, 23 Oct 1999 00:22:35 +1000
From: Tony Cook <tony@develop-help.com>
Subject: Re: bind invalid argument
Message-Id: <3810732B.3B75F2E0@develop-help.com>

simon wrote:
> 
> Hi,
> 
> I'm trying out a client/server model utilizing stream sockets for
> communication
> using both client and server on the same machine, and the client
> simply reads a greating message from server and prints on screen.
> 
> This is a very simple program yet I couldn't seem to figure out what's
> wrong with it.
> 
> I got "Invalid argument" when I try to bind the sock to the file e.g.
> 
> Server Started
> Socket OK
> Bind Invalid argument
> 
> I try it on both Linux and Solaris with same result. I'm using
> perl, version 5.004_04.
> 
> $addr="127.0.0.1";
> #bind(SERVERSOCKET,$name) || die "Bind $!\n";
> bind(SERVERSOCKET,"$addr") || die "Bind $!\n";

The argument to bind needs to be a packed sockaddr_in (think of it as an
internet socket address), the simplest way to produce this is with
sockaddr_in() from Socket.pm.

use Socket;
$sin = sockaddr_in($port, inet_aton($addr));
bind(SERVERSOCKET, $sin) or die "Bind $!";


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

Date: Fri, 22 Oct 1999 12:07:52 -0400
From: andrew_lee <andrew_lee@earthlink.net>
Subject: Re: Card shuffling
Message-Id: <38108BD7.4915FA02@earthlink.net>

Mikko Saari wrote:

> I need a perl script to handle decks of cards. My first and most obvious
> problem is shuffling, a problem which has bothered me previously. How do I
> arrange an array in random order?
>

I am assuming that your issue is one of finding a 'good' random number
generator.

Here is a listing for the Miller/Park PRNG in C ....

const long  IA =  16807;
const long  IM =  2147483647;
const float AM =  (1.0/IM);
const long  IQ =  127773;
const long  IR =  2836;
const long  MASK = 123459876;

float fRandom(long *lSeed);
int nRandom(unsigned range, long *lSeed);
long lRandom(unsigned long range, long *lSeed);

float fRandom(long *lSeed)
{
  long i;
  float RetVal;

  if (*lSeed == 0L)
  // BIG ERROR!!!
  *lSeed = 3145L;    // very random! :-)

  *lSeed ^= MASK;
  i = (long)(*lSeed)/IQ;
  *lSeed = IA*(*lSeed - i*IQ) - IR*i;
  if (*lSeed < 0L)
    *lSeed += IM;
  RetVal = AM*(*lSeed);
  *lSeed ^= MASK;

 return RetVal;
}

int nRandom(unsigned range, long *lSeed)
{
 float RetVal = fRandom(lSeed);
 return ( (int)(RetVal * ~0) % range );
}

long lRandom(unsigned long range, long *lSeed)
{
 float RetVal = fRandom(lSeed);
 return ( (long) (RetVal * ~0L) % range );
}


Some compilers puke at "RetVal * ~0", you can always set BigInt = ~0;

I have a Perl listing of the same, but truthfully it is faster to compile this
and call it.


>
> --
> --
>     for more info                                            msaari
>     finger msaari@tukki.jyu.fi                               @jyu.fi
>     262          "quantum physics: the dreams that stuff is made of"




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

Date: Fri, 22 Oct 1999 18:42:41 +0200
From: Alexander Knack <ak@dasburo.de>
To: Mohd Idaham <techam@tm.net.my>
Subject: Re: crypt function
Message-Id: <38109401.2AB4AC0E@dasburo.de>

Mohd Idaham wrote:
> 
> Hi everyone,
> Below is a part of my perl program:
> 
> $salt = substr($etcpasswd, 0, 2);
> if (crypt($userentered, $salt) ne $etcpasswd) {
>         die "Sorry...\n";
>   } else {
>     print "ok\n";
> }
> 
> This program will compare the entered password and the password inside
> /etc/passwd. Eg: Assume the /etc/passwd value is hello99.
> If user entered hello99123 or hello99bla..bla... the program will accept and
> print ok.
> 
> Can anybody tell me why and how to overcome this.
not exactly, but
1) passwords unter unix are max 8 chars long (hello99 are 7, i know ...)
2) use if (crypt($userentered, $etcpasswd) ne $etcpasswd)) {
instead of what you've did above.

Greetings
-- 
+--------------------------------------------------------------------+
| Alexander Knack  ........Entropie erfordert keine Wartung .........|
|  dasburo.de      ..................................................| 
+--------------------------------------------------------------------+


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

Date: Fri, 22 Oct 1999 16:33:21 GMT
From: jdkronicz@my-deja.com
Subject: Re: Displaying query results in a table format
Message-Id: <7uq3kh$4hd$1@nnrp1.deja.com>

Thanks for the reply Gordon.  I tried it and it worked fine.
JD

In article <36453.53009810B5F8justooltries@4.22.39.85>,
  justarious@hotmail.com (Gordon) wrote:
> jdkronicz@my-deja.com wrote in <7ul3st$jf7$1@nnrp1.deja.com>:
>
> >Hi I am trying to create a CGI to an Access
> >Database.  I want to be able to
> >display the results of the Select in a
> >HTML table but I am having trouble.
> >The following lines of code illustrate
> >what I am trying to do.     The select
> >statement returns two fields from the table.
> >Could someone tell me what I
> >need to do differently?
> >
> >....dbi stuff up here.......... use CGI;
> >$q=new CGI; print start_html; print
> >$q->table({-border}, where(@row=fetchrow_array)
> >{$q->TR($q->td($row[0],
> >$row[1])});
> >
>
> I'm sure there is a better way, but perhaps something
> like this might help you if you are using DBI:
>
> $sth = $your_database_handle->prepare($your_query) || die DBI->errstr;
> print "<tr><td>$row[0]</td><td>$row[1]</td></tr>"
>   while (@row = $sth->fetchrow_array);
>
> perhaps take a look at perldoc DBI
>
> hope this helps
>
> -- Gordon --
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 22 Oct 1999 15:40:57 GMT
From: jrw32982@my-deja.com
Subject: Re: exiting non-zero at end of perl -[np]
Message-Id: <7uq0i8$299$1@nnrp1.deja.com>

In article <7uo2tt$rf8$1@fcnews.fc.hp.com>,
  neutron@fc.hp.com (Jack Applin) wrote:
> The perlvar man page states:
>
> 	Inside an END subroutine $? contains the value that is going
> 	to be given to exit().  You can modify $? in an END subroutine
> 	to change the exit status of the script.

Thanks, Jack!  You're right.

Unfortunately, this points out a real problem -- I scoured the Camel
book for any information (looked under exit, special variables, die,
 ...).  But, it's not there!  I have the 9/96 second edition of Camel.

The online man page gives exactly the right information.  However,
anyone (like me) who relies on the book only is going to lose.  I guess
I'm about ready to pitch the book.  What do people find the book good
for?

I've always found the online doc hard to use.  I like the way tcl's
online html doc is organized: a main page which lists every tcl builtin
plus a few general entries with a link to a separate page for each
entry.  But to get to any entry for a specific function in the perl
html doc takes several clicks, so I usually find it easier to just look
it up in the Camel.

John Wiersba


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 22 Oct 1999 09:46:24 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Expr or block as 1st param: Compiler magic needed?
Message-Id: <MPG.127a34beb88a1dac98a0f9@nntp.hpl.hp.com>

In article <7upm81$pop$1@lublin.zrz.tu-berlin.de> on 22 Oct 1999 
12:44:49 -0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> says...
> Alan Curry <pacman@defiant.cqc.com> wrote in comp.lang.perl.misc:
> >In article <MPG.127907c3b909876598a0ec@nntp.hpl.hp.com>,
> >Larry Rosler  <lr@hpl.hp.com> wrote:
> >>print any_expr_or_block(qw(foo foobar)), "\n";
> >>print any_expr_or_block(qw(foo baz)), "\n";
> >>print any_expr_or_block(sub { /foo/ }, qw(foobar)), "\n";
> >>print any_expr_or_block(sub { /foo/ }, qw(baz)), "\n";
> >
> >But that's not like grep. With grep, you can omit the "sub" keyword before
> >your anonymous sub. That's the compiler magic.
> 
> you can get that with prototypes:
> 
>   sub any_expr_or_block (&@);

But then the function fails if given a scalar argument.

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


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

Date: Fri, 22 Oct 1999 09:58:05 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Expr or block as 1st param: Compiler magic needed?
Message-Id: <MPG.127a37736bc8caee98a0fb@nntp.hpl.hp.com>

In article <7upmjs$pq9$1@lublin.zrz.tu-berlin.de> on 22 Oct 1999 
12:51:08 -0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> says...
+ Larry Rosler  <lr@hpl.hp.com> wrote in comp.lang.perl.misc:

 ...

+ >#!perl -w
+ >use strict;
+ >
+ >  sub any_expr_or_block {
+ >    defined(my $match = shift) or
+ >        die "\nNo first argument.\n"; 
+ >    unless (ref $match) {
+ >        foreach (@_) { return 1 if m/$match/; }
+ >    } elsif (ref $match eq 'CODE') {
+ >        foreach (@_) { return 1 if &$match; }
+ >    } else {
+ >        die "\nFirst argument must be an expr or a block.\n" 
+ >    }
+ >    return 0;
+ >  }
+ >
+ >print any_expr_or_block(qw(foo foobar)), "\n";
+ >print any_expr_or_block(qw(foo baz)), "\n";
+ >print any_expr_or_block(sub { /foo/ }, qw(foobar)), "\n";
+ >print any_expr_or_block(sub { /foo/ }, qw(baz)), "\n";
+ 
+ print any_expr_or_block(sub { $_[0] eq 'bar' }, qw( foo bar)); # ?
+ 
+ The call to &$match should probably be &$match( $_).

I don't understand the purpose of this change.  $_ is nothing special at 

the point that &$match is called.

On the other hand, invoking the code in the block as simply &$match 
gives it access to the remaining arguments to the funciton 
any_expr_or_block.  So "$_[0] eq 'bar'" would fail and "$_[1] eq 'bar'" 
would succeed.  In essence, the code in the block is being executed as a 

subroutine, with the following arguments as its arguments.  That is 
rather cool, I think!

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


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

Date: Fri, 22 Oct 1999 09:41:09 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: file upload
Message-Id: <MPG.127a3384c3646afd98a0f8@nntp.hpl.hp.com>

In article <7uo8k4$euc$1@fir.prod.itd.earthlink.net> on Thu, 21 Oct 1999 
18:44:26 -0500, Blair Heuer <ab@cd.com> says...
> > You have to use binmode before you do any reading or writing to your
> files.
> >
> > open INFILE, "<$myfile";
> >
> > binmode(INFILE);
> 
> Now do I only use this if it is a binary file then? Sounds dumb even as I
> ask it, but i must know. This script is not only used for pictures... it is
> used for all files, I had just noticed how it messed up the pictures.
> 
> Should i do a statement like:
> 
> if (-B $myfile) { binmode(INFILE); }

That is a weak heuristic, even weaker for text files that may contain 
Latin-1 characters from the upper half of the code table.

There are other clues -- MIME types and filename suffixes.

> or will it work for both text and binary?

A Unix text file transfered as binary to Windows/DOS will work fine with 
many text editors (not including Notepad) and with Perl.

A Windows/DOS text file transfered as binary to Unix will have trailing 
CRs before the LFs.  It will look odd with many text editors, and the #! 
line may be misinterpreted by Perl.

I don't have a reliable answer to your question -- ya' pays yer money 
and ya' takes yer cherce (my Brooklyn upbringing coming throush :-).

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


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

Date: Fri, 22 Oct 1999 18:56:11 +0100
From: "Acacia" <acacia@online.no>
Subject: How to cut away decimals
Message-Id: <BE0Q3.9155$7G2.52963@news1.online.no>

I've checked the faq's, and could only find stuff about rounding the
numbers...
I need to cut away all decimals of any given number without rounding...
for instance,
32.951251 --> 32

does this have anything to do with int() ?

any help will be greatly appreciated.
acacia




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

Date: Fri, 22 Oct 1999 05:03:13 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How to round a number?
Message-Id: <h89pu7.291.ln@magna.metronet.com>

Francois Dupradeau (fyd@u-picardie.fr) wrote:

: Is there a function in Perl to round off


   Perl FAQ, part 4:

      "Does perl have a round function?  
       What about ceil() and floor()?  
       Trig functions?"


   You are expected to check the Perl FAQ *before* posting
   to the Perl newsgroup you know.



: Thanks

   Uh huh.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 22 Oct 1999 14:55:09 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: Ignore the idiots
Message-Id: <hV_P3.995$LR3.176491@news.shore.net>

Greg Snow <snow@statsci.com> wrote:
: And when the newbies asked FAQ's, what would happen?  would the recent
: newbies refer them to the FAQ making the new group no different than the
: current one.

Actually, if they were merely referred to the FAQ rather than being
insulted as a waste of DNA and an insult to humanity, that would be a
refreshing change from the current group.

--Art

-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: 22 Oct 1999 16:39:44 GMT
From: snow@statsci.com (Greg Snow)
Subject: Re: Ignore the idiots
Message-Id: <7uq40g$ect$1@junior.statsci.com>

In article <38101e37_2@newsread3.dircon.co.uk>,
Jonathan Stowe  <gellyfish@gellyfish.com> wrote:
>Greg Snow <snow@statsci.com> wrote:
>>            here are some suggestions for getting positive rather than
>> negative feedback:
>> 
>> * State you expertise, or lack thereof.  A statement like "I'm not an
>> expert yet, but I think this will work"  
>> 
>
>I dont believe we want any stuff posted that people only 'think' might
>work - if you dont 'know' it works dont post it - there are confused
>newbies cutting and pasting broken cargo cult code as it is and I dont
>think that we should do anything to make this worse.

Good point, I phrased that poorly, how about if it is changed to:

 ... a statement like "I'm not an expert yet, this soulution works
for the example you gave, however there may be other solutions that are
faster/more elegant/easier to understand/won't break on situations more
complex than your example/etc."



-- 
-------------------------------------------------------------------------------
     Gregory L. Snow         |  Inertia makes the world go round,
     (Greg)                  |   Love makes the trip worth taking.
     snow@statsci.com        |


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

Date: 22 Oct 1999 16:57:08 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Ignore the idiots
Message-Id: <slrn8115r4.fcq.M.Ray@carlova.ulcc.ac.uk>

On 21 Oct 1999 16:32:32 GMT, Greg Snow <snow@statsci.com> wrote:
>In article <slrn80s1k1.6vb.M.Ray@carlova.ulcc.ac.uk>,
>Malcolm Ray <M.Ray@ulcc.ac.uk> wrote:
>>
>>Stop right there!  While I agree with most of what you say, I think
>>you're falling into a trap here.  This classification of clpm posters
>>into 'newbies' and 'experts' is, IMO, something of a straw man put
>>forward by those guilty of the sin of False Laziness.  It allows them
>>to accuse clpm of elitism, 
>
>So, did I fall into the trap, or do the people that suggest a seperate
>group just for experts fall into the trap.

Both, I think.  I'm convinced that splitting the group is not the
answer (though the recurring idea of creating clp.cgi *might* work).
But my point is that this newbies vs experts distinction is largely a
red herring.  In clpm, the word 'expert' is mainly used by FAQ-askers,
and in this usage appears to mean 'someone who reads documentation'.
Those of us who don't accept that definition can't stop them using
the word that way, but we don't need to join in.

That's all I'm going to say, because this discussion has been repeated
a million times in clpm, and I'm sure nothing new has been said on the
subject for years...
-- 
Malcolm Ray                           University of London Computer Centre


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

Date: Fri, 22 Oct 1999 14:59:00 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: in need of example...
Message-Id: <UY_P3.997$LR3.176491@news.shore.net>

Brett W. McCoy <bmccoy@foiservices.com> wrote:
: For the benefit of writing portable (and secure) code, using the Perl
: supplied functions (or modules, if your an OOP geek :-) ) is safer.  What
: if they don't have ls on their system?

He specified that he was running Linux.

--Art

-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: 22 Oct 1999 16:11:43 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: in need of example...
Message-Id: <38107eaf_1@newsread3.dircon.co.uk>

Erik van Roode <newsposter@cthulhu.demon.nl> wrote:
> Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> 
>> But the original poster explicitly said that he was using Linux - which
>> last time I looked had a program ls in its path ...
> 
>> The newline is trivially dealt with:
> 
>> chomp(my @files = `ls *.jpg *.gif`);
> 
> I know that ...
> 

Sure you do. 

>> Of course one generally would recommend using opendir/readdir but there's
>> no point in being dogmatic about it ...
> 
>   Ofcourse, the answer should have mentioned: "this only works on
> machines running some flavor of unix". The point I'm trying to make
> is that it's better to use code that is not platform dependant.


But the original question was:

Jeremiah Stanley <miah@idcomm.com> wrote:
>> Newbie here.
>>
>> Can anyone send me in the direction of a good example of listing and sorting
>> directories under Linux?

Whats your problem that you insist on denying that was the original question

> Fortunately most newbies don't seem to read this group so they
> don't get the wrong ideas.
> 

I dont understand what you are saying here ...

/J\
-- 
"It's easier for a man to enter a camel is he stands on a box" -
Jonathan Creek


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

Date: 22 Oct 1999 15:59:20 GMT
From: pete@theory2.phys.cwru.edu (Peter J. Kernan)
Subject: Re: in need of example...
Message-Id: <slrn8112eo.et8.pete@theory2.phys.cwru.edu>

On 22 Oct 1999 06:34:43 -0700, 
  Randal L. Schwartz <merlyn@stonehenge.com> wrote:
 .=1) what if there's a directory named "foo.jpg" in the current directory?
 ...

 .=Yes there is, when it leads to expensive and potentially dangerous
 .=solutions.  And the proper solution is FEWER keystrokes, thus also
 .=winning Perl golf.
 .=
 .=  my @files = <*.jpg *.gif>;
 .=
 .=Simple and plain, but doesn't handle item #3 above.  For that, you
 .=gotta use readdir.

 and to avoid 1)

    my @files = grep -f,<*.jpg *.gif>;

-- 
  Pete


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

Date: 22 Oct 1999 14:52:56 GMT
From: eperh@ens.ascom.ch (Henri Periat)
Subject: Installation question
Message-Id: <7upto8$l2e$1@ascomax.hasler.ascom.ch>
Keywords: install, modules


Hi everybody

I'm going to install Perl 5.005 son.
Perl it self will be installed in '/usr/local'. But when i install a module
i want to decide whether it should be installed in '/usr/local' or in '/foo'.
When i run Perl it should look first in '/foo' and then in '/usr/local' for
the requested module, without any additional options in the '#!' line.
I have studied the README, the INSTALL and the FAQ's but couldn't find any
hint, maybe someone of you can help, even to tell me that this is not possible.


Thanks a lot
Henri



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

Date: 22 Oct 1999 15:53:55 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Is there a module to parse a HTML-file like this?
Message-Id: <38107a83_1@newsread3.dircon.co.uk>

Markus Hasenöhrl <MHasenoehrl@de.lhsgroup.de> wrote:
> Hello!
> 
> I'am looking for a simple way to extract links from a HTML-file in such a
> way that a Text/HREF- hash is build, i.e. from a HTML file containing links
> like

HTML::LinkExtor ....

/J\
-- 
"Two or three of our staff were stoned on their way to work" - British
Airways Spokesman


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

Date: Fri, 22 Oct 1999 18:53:28 +0200
From: "Markus Hasenöhrl" <MHasenoehrl@de.lhsgroup.de>
Subject: Re: Is there a module to parse a HTML-file like this?
Message-Id: <38109690@news.lhsgroup.com>

Hello again!

As far as I understand it, HTML::LinkExtor does not do exactly what I want.
Ok - it finds the links but how do I set up a callback to assciate the TEXT
of the link with the HREF?
I mean, whenever HTML::LinkExtor sees a construct like

<A HREF=/location1>text1</A>

it calls a callback having seen the <A ...> but BEFORE it has seen the
"text1" or am I wrong?

Could you please provide me with a concrete example of how to achive that
with HTML::LinkExtor ?

Many thanks!

Jonathan Stowe wrote in message <38107a83_1@newsread3.dircon.co.uk>...
>Markus Hasenöhrl <MHasenoehrl@de.lhsgroup.de> wrote:
>> Hello!
>>
>> I'am looking for a simple way to extract links from a HTML-file in such a
>> way that a Text/HREF- hash is build, i.e. from a HTML file containing
links
>> like
>
>HTML::LinkExtor ....
>
>/J\
>--
>"Two or three of our staff were stoned on their way to work" - British
>Airways Spokesman




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

Date: Fri, 22 Oct 1999 09:27:28 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Mail::Send module doesn't work on NT
Message-Id: <38107450.1C368324@mail.uca.edu>

JAG wrote:
> 
> In article <380FA0C0.9320599C@compaq.com>,
>   Abdoulaye Fofana <abdoulaye.fofana@compaq.com> wrote:
> > Does anybody know any other  mail module for Perl on NT or a way to
> > programmatically send a mail with Perl on NT.
> 
> If you read the ActiveState FAQ, it tells you that you need a command
> line tool for sending mail from WinNT. I recommend that you get a copy
> of BLAT from Tim Charron at http://www.interlog.com/~tcharron/blat.html

No, it doesn't. You must have an extremely old version of Perl (5.003 or
earlier). To quote from the FAQ (perlwin32faq4):

	How do I send email from Perl for Win32?

	You may come across scripts that send email with an external mail
program, as in: [details snipped]

	These sort of scripts generally cause people to ask, ``is there a
sendmail equivalent on Windows?'' If you need to send email from a Perl
script, there is no need to use an external program like sendmail. The
libnet bundle includes Net::SMTP, a module that can be used to send
mail. Here is an example: 

        use Net::SMTP; [details snipped]

	Another alternative is Mail::Sender, which can be used like so: 

        use Mail::Sender; [details snipped]

	Or Mail::Sendmail, which can be used like this: 

        use Mail::Sendmail; [details snipped]

	A Perl script for sending mail without using an external program is
also available on Robin Chatterjee's Perl for Win32 page (see Are there
information sources available on Perl for Win32 on the World Wide Web?). 

	If you really need a sendmail equivalent for Windows, several such
equivalents exist: 

	Blat [details snipped]

	sendmail [details snipped]

	A commercial sendmail product is available from MetaInfo, Inc. An
evaluation version is available at http://www.metainfo.com/ 

	Another commercial mail product is wrmail, part of the slmail product
from Seattle Labs. A free version is available at
http://www.seattlelab.com/ 
 ------------------------------
So there are several alternatives, the least recommended of them is the
command-line stuff, and right behind that is Blat (really a Perl4
program, I believe).

My favorites are Mail::Sender (for mail with attachments) and
Mail::Sendmail (for mail without attachments). They are both very easy
to use.


Cameron
-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu


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

Date: Fri, 22 Oct 1999 12:22:05 -0400
From: Kenneth Bandes <kbandes@home.com>
Subject: Re: NEED URGENT HELP
Message-Id: <38108F2D.2DDBD079@home.com>

Kent Perrier wrote:
> > Do you know what barbecue sauce goes best with penguin?
> >
> > I can't find a good one.
> 
> Probably the same one that tastes real good with Spotted Owl.

Arthur Bryant's.  http://www.rbjb.com/rbjb/ab2.htm.  I haven't 
actually tried it with Penguin, however...

Ken Bandes


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

Date: Fri, 22 Oct 1999 10:52:11 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: New short cut assignment operators?
Message-Id: <x3yln8v8n3b.fsf@tigre.matrox.com>


email55555@aol.com (Email55555) writes:

> For example :
>   We have $a -= $b; which is like $a = $a - $b;
>   And for $a = $b - $a; why not $a =- $b;

Because this will make it very hard to distinguish between:

	$a =- $b (which means $a = $a - $b)
and
	$a = -$b (which means $a = -$b)

Besides, there is a simple solution:  $a += -$b

> Another example : 
>   $a .= $b; ( it's like $a = $a . $b; )
>   Why not $a =. $b; (it's like $a = $b . $a; )
>   ... etc  
> 
> The space (or newline) between operator and operant is important to avoid
> ambiguity,

Yes, which makes life VERY HARD and defeats the whole purpose of those
new operators (which I guess was to make life a bit simpler). If you
want to know the agony of significant whitespace, then you should try
Python for a while, which gives a whole new meaning to the term
"cut-and-paste". 

If you misplace a space character by mistake, then you'll create a bug
that is impossible to track down.

Is it worth it?

> We already have this situation in Perl for operator x= .
> e.g.: $ax=4; is not the same as $a x=4; 

This is different. The space here is necessary to disambiguate the
name of the variable and not confuse it with the 'x' operator. This is
the same reason why you need spaces in:

	$a cmp $b    ($acmp$b looks ridiculous)

> If we accept operator =- , that means $a=-3; ( same as $a = -3;) is
> not same as 
> $a =- 3; 

Ok. So what would '$a=-3' exactly mean?

> ( I hope there are not very many programmers who use this kind of
> style :-) )  
> ( Note: you can't write $a =. 3; ==> compilation error. )

Can you imagine the amount of confusion this could potentially create?
It will also break a lot of existing programs.

> The choice of writing is open, maybe not =-, =/, =., =||, =&& ... etc maybe
> !-=, !/=, !.=, ...etc or ...
> 
> I do not want to complicate Perl, I'm just curious.  If we invented -=, /=,
> ...etc. 
> Why not the same for the converse? 

Those were invented for efficiency reasons.

	'$x += $y' is faster than '$x = $x + $y'.

> (Note: I often have the code like this, $a = $b . $a; so the shortcut maybe
> useful in this situation. )

You can use substr(), which should be faster (no benchmarks though).

HTH,
--Ala



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

Date: 22 Oct 1999 16:47:25 GMT
From: "CSRA" <CSRA@tci.telus.com>
Subject: Newbie needs help with script! Should be easy for an expert.
Message-Id: <01bf1cad$261fa030$54b2b28e@M26160>

Hi.
This is my first time posting to this ng.
I just started programming perl and I am already in trouble.
I need help with the following problem

I need a script that scans a .txt file for an a character X then writes
the previous 3 characters to a file.
So basically I want to be able to scan through the entire document and
every time an 'X' shows up, I want the previous 3 characters written to a
file.
The source file would appear as such:

Hello_my_name_is_MrX.
I_am_very_pleased_to_meet_you_X.
I_have_excommunicated_you

So the new file when done would look something like this. I want the
spacing in the new file equal and on the same line. its going to be
imported into a database so
I need the spacing right. (That is 2 spaces between writes)

_Mr _ou  e_e


Can anyone help me out with this? I managed to successfully mess around
with files and grep and reading and writing arguments but cant put it
together. I dont have any perl books other than the web (which I am
searching as I type this.)
Any help would be appreciated.

My email
Foghorn@NOSPAM.Telusplanet.net

Thanks.



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

Date: Fri, 22 Oct 1999 18:53:49 +0200
From: Kjetil Skotheim <kjetilskotheim@iname.com>
Subject: Re: Newbie: Chomp and Case Conversion on Input
Message-Id: <3810A4AC.5FC48728@iname.com>

"Michael W. Fleming" wrote:

> If there is a way, how would I compose a single statement that
> accomplishes the same function as the following two statements?
>
> chomp($line=<STDIN>;
> $line =~ tr/A-Z/a-z/;

Maybe:
chomp($line=lc(<STDIN>));


>
>
> Would the same solution work for @lines=<STDIN>?

@lines=map{chomp;lc}<STDIN>;



>
>
> Thanks.
>
> Michael
>
> --
> Michael W. Fleming, Network Analyst, California State University
> Voice/mail:(661)664-2118 (24hrs)  Fax:(661)664-2099 (24hrs)
> Disclaimer: I directly represent only myself and my family;
>             indirectly, I represent God and all His creation.



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

Date: 22 Oct 1999 15:55:58 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Passing function as parameter.
Message-Id: <38107afe_1@newsread3.dircon.co.uk>

xxaxx@my-deja.com wrote:
> 
> Since I'm basically self-taught in PERL it is extremely easy to not know
> about very useful references and existing functions. That is one of the
> unfortunate aspects of not having formal training in a subject ....

Hey I would suggest that the majority of the folk here never had any
formal training in Perl ...

/J\
-- 
"While they're pumping, you're soaking them" - Speed Loader TV Advert


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

Date: 22 Oct 1999 08:31:25 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Passing function as parameter.
Message-Id: <m11zanbeeq.fsf@halfdome.holdit.com>

>>>>> "Jonathan" == Jonathan Stowe <gellyfish@gellyfish.com> writes:

Jonathan> Hey I would suggest that the majority of the folk here never
Jonathan> had any formal training in Perl ...

I've never had formal training in Perl. :)

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


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

Date: Fri, 22 Oct 1999 14:47:13 GMT
From: "Tom Dawson" <tomd@istar.ca>
Subject: Re: Perl and NT IIS4
Message-Id: <RN_P3.8305$G6.741016@news0.telusplanet.net>

Thanks Jonathan, one of the group sent me a note via email and he was very
helpful. We solved the problem and it works....

I appreciate these kinds of groups as they are a great source of assistance
to someone like me.

Tom

Jonathan Stowe wrote in message

>Download and install the latest ActivePerl from
<http://www.activestate.com>
>and then read the instructions in the documentation installed regarding
>configuring the server to work with Perl.
>
>Further IIS questions should be directed to the group
>
>   comp.infosystems.www.servers.ms-windows
>
>
>/J\
>--
>"You're blowing me off for a monkey?" - Joey, Friends




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

Date: 22 Oct 1999 10:38:02 -0400
From: James Peregrino <james_peregrino@harvard.edu>
Subject: Re: perl compile question - Solaris
Message-Id: <x7aepbcvg5.fsf@bert.dce.harvard.edu>

What you did was okay.  By doing distclean after you moved /etc/ar out of the
way means Perl doesn't know about it anymore.  And certainly the fact that
it passed 'make test' proves that.

If Perl needs to use 'ar' (I don't think it does, but when installing Perl
modules it could) it now knows the the proper location /usr/ccs/bin/ar.

You may run into future trouble trying to compile other software which needs
ar.

Reminds me of the time I tried to write a script called "test" and could never
get it to run because my shell thought I meant the builtin command 'test'.

-James


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

Date: Fri, 22 Oct 1999 14:29:00 GMT
From: Jeremy Gurney <c4jgurney@my-deja.com>
Subject: Re: perl whith nt and schedular
Message-Id: <7upsb7$ute$1@nnrp1.deja.com>

In article <3810157F.6E4F5EA7@bmw.de>,
  Manuel Schicktanz <Manuel.Schicktanz@bmw.de> wrote:
> Hi,
>
> I use a perl-Script under NT.
> It uses Win:OLE to start an Application, load some Files and at the
end
> I save the result.
> It works fine.
> BUT if I try to run my Script with the Schedular I can't Load the
Files
> (I use Absolut Path only).
> What is wrong?

If your scheduler is running as a service then you have a problem - NT
services can either have access to OLE (if running under the localsystem
account) or network access (if running under a user account).

Jeremy Gurney
SAS Programmer  |  Proteus Molecular Design Ltd.
"What if there were no hypothetical situations?"


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 22 Oct 1999 10:19:14 -0600
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: REFERENCE CHALLENGE: final (?) realref() test
Message-Id: <7uq2q2$8tr@llama.swcp.com>

[posted and cc'd to cited author]

Jeff Pinyan  <japhy@pobox.com> wrote:
> Following is a test of two realref() functions that I have found to work
> perfectly.  The realref2 function uses no regular expressions, while
> realref1 does.  I've found realref2 to be just a bit faster on my machine.
> 
> If people would like to try for themselves, go right ahead.  Report any
> bugs you find.  I'll be happy to send along documentation to anyone
> curious enough.

Here is a case that causes it to fail:

{
	package Overloaded;
	use overload q{""} => sub { 'FOOBARTYPE' };
}

my $bar = bless {}, 'Overloaded';
print "bar is a $bar, but realref1=", realref1 $bar,
	" realref2=", realref2 $bar, "\n";
__END__

Fails with the output:

"bar is a FOOBARTYPE, but realref1=  realref2=FOOBA"

instead of the correct answer of HASH.

Tramm
-- 
  o   hudson@swcp.com                 tbhudso@cs.sandia.gov   O___|   
 /|\  http://www.swcp.com/~hudson/          H 505.323.38.81   /\  \_  
 <<   KC5RNF @ N5YYF.NM.AMPR.ORG            W 505.284.24.32   \ \/\_\  
  0                                                            U \_  | 


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

Date: Fri, 22 Oct 1999 09:34:04 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
To: Michel Dalle <michel.dalle@usa.net>
Subject: Re: stealing the news: how hard can it be?
Message-Id: <381075DC.25BBF847@mail.uca.edu>

[cc'd to md]

Michel Dalle wrote:
> 
> In article <7uo0ai$lvj$1@nnrp1.deja.com>, dsparling <dsparling@my-deja.com> wrote:
> [snip]
> >Sent via Deja.com http://www.deja.com/
> >Before you buy.
> 
> Now why would I want to buy Deja.com ?

<Universal truth ;) > Anything with a .com in its name is automatically
a good investment, especially if you can buy the whole thing.
</Universal truth ;) >

Cameron

-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu


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

Date: 22 Oct 1999 15:23:40 GMT
From: eperh@ens.ascom.ch (Henri Periat)
Subject: Re: Using "use strict" and "Getopt" together
Message-Id: <7upvhs$l2e$2@ascomax.hasler.ascom.ch>

In article <7upe2g$l0d$1@nnrp1.deja.com>, c_j_marshall@my-deja.com writes:
>Hi,
>
>I've been perling for a couple of years now - and I try to be a good boy
>and use 'use strict' all the time.
>
>But for the life of me I have been unable to get a clean compile and
>working code whenever I use the Getopt module (which I am fairly reliant
>on).
>
>The only clean compile I have managed is below - but it seems to lose
>the value of the option for me.
>
>Any ideas ?
>
>(p.s. extra bonus points if you manage not to use the word 'lexical' in
>the answer :-)
>
>Cheers
>Chris
>
>
>#!/dvlp/gnu/SunOS5/perl/V5.004/bin/perl -w
>
>use Getopt::Std;
>
>use strict;
>use diagnostics;
>
>my $opt_d = "";

Don't write the line above.

>
>if (!getopts('d:'))
>{
>        print "Usage: UserGroup.pl -d\n";
>        print "       -d Do something clever and useful.\n";
>}
>
>print "opt_d:$opt_d:\n";

print "opt_d:$Getopt::Std::opt_d\n";

>
>
>And when I run it:
>
>% ./Test.pl -d fred
>opt_d::
>

With the code above Perl tells you:
Name "Getopt::Std::opt_d" used only once: possible typo at ...

To avoid that i usually add 'undef $Getopt::Std::opt_d;' at the end.


Henri



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

Date: Fri, 22 Oct 1999 14:20:14 GMT
From: Mike Salter <msalter@bestweb.net>
Subject: Re: Where is the c.l.p.m charter?
Message-Id: <Pine.BSF.4.05.9910221018040.16398-100000@monet.bestweb.net>



On 21 Oct 1999, Randal L. Schwartz wrote:

RLS>>>>>> "Mike" == Mike Salter <msalter@bestweb.net> writes:
RLS>
RLS>Mike> <2 cents>
RLS>
RLS>Mike> Since this is an unmoderated group, it might help if guidelines for this
RLS>Mike> group, as well as url's to FAQs and other sites were posted once a month
RLS>Mike> for users new to this group.
RLS>Mike> </2 cents>
RLS>
RLS>You mean, besides the FAQ that gets posted EVERY THREE DAYS by gnat?
RLS>And sent to every new user besides?
RLS>
RLS>And the Perl Mini-FAQ that gets posted *weekly* to comp.lang.perl.announce?
RLS>
RLS>You want to reduce that from EVERY THREE DAYS down to a month?  Why?
RLS>

As I stated in a followup, I am having difficulty with my news server, and
have not seen a FAQ in this group.  I have seen the same old posts come up
time after time, after having already read them.  My intent was not to
change the frequency of posts that I am obviously not getting.

I appologize to the group for the confusion.

Mike





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

Date: 22 Oct 1999 15:05:36 GMT
From: johnDoe@noSpamToday.com (Kevin Scott)
Subject: XML::XSL
Message-Id: <A6B0B814FF39B51B.A367C794B86F22FC.83FD33CE6C6DE02C@lp.airnews.net>

Has anyone come a across any perl that can take an XML file and apply a XSL 
styleseet to it and return the resulting document.  This would be used to 
convert an XML document to HTML for excample.


Kevin Scott



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

Date: Fri, 22 Oct 1999 08:54:15 -0700
From: Matthew Amster-Burton <mamster@mamster.net>
Subject: Re: XML::XSL
Message-Id: <381088A7.E45DC4CD@mamster.net>

Kevin Scott wrote:

> Has anyone come a across any perl that can take an XML file and apply a XSL
> styleseet to it and return the resulting document.  This would be used to
> convert an XML document to HTML for excample.

Yes, XML::XSLT is at

http://www.sci.kun.nl/sigma/Persoonlijk/egonw/xslt/

I haven't tried it, so no idea how well it works.  If you don't care
whether Perl handles the parsing, just use XT.

Matthew


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 1151
**************************************


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