[15840] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3253 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 5 09:05:25 2000

Date: Mon, 5 Jun 2000 06:05:10 -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: <960210310-v9-i3253@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 5 Jun 2000     Volume: 9 Number: 3253

Today's topics:
    Re: 3 questions about perl (Bart Lateur)
        embedded macros <daniel.heiserer@bmw.de>
        RE: error compiling Perl with HP-UX 11 (H. Merijn Brand)
        execute/include script from another <dragon@online.no>
    Re: floating point algorithm bug in perl 5.6.0? (Bart Lateur)
    Re: getpwnam and Shadow Passwords (Andreas Kahari)
    Re: getpwnam and Shadow Passwords <blah@nospam.com>
        help me to undestand this syntax!! <arun67@yahoo.com>
    Re: help me to undestand this syntax!! (Thorfinn)
    Re: help me to undestand this syntax!! <alfonso.palacios-sureda@alcatel.fr>
    Re: How to open another windows? <bill.kemp@wire2.com>
    Re: HTML on a local server (Andreas Kahari)
        NET::SMTP sends to nowhere <tschilbach@aodinc.com>
    Re: NET::SMTP sends to nowhere <sweeheng@usa.net>
        Newbie: counter sometimes resets (Yan Bilik)
    Re: open http file <pad755@padovanet.it>
    Re: passing arrays to a subroutine (Andreas Kahari)
    Re: Perl -VS- PHP (jason)
    Re: Perl vs Python for Numerical Analysis <tobix@fsck.com>
        s?printf and format output feature (Michael Kichanov)
        Script Question <md8hultz@mdstud.chalmers.se>
        Still a little puzzled (Was Re: Globbing with ActivePer <p.brouwer@prevalent.nl>
    Re: Still a little puzzled (Was Re: Globbing with Activ <sweeheng@usa.net>
    Re: Stopping perl CGI <alfonso.palacios-sureda@alcatel.fr>
    Re: Using Net::SMTP <tschilbach@aodinc.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 05 Jun 2000 12:21:55 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: 3 questions about perl
Message-Id: <393b9a45.13206826@news.skynet.be>

Villy Kruse wrote:

[a nice example of last in a bare block inside a loop]

Two remarks:

 * Your comment is not a Perl comment: change

  /* last returnes to here */

into

  # last returnes to here

 * It would be nice if the value of $abc was printed out in the final
statement:

  print "returning, \$abc = $abc\n";

(which prints '51' for $abc).

-- 
	Bart.


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

Date: Mon, 05 Jun 2000 12:25:51 +0200
From: Daniel Heiserer <daniel.heiserer@bmw.de>
Subject: embedded macros
Message-Id: <393B802F.9C91A123@bmw.de>

Hi,
I try solve the following problem:
I have a text file. Inside this
text files I want to embed perl macros:
--------- my file-----------------
$This should  not be a variable for perl!!!!!
hello every body.
now I try to run a perl macro.
My name is %$ENV{USER}% and
I want to embed some macros here:
%for ($ii=0;$ii<10;$ii++){print $ii};%
----------end of my file---------

So the idea is I split the file using the '%'
then I take every 2nd element and put
it into an %TOEVAL hash.
Then I evaluate each key in the toeval hash
and print $_ and put the result back as the value
of the hash and then I substitute each key of the
hash inside myfile with its value.

Unfortunately I fail at some points:
I faile for example at points like
$r='$ENV{USER}' because (I think)
perl sees in the substitute
s,$r,whoIam,;
the value of $r which itself is a variable
and therefore is going to be substituted right?
How can I fix this or is there a better way to mix
perl code and simple text and keeping the simple text
still readable (no printf-crap for all the text lines)?
Remind the amount of perl commands inside the text
should be quite small.


my code:
sub parse{
        @Tmp=split('\%',$frame);
        for ($jk=1;$jk<=$#Tmp;$jk=$jk+2){
                $TOEVAL{$Tmp[$jk]}=peval($Tmp[$jk]);
        }
        foreach $r (keys %TOEVAL){
                print "evaluating: $r ==> $TOEVAL{$r}";
                $frame=~s,\%$r\%,$TOEVAL{$r},;
        };
        print $frame;
}
#------------------------------------------------------------------------
sub peval{
        $\="\n";
        my $toeval=shift @_;
#       print "1.$toeval";
        $toeval='$_='.$toeval;
#       print "2.$toeval";
        eval($toeval);
        s/\n*$//g;
#        print;
        return $_;
};
#------------------------------------------------------------------------


Thanks Daniel


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

Date: Mon, 5 Jun 00 14:16:51 +0200
From: h.m.brand@hccnet.nl (H. Merijn Brand)
Subject: RE: error compiling Perl with HP-UX 11
Message-Id: <8F4A9500BMerijn@192.0.1.90>

sicherman@lucent.com (G. L. Sicherman) wrote in 
<8h395j$k7h@nntpb.cb.lucent.com>:

>We have encountered an obscure compiler bug in compiling Perl 5.005-03 
>for HP-UX 11.  Our software runs on many HP-UXs so we compile with
>+DAportable as well as -O.  Unfortunately, that combination breaks
>HP-UX's cc so that a complex expression in pp.c involving ^ and |
>miscompiles.  This produces results like:
>
>          $x = 7;
>          $x ^= 3;
>          print "$x\n";
>     3
>
>In other words, ^= and |= act as if they were =.

Not in my port:
# perl -de0

Loading DB routines from perl5db.pl version 1.0402
Emacs support available.

Enter h or `h h' for help.

main::(-e:1):   0
  DB<1> $x = 7;

  DB<2> $x ^= 3;

  DB<3> print $x
4
  DB<4>


>Workarounds:
>
>1. Omit +DAportable.  Not feasible for us; our customers are running
>   too many kinds of hardware and software.

No. You might be late with applying HP's recommended patches, though there 
pretty old already. See version info below.

>2. Omit -O or replace it by +O1.  Feasible but sacrifices efficiency.

"+O2 +Onolimit -Ae +DAportable" to get best of both worlds.

>3. Use gcc.  Same comment as 2.

No!

HP-UX 10.20 perl 5.005.03 +DAportable:
# perl -V
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=hpux, osvers=10.20, archname=PA-RISC2.0
    uname='hp-ux k1 b.10.20 e 9000800 90308302 8-user license '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='+O2 +Onolimit', gccversion=
    cppflags='-DDEBUGGING -Ae +DAportable -D_HPUX_SOURCE -I/pro/local/include'
    ccflags ='-DDEBUGGING -Ae +DAportable -D_HPUX_SOURCE -I/pro/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='ld', ldflags ='-L/pro/local/lib'
    libpth=/pro/local/lib /lib/pa1.1 /lib /usr/lib /usr/ccs/lib
    libs=-lnsl_s -lndbm -lgdbm -ldld -lm -lc -lndir -lcrypt
    libc=/lib/libc.sl, so=sl, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_hpux.xs, dlext=sl, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-
B,deferr
ed '
    cccdlflags='+z', lddlflags='-b -L/pro/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options: DEBUGGING
  Built under hpux
  Compiled at Mar 16 2000 11:37:56
  @INC:
    /pro/lib/perl5/5.00503/PA-RISC2.0
    /pro/lib/perl5/5.00503
    /pro/lib/perl5/site_perl/5.005/PA-RISC2.0
    /pro/lib/perl5/site_perl/5.005
    .


HP-UX 11.00 perl5.005.03 (Geen DAportable, but should work OK)
# perl -V
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=hpux, osvers=11.00, archname=PA-RISC2.0
    uname='hp-ux d3 b.11.00 e 9000800 2015358431 8-user license '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='+O2 +Onolimit', gccversion=
    cppflags='-DDEBUGGING -D_HPUX_SOURCE -Ae -I/pro/local/include'
    ccflags ='-DDEBUGGING -D_HPUX_SOURCE -Ae -I/pro/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='ld', ldflags =' -L/pro/local/lib'
    libpth=/pro/local/lib /lib/pa1.1 /lib /usr/lib /usr/ccs/lib
    libs=-lnsl -lnm -lndbm -lgdbm -ldld -lm -lc -lndir -lcrypt
    libc=/lib/libc.sl, so=sl, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_hpux.xs, dlext=sl, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-
B,deferr
ed '
    cccdlflags='+z', lddlflags='-b -L/pro/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options: DEBUGGING
  Built under hpux
  Compiled at Mar 16 2000 15:14:01
  @INC:
    /pro/lib/perl5/5.00503/PA-RISC2.0
    /pro/lib/perl5/5.00503
    /pro/lib/perl5/site_perl/5.005/PA-RISC2.0
    /pro/lib/perl5/site_perl/5.005
    .
# what /opt/ansic/bin/cc
/opt/ansic/bin/cc:
         LINT A.11.01.02 CXREF A.11.01.02
        HP92453-01 A.11.01.02 HP C Compiler
         $ CUPI80_IC7  Jan  7 1999 11:20:34 $
# what /usr/lib/libc.2
/usr/lib/libc.2:
         $ PATCH/11.00:PHCO_19491  Aug  9 1999 09:53:07 $

-- 
H.Merijn Brand
using perl5.005.03 and 5.6.0 on HP-UX 10.20, HP-UX 11.00, AIX 4.2, AIX 4.3,
  DEC OSF/1 4.0 and WinNT 4.0 SP-6a,  often with Tk800.022 and/or DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/
Member of Amsterdam Perl Mongers (http://www.amsterdam.pm.org/)


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

Date: Mon, 05 Jun 2000 14:15:08 +0200
From: nils grimsmo <dragon@online.no>
Subject: execute/include script from another
Message-Id: <393B99CC.76F3EC8F@online.no>

how do i execute one perl script from another? i am building a web page,
and found out how perl could make my life easier (making me type fewer
characters). what i want is for '/dir/dir/jalla.cgi' to execute
'/main.cgi', which will output the top and bottom of all the pages
(which is the same).

can i then use variables from 'jalla.cgi' in 'main.cgi'? let say i want
to write a page hit counter to the file "counter_$dir1_$dir2_$page.dat".
i don't know if this is correct syntax or at all possible. tell me
better ways if you want to.

how do i include a file, containing i.e. just variables? could i have
the entire top of my web-pages as a variable in '/main.data', like
"<html>\n<head>\n<title>$name_of_curr_page</title>\n", with
$name_of_curr_page taken from '/dir/dir/jalla.cgi'?

is it possible to search through the entire content of perldoc? can i in
some way install it as html locally?

what great book should i buy? i am a perl newbie, but have written som c
and stuff. i plan to use perl for web mainly.



nils grimsmo
dragon@online.no


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

Date: Mon, 05 Jun 2000 10:27:58 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: floating point algorithm bug in perl 5.6.0?
Message-Id: <393e7e6e.6079428@news.skynet.be>

Vincent Voois wrote:

>I noticed, but as a bridge engineer i would not place my bets on such
>fpu arithmics or you want to have my constructions end up on your head 
>one day or fall down with it.

I wouldn't trust your bridges if a roundoff error of only a fraction of
a fraction of a percent, would be enough to make it collapse. Bridge
engineers are used to roundoff errors, or material property
approximations errors, of 5 to 20%, and more.

-- 
	Bart.


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

Date: 5 Jun 2000 13:18:43 +0100
From: andkaha@hello.to.REMOVE (Andreas Kahari)
Subject: Re: getpwnam and Shadow Passwords
Message-Id: <393b8c93@merganser.its.uu.se>

In article <393B6801.C6A6D8DF@nospam.com>,
Marco Natoni  <mnatoni@rumbanet.it> wrote:
>Hi,
>
>  I wonder if someone can point me to a module (or give me just a tip)
>in order to verify the UNIX authentication of an user when the shadow
>password system is used.
>
>  Thank you in advance, and...
>
>
>	Best regards,
>		Marco

It's in the FAQ: "perldoc -q shadow"

/A

-- 
# Andreas Kähäri, <URL:http://hello.to/andkaha/>
# -----------------------------------------------------------
# All junk e-mail is reported to the appropriate authorities. 
# Quidquid latine dictum sit, altum viditur.


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

Date: Mon, 05 Jun 2000 13:40:02 +0200
From: Marco Natoni <blah@nospam.com>
Subject: Re: getpwnam and Shadow Passwords
Message-Id: <393B9192.CFEA01A4@nospam.com>

Andreas,

Andreas Kahari wrote:
>> I wonder if someone can point me to a module (or give me just a 
>> tip) in order to verify the UNIX authentication of an user when 
>> the shadow password system is used.
> It's in the FAQ: "perldoc -q shadow"

  Yes, indeed.  But, as a terrifying caveat recites, "If perl was
installed correctly, and your shadow library was written properly, the
getpw*() functions described in the perlfunc manpage should in theory
provide (read-only) access to entries in the shadow password file.".

  That theory is unfortunately not effective for my system:  In fact,
getpwname returns a disconsolate 'x' in the password field.

  However, a partial solution I have adopted is to read and parse
independently the /etc/shadow file (running into some user related
questions).


	Best regards,
		Marco


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

Date: Mon, 05 Jun 2000 10:32:19 GMT
From: Arun Mahajan <arun67@yahoo.com>
Subject: help me to undestand this syntax!!
Message-Id: <sjn0djmh5ri44@corp.supernews.com>

Hi everybody,

Please help me to understand this code. I am confused at -e and -w here, 
what does it mean?


  if ($ENV{'REQUEST_METHOD'} eq "POST" && -e $DATA_FILE && -w $DATA_FILE){

  if ($ENV{'REQUEST_METHOD'} eq "GET" && -e $DATA_FILE){

Thanks & regard,

Arun

--
Posted via CNET Help.com
http://www.help.com/


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

Date: 5 Jun 2000 10:35:02 GMT
From: thorfinn@netizen.com.au (Thorfinn)
Subject: Re: help me to undestand this syntax!!
Message-Id: <slrn8jn0im.jb.thorfinn@netizen.com.au>

In comp.lang.perl.misc, on Mon, 05 Jun 2000 10:32:19 GMT
Arun Mahajan <arun67@yahoo.com> wrote:
> Please help me to understand this code. I am confused at -e and -w here, 
> what does it mean?

% perldoc -f -X

Later,

   Thorf

-- 
David Goh <thorfinn@netizen.com.au> -- http://netizen.com.au/
Internet and Open Source Development, Consulting and Training
Netizen Pty Ltd, GPO Box 2265U, Melbourne VIC 3000, Australia
   Telephone: +61-3-9614-0949   Facsimile: +61-3-9614-0948


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

Date: Mon, 05 Jun 2000 13:28:08 +0200
From: Alfonso PALACIOS SUREDA <alfonso.palacios-sureda@alcatel.fr>
To: Arun Mahajan <arun67@yahoo.com>
Subject: Re: help me to undestand this syntax!!
Message-Id: <393B8EC8.6890D18D@alcatel.fr>

Arun Mahajan wrote:
>   if ($ENV{'REQUEST_METHOD'} eq "POST" && -e $DATA_FILE && -w $DATA_FILE){

$DATA_FILE exists and it's writable by effective user/group. In your
case, it must be writable by the user running your HTTP server (it seems
to be a CGI script).
 
>   if ($ENV{'REQUEST_METHOD'} eq "GET" && -e $DATA_FILE){

True if $DATA_FILE exists (and CGI GET).


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

Date: Mon, 5 Jun 2000 12:53:06 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: How to open another windows?
Message-Id: <960206090.16852.0.nnrp-08.c3ad6973@news.demon.co.uk>


Alan J. Flavell wrote in message ...
>On Sun, 4 Jun 2000, B Kemp wrote:
>
>> >I want to open another browser window through perl CGI. Can you tell me
how
>> >to do this?
>>
>> With Javascript, which you can print out in the html.
>
>Another reason to have javascript disabled...
>
Why is it that much of worry that someone would want to open an extra
window? (esp ME?)

Addmitedly this seems to be something that is used almost entirely by
advertisers,
but the only people who seem to really abuse this are the porn sites.
Surely that's not an issue for perl gurus?




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

Date: 5 Jun 2000 13:30:15 +0100
From: andkaha@hello.to.REMOVE (Andreas Kahari)
Subject: Re: HTML on a local server
Message-Id: <393b8f47@merganser.its.uu.se>

In article <8hfok3$jq2$1@nnrp1.deja.com>,  <stuartee@my-deja.com> wrote:
>
>
>I'm v.new to all this web page authoring lark but having a great time
>with it.  My prooblem is that I really need a hit counter on my page.
>This wouldn't normally be a problem (as far as I can tell) except that
>I'm working off a local server rather than publishing on the wwweb.  I
>seem to be lacking a load of workie bits from the server.
>This is where my confusion starts :o(
>Can anyone tell me what I need to add to the server to get it to work
>for me?

All you need to have is the ability to execute CGI scripts. There are
loads of CGI scripts that does access counting (search the web). For
example, there's one site called "Matt's Free Perl CGI Scripts"
located at <URL:http://www.worldwidemart.com/scripts/> that has one
graphical counter and one text based counter (I haven't used them).

To roll your own script, see the Perl FAQ and documentation:

perldoc -q "Web programming"
perldoc -q "CGI"
perldoc CGI

/A

-- 
# Andreas Kähäri, <URL:http://hello.to/andkaha/>
# -----------------------------------------------------------
# All junk e-mail is reported to the appropriate authorities. 
# Quidquid latine dictum sit, altum viditur.


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

Date: Mon, 5 Jun 2000 07:23:43 -0500
From: "Timothy H. Schilbach" <tschilbach@aodinc.com>
Subject: NET::SMTP sends to nowhere
Message-Id: <8hg66e$i19$1@news.chatlink.com>

I have everything working correctly and ActiveState 5.6.0 runs awesome.  I
do however have a simple SMTP question.  When I send the following script
through, It seems to never get to its destination.  I do not see the entry
of a sent mail in my SMTP log either.  I have the latest Libnet Module
installed from CPAN and I have my smtp, pop3, and nntp server all designated
as well.  Can someone tell me what I am doing wrong?

The Script
##########################

use Net::SMTP;

        $smtp = Net::SMTP->new('mail.aodinc.com');
        $smtp->mail( 'tschilbach@aodinc.com');
        $smtp->to('exchange@aodinc.com');
        $smtp->data();

        # Send the header.
        $smtp->datasend("To: tschilbach\@aodinc.com\n");
        $smtp->datasend("From: exchange\@aodinc.com\n");
        $smtp->datasend("\n");

        # Send the body.
        $smtp->datasend("Tetsing!\n");
        $smtp->dataend();
        $smtp->quit;

P.S. :  The script requires that I have the "\" after the name in the
datasend block as you see above for the sender and recipient.  I think this
may be the problem. How do I get PERL to recognize just the email addressing
without the "\"?

Timothy H. Schilbach
Alpha Omega Design Inc.
Tschilbach@aodinc.com
1-877-263-7094
Visit our website at www.aodinc.com





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

Date: Mon, 5 Jun 2000 21:04:20 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: Re: NET::SMTP sends to nowhere
Message-Id: <8hg85q$qme$1@mawar.singnet.com.sg>

> I have everything working correctly and ActiveState 5.6.0 runs awesome.  I
> do however have a simple SMTP question.  When I send the following script
> through, It seems to never get to its destination.  I do not see the entry
> of a sent mail in my SMTP log either. I have the latest Libnet Module

Out of curiosity, who is doing the logging? Net::SMTP or your mail server?

> installed from CPAN and I have my smtp, pop3, and nntp server all
designated
> as well.  Can someone tell me what I am doing wrong?
>
> The Script
> ##########################
>
> use Net::SMTP;
>
>         $smtp = Net::SMTP->new('mail.aodinc.com');
Try:

          $smtp = Net::SMTP->new('mail.adoinc.com') or
                  die "connection failed: $!");

You really should test if the connection was successful. You can also turn
on debugging in Net::SMTP (read its docs).

>         $smtp->mail( 'tschilbach@aodinc.com');
>         $smtp->to('exchange@aodinc.com');
>         $smtp->data();
>
>         # Send the header.
>         $smtp->datasend("To: tschilbach\@aodinc.com\n");
>         $smtp->datasend("From: exchange\@aodinc.com\n");
>         $smtp->datasend("\n");
>
>         # Send the body.
>         $smtp->datasend("Tetsing!\n");
>         $smtp->dataend();
>         $smtp->quit;
>
> P.S. :  The script requires that I have the "\" after the name in the
> datasend block as you see above for the sender and recipient.  I think
this
> may be the problem.

That is because you used double quotes ". If you do not escape @ with '\',
Perl will attempt to interpolate "@aodinc" as an array. Got it? If you
really don't want to use '\', then try 'To: tschilback@aodinc.com' . "\n" -
note the single quote. IIRC, "\n" may not be necessary as Net::SMTP appends
it automagically.




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

Date: Mon, 05 Jun 2000 11:11:43 GMT
From: fromng@pourpre.com (Yan Bilik)
Subject: Newbie: counter sometimes resets
Message-Id: <393b8a19.9893640@news.free.fr>

Hi,
For a few days, my counter sometimes has reset, and the count rolled
back to zero. The count is around 28000 or 29000 hits.
My Perl code seems quite simple, but as I'm new to Perl, I hope some
of you will be able to help me...
Here is the main code:

open(CNTFILE, "<cnt.txt");
flock CNTFILE, 2;
$count = <CNTFILE>;
chop($count);
close(CNTFILE);

$count++;

open(CNTFILE, ">cnt.txt");
flock CNTFILE, 2;
print CNTFILE "$count\n";
close(CNTFILE);

What's wrong ??
Thanks in advance.

Yan



----------------------------------------------
c h r o m a          http://pourpre.com/chroma
16 millions de couleurs, oui mais lesquelles ?
----------------------------------------------
              chroma@pourpre.com


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

Date: Mon, 5 Jun 2000 13:31:11 +0200
From: "giorgio" <pad755@padovanet.it>
Subject: Re: open http file
Message-Id: <8hg37l$avd$3@sirmdpsin17.inwind.it>

I've tried what you say, but always I get an error: unable to open file no
such file or directory


"scott thomason" <scott@industrial-linux.org> ha scritto nel messaggio
news:ksF_4.1703$gZ4.637244@feed.centuryinter.net...
> ..to be more specific, use LWP this way:
>
> #!/usr/bin/perl -w
>
> use LWP::Simple;
>
> my $html = get('http://www.yahoo.com/');




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

Date: 5 Jun 2000 11:05:47 +0100
From: andkaha@hello.to.REMOVE (Andreas Kahari)
Subject: Re: passing arrays to a subroutine
Message-Id: <393b6d6b@merganser.its.uu.se>

In article <8hf03l$2nt$1@nnrp1.deja.com>,  <brondsem@my-deja.com> wrote:
>I'm having trouble passing arrays to a subroutine and preserving the
>structure.  (I suspect this problem will come up again if I send it a
>nested array, which I will need to do.)
>
>Here's the code:
>
>use CGI::Carp qw(fatalsToBrowser);
>print "Content-Type: text/html\n\n";
>print "starting\n";
>
>@myfields = ("user_id", "username", "pwd", "name");
>@myconds = (
>	["user_id", "==", "12"],
>	["name", ">", "s"],
>	);
>select("mytable", @myfields, @myconds);


Please notice that 'select' is a built in function in Perl.


>print "done\n";
>
>
>and here's the subroutine:
>
>
>sub select()
>{
>	my $table = @_[0];
>	my @fields = @_[1];
>	my @conds = @_[2];


$table will get the value of "mytable", the first value of @myfields
will then be stored in @fields and the second value of @myfields will
be stored in @conds. The array @_ will be the "flattened" argument
list.


>
>	print $table, "<br>";
>	foreach (@fields)
>	{
>		print; print "|";
>	}
>	print "<br>";
>	foreach (@conds)
>	{
>		print; print "|";
>	}
>	print "<br>";
>	exit(0);
>	# more code would follow once I get this to work....
>}
>
>
>And the results are:
>
>starting
>mytable<br>user_id|<br>username|<br>
>
>Can anyone show me how do this?  I'm somewhat familiar with perl but
>not too experienced.
>
>Thanks,
>
>Dave Brondsema
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.


Try passing the arrays as references instead:

myfunction("mystring", \@array1, \@array2);

# ...

sub myfunction {
  my $string = shift;
  my $arr1 = shift;
  my $arr2 = shift;

  # the values of @array1 are stored in $arr1->[0], $arr1->[1] etc.
  # the values of @array2 are stored in $arr2->[0], $arr2->[1] etc.


  # misc. code
}

See the perlref manual.


/A


-- 
# Andreas Kähäri, <URL:http://hello.to/andkaha/>.
# All junk e-mail is reported to the
# appropriate authorities, no exceptions.


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

Date: Mon, 05 Jun 2000 10:28:37 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Perl -VS- PHP
Message-Id: <MPG.13a61dfd4cf48f398970e@news>

Tad McClellan writes ..
>On Sun, 04 Jun 2000 17:11:00 GMT, jason <elephant@squirrelgroup.com> wrote:
>>MC writes ..
>>>Does anyone know what advantages PHP has over Perl, both in general and for
>>>CGI/Database processing??
>>
>>I'll go on record .. none
>
>
>It is better for golf, you save one character whenever you type
>"PHP" instead of "Perl"...
>
>... but PHP loses when pronounced out loud, three syllables to one.
>
>... and I guess typing it isn't so great after all, PHP loses
>six keypresses to five.

*8^) .. w/ capslock it's five all

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 05 Jun 2000 13:49:44 +0200
From: Tobias Brox <tobix@fsck.com>
Subject: Re: Perl vs Python for Numerical Analysis
Message-Id: <1aaeh04aav.fsf@odin.funcom.com>

zenin@bawdycaste.org writes:

> 	Convincing Python advocates that Perl is anything beyond the spawn
> 	of Satin is typically a lost cause...they typically just won't
> 	listen. :-(

Why not just admit that we're satanists - and happy with it? :)

-- 
"The trouble with the world is that the stupid are
 cocksure and the intelligent are full of doubt."
- Bertrand Russell


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

Date: 5 Jun 2000 11:01:51 GMT
From: mike@mix.nordlink.ru (Michael Kichanov)
Subject: s?printf and format output feature
Message-Id: <8hg1av$1f2e$1@is.inar.ru>

Hi All!

Please explain how to fix this floating point rounding feature
while using sprintf,printf and format (.##) output:
sprintf("%.2f", 1.555) == 1.55 (should be 1.56)
sprintf("%.2f", 0.555) == 0.56 (everything here is correct)

by growing precission to 20 we got
sprintf("%.20f", 1.555) == 1.55499999999999993783
that explains everything.

How to resolve this problem?
I did it this way:
$f = 1.555;
$f = sprintf("%.3f", $f) * 1000;
$f = $f%10 >= 5 ? (int($f/10)+1)/100 : int($f/10)/100;
$f_rounded = sprintf("%.2f", $f); # == 1.56

Does a better solution exist?

mike


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

Date: Mon, 5 Jun 2000 12:41:09 +0200
From: Johan Huldtgren <md8hultz@mdstud.chalmers.se>
Subject: Script Question
Message-Id: <Pine.SOL.4.21.0006051221170.21444-100000@fraggel13.mdstud.chalmers.se>

In FreeBSD the following is used to find and delete empty directories:

find -d .  -type d | /usr/bin/perl -lne \
'opendir(D,$_);@f=readdir(D);rmdir if $#f == 1;closedir(D);'

Now I've been trying to figure out something similar, but I want to print
the names of the non-empty folders to a file. Any tips?

- Johan



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

Date: Mon, 5 Jun 2000 12:49:25 +0200
From: "Pieter Brouwer" <p.brouwer@prevalent.nl>
To: comp.lang.perl.misc
Subject: Still a little puzzled (Was Re: Globbing with ActivePerl)
Message-Id: <PRVL3812A1F3D@prevalent.nl>

Hi Jason,

I came across your reply in the newsgroup. I have the same problem and I am
still confused as to what I should do to make things work. So I hope you can
help me out (I am using .

I would still like to pass some kind of wildcard from the command-line. *.*
(or *) will not do in my case, only something like *.xw (or someting like
*.x?). I allways end up with the same error-message.

Whenever I try this little program:
# start program scan.pl
while ( <> ) {
   print "Scanning file $ARGV ...\n";
}
# end program scan.pl

And run it with:
>perl scan.pl *.wx

I get the message:
Can't open *.xw: No such file or directory at scan.pl line 2.

If I change the program like this:
# start program scan.pl
while ( <$ARGV[0]> ) {
   print "Scanning file $ARGV ...\n";
}
# end program scan.pl

and run it the same way, something is indeed happening, but it seems that I
am not getting what I was hoping for. The result is that the filename is
placed in $_ and $ARGV is empty. The only way I can think of is this:
# start program scan.pl
while ( $file = <$ARGV[0]> ) {
    print "Scanning file $file ...\n";
    open INFILE, "$file";
    while ( <INFILE> )
    {
        print;
    }
}
# end program scan.pl

Is this indeed the only way?????

I am using:
>>>>>>>>>>>
E:\okz\comp\okz\xref>perl -v

This is perl, v5.6.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2000, Larry Wall

Binary build 613 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 12:36:25 Mar 24 2000
<<<<<<<<<<<

TIA

Pieter Brouwer

jason <elephant@squirrelgroup.com> schreef in nieuwsbericht
<MPG.13a25706ce823dc0989704@news>:ðÐÁ^ÀÐÁ^˜ÐÁ^pÐÁ^`ÐÁ^0ÐÁ^...
> Bernard Delmée writes ..
> >I noticed a while ago that wildcard expansion on the command
> >line seems to have changed with AP. Let's take a simple example:
> >
> >C:\>    perl -e "print @ARGV;" *.*
> >
> >On Win32, I know this works at least with perl4 and perl5.003
> >(build 315). It doesn't anymore as of build 520+, nor does 5.6.
> >
> >Does someone know the trick?
>
>   perl -e "print qq/$_\n/ while <*>;"
>
> note that *.* is dropped in 5.6 in favour of * because in 5.6 the
> globbing is no longer passed to the shell - but is done internally by
> File::Glob (a POSIX glob())
>
> but I have to add that
>
>   dir /b
>
> is pretty damn tempting too
>
> --
>  jason - elephant@squirrelgroup.com -




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

Date: Mon, 5 Jun 2000 20:47:37 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: Re: Still a little puzzled (Was Re: Globbing with ActivePerl)
Message-Id: <8hg76k$quk$1@mawar.singnet.com.sg>

> Whenever I try this little program:
> # start program scan.pl
> while ( <> ) {
>    print "Scanning file $ARGV ...\n";
> }
> # end program scan.pl

What is $ARGV doing there? @ARGV has nothing to do with $ARGV. And $ARGV has
nothing to do with $ARGV[0]. But @ARGV is related to $ARGV[i] - the latter
being the (i+1)-th element of the former. Got it?

> And run it with:
> >perl scan.pl *.wx
>
> I get the message:
> Can't open *.xw: No such file or directory at scan.pl line 2.

Opening the files (in the arguments) is what the magical <> operator does!
See the "perlop" page, which is included with ActivePerl. Read how the
magical <> operator works before using it. You will be less perplexed.

> If I change the program like this:
> # start program scan.pl
> while ( <$ARGV[0]> ) {
>    print "Scanning file $ARGV ...\n";
> }
> # end program scan.pl
>
> and run it the same way, something is indeed happening, but it seems that
I
> am not getting what I was hoping for. The result is that the filename is
> placed in $_ and $ARGV is empty. The only way I can think of is this:

Again, what has $ARGV got to do with anything? It is undef or '' at best.

Since you called the script with *.xw as the first argument, naturally @ARGV
= ('*.xw'). So $ARGV[0] = '*.xw', and therefore <$ARGV[0]> returns an array
of all files ending with '.xw'. And $_ takes the value of each argument on
each loop of while. Meanwhile, $ARGV remains unperturbed...

> # start program scan.pl
> while ( $file = <$ARGV[0]> ) {
>     print "Scanning file $file ...\n";
>     open INFILE, "$file";
>     while ( <INFILE> )
>     {
>         print;
>     }
> }
> # end program scan.pl
>
> Is this indeed the only way?????

What's wrong with that if it is describes logically what you intend to do?

Swee Heng




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

Date: Mon, 05 Jun 2000 14:42:11 +0200
From: Alfonso PALACIOS SUREDA <alfonso.palacios-sureda@alcatel.fr>
To: AyJay <ayjayr@my-deja.com>
Subject: Re: Stopping perl CGI
Message-Id: <393BA023.E9D938D5@alcatel.fr>

Instead of keeping the script running, you should try something like
this:

<HTML><HEAD><TITLE>HTML REDIRECT</TITLE>
<META HTTP-EQUIV="REFRESH" CONTENT="5;
URL=http://www.foo.com/cgi-bin/show-log.pl?lastSize=20573">
</HEAD>

This will tell the browser to update the page 5 seconds later. You can
add a parameter to tell the script which was the size of the file when
you last saw it, so he can show you only the new logs.

AyJay wrote:
> 
> G'day,
> 
> I have a perl CGI that displays information from a log file, while that
> file is being appended to. The approach taken was to check the size of
> the log file and if it has increased send those lines to the browser.
> This all works fine and dandy, any improvement suggestions would be
> appreciated however.
> 
> The problem is that if the user presses the 'Stop' or 'back' buttons on
> their browser or even closes their browser the perl keeps running until
> the log file size no longer changes. How can I tell when any of these
> events happen?
> 
> ---
> TIA
> AJ
> 
> AyJayR_at_Yahoo.com.au
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.


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

Date: Mon, 5 Jun 2000 07:35:54 -0500
From: "Timothy H. Schilbach" <tschilbach@aodinc.com>
Subject: Re: Using Net::SMTP
Message-Id: <8hg6t8$iac$1@news.chatlink.com>

I hate to disagree,

  I run multiple email and web servers with SMTP AUTH protocal as outlined
in RFC 2554 (which can be found here:
ftp://ftp.isi.edu/in-notes/rfc2554.txt ) This great protocal allows you to
secure your SMTP for incomming and outgoing mail. This is great to use if
your server is one of many organizational servers and you dont want anyone
but the users with the password or accounts to use them.  Its also really
easily implemented into PERL.  :-)

Timothy H. Schilbach
Alpha Omega Design Inc.
1-877-263-7094
Visit our website at www.aodinc.com






morgan@lineone.net> wrote in message news:8hdccn$kv$1@nnrp1.deja.com...
> Hi,
>
> I've tried to use an example of Net::SMTP that I found, however I can't
> get it to work...
> One thing I have noticed is that Net::SMPTP doesn't require a password
> to log onto the mail server... why not? With OE (Outlook Express) and
> other mail programs it is neccessary to have a password or is that only
> used for pop3???
>
> It may be that my server doesn't have Net::SMTP installed, does it come
> as standard with version 5?? But even so I would have though a password
> would be needed to send mail??
>
> thanx 4 any1's help...
>
> Luke
> aka Phantom*Breeze
> lmorgan@lineone.net
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




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

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


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