[18003] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 163 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 28 21:05:30 2001

Date: Sun, 28 Jan 2001 18:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980733909-v10-i163@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 28 Jan 2001     Volume: 10 Number: 163

Today's topics:
        <STDIN> as an array <traigle@si.umich.edu>
    Re: <STDIN> as an array (Abigail)
    Re: Benchmark Module Flaws <chrisw@dynamite.com.au>
    Re: Benchmark Module Flaws <godzilla@stomp.stomp.tokyo>
    Re: CGI.pm bits101010@my-deja.com
        closed filehandle error <whtwlf@NOSPAMoptushome.com.au>
    Re: closed filehandle error (Eric Bohlman)
        Error compiling Perl 5.6.0 (and 5.7.0) with glibc 2.2.1 <ryarger@mediaone.net>
    Re: Finding unused variables ? <johnlin@chttl.com.tw>
    Re: Finding unused variables ? (Abigail)
        how do I use 'strict' and 'vars' <extramail@home.com>
    Re: how do I use 'strict' and 'vars' (Mark Jason Dominus)
    Re: how do I use 'strict' and 'vars' (Abigail)
    Re: How to make Perl wait <chrekh@chello.se>
    Re: How to make Perl wait tigra@sky.deep.ru
    Re: How to make Perl wait bits101010@my-deja.com
    Re: How to make Perl wait <flavell@mail.cern.ch>
    Re: How to make Perl wait (Jimtaylor5)
    Re: How to make Perl wait (Jimtaylor5)
    Re: How to make Perl wait (Jimtaylor5)
    Re: How to pass $vars to a script from within another s <creafin1998@yahoo.com>
    Re: How to pass $vars to a script from within another s <comdog@panix.com>
    Re: mod_perl Perl: <comdog@panix.com>
    Re: New way to learn Perl? <mdemello@kennel.ruf.rice.edu>
    Re: Perl is bad at (very) simple math! <chrisw@dynamite.com.au>
    Re: Perl on 98 bits101010@my-deja.com
        Problem renaming under Win32 (at)msn.(dot)(deletethis)
    Re: ternary conditional operator <johnlin@chttl.com.tw>
    Re: ternary conditional operator (Eric Bohlman)
        Unicode and URL encoding (Benjamin Chen)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 29 Jan 2001 01:04:22 GMT
From: Jeff Traigle <traigle@si.umich.edu>
Subject: <STDIN> as an array
Message-Id: <B69A2DAC.18EC3%traigle@si.umich.edu>

Hi, folks.

In all the years I've been administering Unix systems, I've rarely had need
to write scripts. The few I have needed, I've done in csh or ksh, depending
on the environment I was working in at the time. I decided to delved into
the world of perl so this weekend I've started by reading Learning Perl (2nd
Edition) from O'Reilly & Associates, Inc. I've run into a problem concerning
<STDIN> as an array that I haven't seen mentioned in the archives at
www.deja.com. I hope you can enlighten me.

I'm running perl 5.005_003 on RedHat Linux 6.0. Nothing special. It's as
shipped on that Linux distribution. One of the exercises in the regular
expressions section asks to write a program that accepts a list of words on
STDIN and looks for a line containing all five vowels.

The code is simple:

#!/usr/bin/perl

while (<STDIN>) {
    if (/a/i && /e/i && /i/i /o/i && /u/i) {
        print;
    }
}

This is, in fact, the exact code provided in the book as one solution for
this exercise. However, executing this code results in the following error:

 ./vowels.plx: syntax error near unexpected token `<STDIN>'
 ./vowels.plx: ./vowels.plx: line 3: `while (<STDIN>) {'

I get similar errors trying to make an explicit assignment of <STDIN> to an
array variable (@arrayname = <STDIN>;) as is also mentioned as legitimate in
the book.

Is this a design change between 5.004 (which the book was written for) and
5.005? Is there a known bug in the RedHat Linux 6.0 distributed copy of
perl? Was the book just plain wrong in multiple locations about this
working?

-- 
Jeff Traigle
traigle@si.umich.edu
http://www-personal.si.umich.edu/~traigle/



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

Date: 29 Jan 2001 01:17:30 GMT
From: abigail@foad.org (Abigail)
Subject: Re: <STDIN> as an array
Message-Id: <slrn979h5a.rro.abigail@tsathoggua.rlyeh.net>

Jeff Traigle (traigle@si.umich.edu) wrote on MMDCCVIII September MCMXCIII
in <URL:news:B69A2DAC.18EC3%traigle@si.umich.edu>:
-: 
-: I'm running perl 5.005_003 on RedHat Linux 6.0. Nothing special. It's as
-: shipped on that Linux distribution. One of the exercises in the regular
-: expressions section asks to write a program that accepts a list of words on
-: STDIN and looks for a line containing all five vowels.
-: 
-: The code is simple:
-: 
-: #!/usr/bin/perl
-: 
-: while (<STDIN>) {
-:     if (/a/i && /e/i && /i/i /o/i && /u/i) {
-:         print;
-:     }
-: }
-: 
-: This is, in fact, the exact code provided in the book as one solution for
-: this exercise. However, executing this code results in the following error:
-: 
-: ./vowels.plx: syntax error near unexpected token `<STDIN>'
-: ./vowels.plx: ./vowels.plx: line 3: `while (<STDIN>) {'


I don't get that with 5.005_03. I do get a run time error (division by
zero), because there is no && between /i/i and /o/i (-w would have warned
you against that).


-: I get similar errors trying to make an explicit assignment of <STDIN> to an
-: array variable (@arrayname = <STDIN>;) as is also mentioned as legitimate in
-: the book.
-: 
-: Is this a design change between 5.004 (which the book was written for) and
-: 5.005? Is there a known bug in the RedHat Linux 6.0 distributed copy of
-: perl? Was the book just plain wrong in multiple locations about this
-: working?

No. RedHat has distributed development versions of Perl, but that wouldn't
effect this. No.



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: Mon, 29 Jan 2001 10:55:15 +1100
From: "Chris W" <chrisw@dynamite.com.au>
Subject: Re: Benchmark Module Flaws
Message-Id: <1l2d6.37$aR.1071@news0.optus.net.au>


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3A731B61.F4C753FF@stomp.stomp.tokyo...

> I have yet to successfully run "cmpthese" per documentation
> for this benchmark module. Regardless of changes I make,
> an "Undefined subroutine $main::cmpthese...." error is
> always returned.
> His timethis and timethese work ok, but never cmpthese.
> Have you successfully run cmpthese? What syntax did
> you use to run this?

As outlined in the the documentation cmpthese() is not exported by default.
To use cmpthese you need to explicitly import it in your code:

#perl -w
use strict;
use Benchmark qw/ cmpthese /;
sub test1 { print "Hello, World\n"; }
sub test2 { print "Hello, Godzilla\n"; }
cmpthese (10000, { 'test1' => \&test1, 'test2' => \&test2 } );
__END__

The examples in the documentation do not compile because they do not import
cmpthese().

I can't comment on the accuracy of Benchmark, although I expect it will
improve with extended run times.   Depending on your exact requirements
Devel::DProf in conjunction with dprofpp may be of use to you.

perl -d:DProf test.pl
dprofpp

Hope this helps.




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

Date: Sun, 28 Jan 2001 17:08:08 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Benchmark Module Flaws
Message-Id: <3A74C278.F454DDA9@stomp.stomp.tokyo>

Chris W wrote:
 
> Godzilla! wrote:
 
> > I have yet to successfully run "cmpthese" per documentation
> > for this benchmark module. Regardless of changes I make,
> > an "Undefined subroutine $main::cmpthese...." error is
> > always returned.
> > His timethis and timethese work ok, but never cmpthese.
> > Have you successfully run cmpthese? What syntax did
> > you use to run this?
 
> As outlined in the the documentation cmpthese() is not exported
> by default. To use cmpthese you need to explicitly import it in
> your code:
 
> #perl -w
> use strict;
> use Benchmark qw/ cmpthese /;
> sub test1 { print "Hello, World\n"; }
> sub test2 { print "Hello, Godzilla\n"; }
> cmpthese (10000, { 'test1' => \&test1, 'test2' => \&test2 } );
> __END__
 
> The examples in the documentation do not compile because 
> they do not import cmpthese().
 

Thank you again Chris. I was using the wrong syntax
and am unable to locate any notes on correct syntax.
It is unfortunate this author and, authors of many
other modules available on CPAN, do not properly
document their modules. It is annoying to discover
so many modules have such poor documention. I came
across one module within my perl install, which
has no documentation other than author credit.

Strikes me CPAN would benefit by requiring passage
of quality control tests, before a module is allowed
to presented to the public via CPAN. Our CPAN is an
excellent site and volunteers do a wonderful job of
maintaining it. However, I am convinced many module
authors are solely interested in personal attention
and have little interest in providing quality work.

Regarding your feedback on benchmark accuracy, I have
been running my tests as a single script holding four
batch runs, each batch with one-million iterations, 
for a total of four-million iterations. Results are
at least consistent and do seem to return relatively
accurate data, displaying no major variations between
batch runs.

Thanks again. I will try your syntax with cmpthese
then move on to other features of benchmark which
require explicit import as shown by line 362 of 
the benchmark module.

Godzilla!


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

Date: Sun, 28 Jan 2001 23:47:36 GMT
From: bits101010@my-deja.com
Subject: Re: CGI.pm
Message-Id: <952b2n$id4$1@nnrp1.deja.com>

Try this:

$cgi = new CGI;
# this should get the number=714 part, using regular expression
# $ENV{'QUERY_STRING') should contain number=714
$ENV{'QUERY_STRING') =~ /number=(\d+)$/;
$number = $1;

# get the rest into array
foreach ($query->param()) {
  $FieldArray[$i++] = $query->param($_);
}

Winston.

In article <3a749004.5002227@news.planet.nl>,
  mustbe@pdelahunta.cjb.com (Paul Delahunta) wrote:
> On Sun, 28 Jan 2001 21:22:06 GMT, mustbe@pdelahunta.cjb.com (Paul
> Delahunta) wrote in message <3a748ad3.3673190@news.planet.nl>:
>
> >Hi,
> >I have a form wich's method = POST and action= "../form.pl?
number=714"
> >I want to retrieve  both the POSTed parameters and the 'number'
> >parameter using CGI.
>
> I meant CGI.pm here. Sorry for the inconvenience :-)
>


Sent via Deja.com
http://www.deja.com/


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

Date: Mon, 29 Jan 2001 10:24:21 +1100
From: "Shane Lowry" <whtwlf@NOSPAMoptushome.com.au>
Subject: closed filehandle error
Message-Id: <9529dt$94g$1@merki.connect.com.au>

Hey Folk,
            I have a problem with a simple script that is driving my nuts.
The script scans a directory for files, which it then reads and uses the
text to format and send email. It reads the first line fine and then gives a
read on closed filehandle error for the subsequent line, before moving on
the next file. It does this for each file. The code looks fine and I have
used very similar code elsewhere. So my thinking is the problem is data
related. Each line in the data file is \n (newline) terminated with no other
control characters. The file is created by a c program on Unix, while the
perl program is running on Linux. I have also hand created test data with
the same results.

Any ideas ?

TIA

Shane Lowry


opendir DIR, $fileDir || logit(11, "Cannot open directory \'$fileDir\' $!");

@filelist = grep -f, map "$fileDir/$_", readdir DIR;

closedir(DIR);

# debug info
logit(0,"file list is @filelist");

for $filename (@filelist)
{
     # if the file has an 'eml' file extension it's an email data file.
     if ( $filename =~ ".eml" )
    {
        # debug info
        logit(0, "filename is $filename");

        # open the file
        open FH, "$filename"

     # open the file
     open FH, "$filename"
         || logit (12, "Cannot Open file $userFile: $!");

     # read the file
     while( $line = <FH> )
    {
        # debug info
        logit(0,"line is $line");

        # split out the login and password
       ($lineNumber,$data) = split/`/, $line;

        if ( $lineNumber == "01" )
       {
            # grab the user information
            ( $lineNumber,$user,$email,$terminal,$subject )
                     = split/`/, $line;
       } # end if
      else
      {
                # grab the email details
               ( $lineNumber,$message ) = split/`/, $line;

                # debug info
                logit(0,"message is $message");

                # add message to end of current body text
                $body .= $message;

                # debug info
                logit(0, "body is $body");
            } # end else
        } # end while

        # debug info
        logit(0,"closing file $filename");

        # close the file handle
        # close (FH);

        # delete the file
        # unlink "$filename";
    } # end if
} # end for





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

Date: 29 Jan 2001 00:53:31 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: closed filehandle error
Message-Id: <952eub$cmt$3@bob.news.rcn.net>

Shane Lowry <whtwlf@nospamoptushome.com.au> wrote:
> Hey Folk,
>             I have a problem with a simple script that is driving my nuts.
> The script scans a directory for files, which it then reads and uses the
> text to format and send email. It reads the first line fine and then gives a
> read on closed filehandle error for the subsequent line, before moving on
> the next file. It does this for each file. The code looks fine and I have
> used very similar code elsewhere. So my thinking is the problem is data
> related. Each line in the data file is \n (newline) terminated with no other
> control characters. The file is created by a c program on Unix, while the
> perl program is running on Linux. I have also hand created test data with
> the same results.

> Any ideas ?

> TIA

> Shane Lowry


> opendir DIR, $fileDir || logit(11, "Cannot open directory \'$fileDir\' $!");

Due to precedence problems, you'll never get the error message even if 
opening the directory fails.  Replace the '||' with 'or' or parenthesize 
the arguments to opendir.

> @filelist = grep -f, map "$fileDir/$_", readdir DIR;

> closedir(DIR);

> # debug info
> logit(0,"file list is @filelist");

> for $filename (@filelist)
> {
>      # if the file has an 'eml' file extension it's an email data file.
>      if ( $filename =~ ".eml" )

Anchor your match to the end of the string so you don't get false-positive 
matches on filenames that contain '.eml' somewhere other than the end.

>     {
>         # debug info
>         logit(0, "filename is $filename");

>         # open the file
>         open FH, "$filename"

>      # open the file
>      open FH, "$filename"
>          || logit (12, "Cannot Open file $userFile: $!");

It looks like you're trying to open the file twice, or that you've typed 
in your code rather than cutting-and-pasting, neither of which is a good 
idea.  You have the same precedence problem as you did with the opendir.

>      # read the file
>      while( $line = <FH> )
>     {
>         # debug info
>         logit(0,"line is $line");

>         # split out the login and password
>        ($lineNumber,$data) = split/`/, $line;

>         if ( $lineNumber == "01" )

>        {
>             # grab the user information
>             ( $lineNumber,$user,$email,$terminal,$subject )
>                      = split/`/, $line;
>        } # end if
>       else
>       {
>                 # grab the email details
>                ( $lineNumber,$message ) = split/`/, $line;

>                 # debug info
>                 logit(0,"message is $message");

>                 # add message to end of current body text
>                 $body .= $message;

>                 # debug info
>                 logit(0, "body is $body");
>             } # end else
>         } # end while

>         # debug info
>         logit(0,"closing file $filename");

>         # close the file handle
>         # close (FH);

>         # delete the file
>         # unlink "$filename";

You should test this for success.

>     } # end if
> } # end for





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

Date: Mon, 29 Jan 2001 01:13:55 GMT
From: Randy Yarger <ryarger@mediaone.net>
Subject: Error compiling Perl 5.6.0 (and 5.7.0) with glibc 2.2.1 (invalid parameters with recvfrom ,etc.)
Message-Id: <3A74C456.203@mediaone.net>

Hello,

I am getting errors compiling both Perl 5.6.0 and Perl 5.7.0. I just 
upgraded my glibc to 2.2.1 (compiled from source), so I think that it 
may be the culprit.

This is the error output:
pp_sys.c: In function `Perl_pp_sysread':
pp_sys.c:1526: incompatible type for argument 5 of `recvfrom'
pp_sys.c: In function `Perl_pp_send':
pp_sys.c:1716: incompatible type for argument 5 of `sendto'
pp_sys.c: In function `Perl_pp_bind':
pp_sys.c:2208: incompatible type for argument 2 of `bind'
pp_sys.c: In function `Perl_pp_connect':
pp_sys.c:2246: incompatible type for argument 2 of `connect'
pp_sys.c: In function `Perl_pp_accept':
pp_sys.c:2315: incompatible type for argument 2 of `accept'
pp_sys.c: In function `Perl_pp_getpeername':
pp_sys.c:2483: incompatible type for argument 2 of `getsockname'
pp_sys.c:2487: incompatible type for argument 2 of `getpeername'
make: *** [pp_sys.o] Error 1

Anyone have any ideas?
-Randy Yarger
ryarger@mediaone.net

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
   Platform:
     osname=linux, osvers=2.4.0, archname=i686-linux
     uname='linux nic-xxx-xxxx-xxx.mw.mediaone.net 2.4.0 #2 wed jan 24 
14:02:47 est 2001 i686 unknown '
     config_args=''
     hint=recommended, useposix=true, d_sigaction=define
     usethreads=undef use5005threads=undef useithreads=undef 
usemultiplicity=undef
     useperlio=undef d_sfio=undef uselargefiles=define
     use64bitint=undef use64bitall=undef uselongdouble=define usesocks=undef
   Compiler:
     cc='cc', optimize='-O2', gccversion=2.95.3 19991030 (prerelease)
     cppflags='-fno-strict-aliasing -I/usr/local/include'
     ccflags ='-fno-strict-aliasing -I/usr/local/include 
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
     stdchar='char', d_stdstdio=define, usevfork=false
     intsize=4, longsize=4, ptrsize=4, doublesize=8
     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
     ivtype='long', ivsize=4, nvtype='long double', nvsize=12, 
Off_t='off_t', lseeksize=8
     alignbytes=4, usemymalloc=n, prototype=define
   Linker and Libraries:
     ld='cc', ldflags =' -L/usr/local/lib'
     libpth=/usr/local/lib /lib /usr/lib
     libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lcrypt
     libc=/lib/libc-2.2.1.so, so=so, useshrplib=true, libperl=libperl.so
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic 
-Wl,-rpath,/usr/lib/perl5/5.6.0/i686-linux/CORE'
     cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'



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

Date: Mon, 29 Jan 2001 09:27:00 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Finding unused variables ?
Message-Id: <952h0h$lrk@netnews.hinet.net>

"Abigail" wrote
> -w *might* warn you for unused variables; but not for
> my()ed variables. Witness:
>
>     $ perl -wle '$foo = 1'
>     Name "main::foo" used only once: possible typo at -e line 1.
>     $ perl -wle 'my $foo = 1'

But it warns for "our" variables.  Witness:

$ perl -wle 'our $foo = 1'
 Name "main::foo" used only once: possible typo at -e line 1.

It's weird.
And also annoying because most of my programs/modules have

our $debug = 0;    # but not necessarily further used

John Lin





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

Date: 29 Jan 2001 02:03:33 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Finding unused variables ?
Message-Id: <slrn979jrl.sh1.abigail@tsathoggua.rlyeh.net>

John Lin (johnlin@chttl.com.tw) wrote on MMDCCVIII September MCMXCIII in
<URL:news:952h0h$lrk@netnews.hinet.net>:
$$ "Abigail" wrote
$$ > -w *might* warn you for unused variables; but not for
$$ > my()ed variables. Witness:
$$ >
$$ >     $ perl -wle '$foo = 1'
$$ >     Name "main::foo" used only once: possible typo at -e line 1.
$$ >     $ perl -wle 'my $foo = 1'
$$ 
$$ But it warns for "our" variables.  Witness:
$$ 
$$ $ perl -wle 'our $foo = 1'
$$  Name "main::foo" used only once: possible typo at -e line 1.
$$ 
$$ It's weird.

our() is weird, confusing, and should be avoided. Scoping turns out to
be one of the most difficult things to grasp for new Perl programmers -
why it had to be made more difficult with our() I fail to understand.

Let not let the fact that "our" and "my" as English word are in the
same grammatical class give you the impression that our()ed variables
and my()ed variables are in the same class. Far, far from that. my()ed
variables are lexicals. our()ed variables are plain old package vars.

$$ And also annoying because most of my programs/modules have
$$ 
$$ our $debug = 0;    # but not necessarily further used

Assuming $debug is placed at the top of your program/module, why not:

    my $debug = 0;


Abigail
-- 
perl -we 'eval {die ["Just another Perl Hacker\n"]}; print ${${@}}[$#{@{${@}}}]'


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

Date: Mon, 29 Jan 2001 01:05:43 GMT
From: Joel Nelson <extramail@home.com>
Subject: how do I use 'strict' and 'vars'
Message-Id: <3A74C1AD.F664EBAE@home.com>

In my typical cgi scripts I have an '&initialize' subroutine I call
right away.  It will declare global variables other subroutines will
need to access.  When I use 'strict' I get a lot of :

Global symbol $soAndSo requires explicit package name at scriptName.cgi
line 22

I would like to use strict to make sure my code is good and for
debugging.  If I declare variables using 'my' they are not global.  If
I don't use 'my' I get the above warnings.  From reading it looks like I
should use 'vars'.  Can someone explain this or point me to some
documentation that covers it?

Thanks!

Joel



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

Date: Mon, 29 Jan 2001 01:19:34 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: how do I use 'strict' and 'vars'
Message-Id: <3a74c526.16d7$34e@news.op.net>

In article <3A74C1AD.F664EBAE@home.com>,
Joel Nelson  <extramail@home.com> wrote:
>I would like to use strict to make sure my code is good and for
>debugging.  If I declare variables using 'my' they are not global.  If
>I don't use 'my' I get the above warnings.  From reading it looks like I
>should use 'vars'.  Can someone explain this or point me to some
>documentation that covers it?

http://perl.plover.com/FAQs/Namespaces.html
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: 29 Jan 2001 01:19:35 GMT
From: abigail@foad.org (Abigail)
Subject: Re: how do I use 'strict' and 'vars'
Message-Id: <slrn979h97.rro.abigail@tsathoggua.rlyeh.net>

Joel Nelson (extramail@home.com) wrote on MMDCCVIII September MCMXCIII in
<URL:news:3A74C1AD.F664EBAE@home.com>:
&& In my typical cgi scripts I have an '&initialize' subroutine I call
&& right away.  It will declare global variables other subroutines will
&& need to access.  When I use 'strict' I get a lot of :
&& 
&& Global symbol $soAndSo requires explicit package name at scriptName.cgi
&& line 22
&& 
&& I would like to use strict to make sure my code is good and for
&& debugging.  If I declare variables using 'my' they are not global.  If
&& I don't use 'my' I get the above warnings.  From reading it looks like I
&& should use 'vars'.  Can someone explain this or point me to some
&& documentation that covers it?


    man vars
    man strict


Could it have been more obvious?


Abigail
-- 
$_ = "\112\165\163\1648\141\156\157\164\150\145\1628\120\145"
   . "\162\1548\110\141\143\153\145\162\0128\177"  and &japh;
sub japh {print "@_" and return if pop; split /\d/ and &japh}


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

Date: Sun, 28 Jan 2001 23:38:28 GMT
From: Christer Ekholm <chrekh@chello.se>
Subject: Re: How to make Perl wait
Message-Id: <86r91njlmt.fsf@jane.localdomain>

jimtaylor5@aol.com (Jimtaylor5) writes:

> I've written a perl program which writes out a form with certain
> options, and I want to force everyone to answert the question within
> "say 60 seconds." Where, if not, my perl program would write to a
> file and go to another page. The part I am having problems with is
> having perl wait. Does anyone know of an effective way to do this? I
> tried sleep(60); at the end of the printout. That waited alright,
> but it didn't allow any html to be printed to screen until after the
> 60 seconds. Of course then the program writes to file and goes on to
> the next page. Can anytone help me with this PLEASE!

You need to set up a signal-handler for $SIG{ALRM} and call alarm.
see "perldoc -f alarm"

/Christer


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

Date: Sun, 28 Jan 2001 23:29:42 GMT
From: tigra@sky.deep.ru
Subject: Re: How to make Perl wait
Message-Id: <952a0v$hns$1@nnrp1.deja.com>

In article <20010128162737.16317.00001537@ng-cn1.aol.com>,
  jimtaylor5@aol.com (Jimtaylor5) wrote:
> I've written a perl program which writes out a form with certain
options, and I
> want to force everyone to answert the question within "say 60
seconds." Where,
> if not, my perl program would write to a file and go to another page.
The part
> I am having problems with is having perl wait. Does anyone know of an
effective
> way to do this? I tried sleep(60); at the end of the printout. That
waited
> alright, but it didn't allow any html to be printed to screen until
after the
> 60 seconds. Of course then the program writes to file and goes on to
the next
> page. Can anytone help me with this PLEASE!
>

I haven't caught the algorythm you use. As I understood:
1) User sends a request for an URI.
2) You respond with a html page (not finished yet).
3) Then you wait for a responce.

The question is: how could you manage redirecting the user from the
stage of sending him data? Some code could be helpful (if it doesn't tak
much space)


Sent via Deja.com
http://www.deja.com/


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

Date: Sun, 28 Jan 2001 23:36:11 GMT
From: bits101010@my-deja.com
Subject: Re: How to make Perl wait
Message-Id: <952adb$htl$1@nnrp1.deja.com>

Jim,

Use alarm... look at perlfunc and perlipc man pages.
Here's an example (probably work on unix only):

#!/usr/local/bin/perl
$timeout = 5;
    eval {
        local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
        alarm $timeout;
        print "Enter an int: ";
        $a = <STDIN>;
        print "Enter a char: ";
        $a = <STDIN>;
        print "Enter a word: ";
        $a = <STDIN>;
        alarm 0;
    };
    if ($@) {
        die unless $@ eq "alarm\n";   # propagate unexpected errors
        # timed out
        print "Time out ($timeout)\n";
    }
    else {
        # didn't
    }
### end of example
Winston.

In article <20010128162737.16317.00001537@ng-cn1.aol.com>,
  jimtaylor5@aol.com (Jimtaylor5) wrote:
> I've written a perl program which writes out a form with certain
options, and I
> want to force everyone to answert the question within "say 60
seconds." Where,
> if not, my perl program would write to a file and go to another page.
The part
> I am having problems with is having perl wait. Does anyone know of an
effective
> way to do this? I tried sleep(60); at the end of the printout. That
waited
> alright, but it didn't allow any html to be printed to screen until
after the
> 60 seconds. Of course then the program writes to file and goes on to
the next
> page. Can anytone help me with this PLEASE!
>


Sent via Deja.com
http://www.deja.com/


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

Date: Mon, 29 Jan 2001 00:55:46 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: How to make Perl wait
Message-Id: <Pine.LNX.4.30.0101290048440.20990-100000@lxplus003.cern.ch>

On 28 Jan 2001, Jimtaylor5 wrote:

[lines now re-flowed to usenet conventions]

> I've written a perl program which writes out a form with certain
> options, and I want to force everyone to answert the question
> within "say 60 seconds." Where, if not, my perl program would
> write to a file and go to another page. The part I am having
> problems with is having perl wait.

Not really: the part you are having problems with is understanding how
the WWW works, and that's off-topic for perl.  From what you're
describing, you're involved in writing a CGI script, and that would be
on-topic for comp.infosystems.www.authoring.cgi

User requests URL, server fires up CGI process, CGI process returns
web page and terminates, end of story.  At some later point in time,
user submits form, server fires up (same of other) CGI process
asynchronously, it's your task as a programmer to associate that with
the initial instance and work out what you want to do next.  (This is
called "maintaining state" in the jargon).

> Does anyone know of an
> effective way to do this? I tried sleep(60);

Not an appropriate thing to do with server-side processes.

> at the end of the
> printout. That waited alright, but it didn't allow any html to be
> printed to screen until after the 60 seconds.

That's only half your problem.  The instance that wrote the form isn't
going to be the instance which processes its submission, so there's no
point in the first one hanging around like that, even if you found out
how to get the HTML displayed.



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

Date: 29 Jan 2001 01:49:27 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: Re: How to make Perl wait
Message-Id: <20010128204927.08389.00001845@ng-fn1.aol.com>

>Use alarm... look at perlfunc and perlipc man pages.
>Here's an example (probably work on unix only):

Thanks Dude. I really appreciate the direction, and I hope to be able to work
it out now.


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

Date: 29 Jan 2001 01:51:06 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: Re: How to make Perl wait
Message-Id: <20010128205106.08389.00001846@ng-fn1.aol.com>

>You need to set up a signal-handler for $SIG{ALRM} and call alarm.
>see "perldoc -f alarm"
>

Thanks for the hep Dude. 


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

Date: 29 Jan 2001 01:58:27 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: Re: How to make Perl wait
Message-Id: <20010128205827.08389.00001849@ng-fn1.aol.com>

>From what you're
>describing, you're involved in writing a CGI script, and that would be
>on-topic for comp.infosystems.www.authoring.cgi

Yeah, I'm new at this, but actually the printed out form is just a VERY tiny
part of my Perl code, but is giving me the most problem in how to work it out.
Anyway, some good guys here have given me some direction so hopefully i won't
wake you again. 


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

Date: Sun, 28 Jan 2001 23:02:42 GMT
From: "creafin1998" <creafin1998@yahoo.com>
Subject: Re: How to pass $vars to a script from within another script and e-mail results to a group.
Message-Id: <01c0897e$d1f5b7c0$48c249d8@rjuliano>

I tried the following and get no content in the output file or e-mail. 
Please advise.

use LWP::Simple;

$my_url = "http://www.mydomain.com/myscript.cgi";
$fileo = "/path/out.html";
$group = 'user1@mydomain.com';

$prog = "get '$my_url'";

`$prog > $fileo`;
`$prog | mail $group`;

Thanks in advance.



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

Date: Sun, 28 Jan 2001 19:31:27 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: How to pass $vars to a script from within another script and e-mail results to a group.
Message-Id: <comdog-737F6E.19312728012001@news.panix.com>

In article <01c0897e$d1f5b7c0$48c249d8@rjuliano>, "creafin1998" 
<creafin1998@yahoo.com> wrote:

> I tried the following and get no content in the output file or e-mail. 
> Please advise.


please crosspost rather than posting the same message separately
to several groups.  see my answer in the first group where i saw
this. ;)

-- 
brian d foy <comdog@panix.com>



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

Date: Sun, 28 Jan 2001 17:23:30 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: mod_perl Perl:
Message-Id: <comdog-DDFC6B.17233028012001@news.panix.com>

In article <951n2o$2dt$1@nnrp1.deja.com>, Rob <a565a87@my-deja.com> 
wrote:

> 1.  It is my understanding that mod_perl lends a complete, native Perl
> API to Apache, making Apache higher performance than if conventional
> CGI scripting is used.  Is this the case?

just about.

> 2.  Does mod_perl really in fact simply encapsulate whatever existing
> installation of perl that I have on my machine. 

it uses whichever version with which it was compiled.

-- 
brian d foy <comdog@panix.com>



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

Date: 29 Jan 2001 01:16:48 GMT
From: Martin Julian DeMello <mdemello@kennel.ruf.rice.edu>
Subject: Re: New way to learn Perl?
Message-Id: <952ga0$24o$3@joe.rice.edu>

Wyzelli <wyzelli@yahoo.com> wrote:

> Try answers(S).  In some cases it is two ( or more answers) required before
> being marked 'correct'

> I found it a bit annoying.

What annoyed me is that it never told me the correct answer. Rather limits
its usefulness as a learning aid.

-- 
Martin DeMello


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

Date: Mon, 29 Jan 2001 11:35:20 +1100
From: "Chris W" <chrisw@dynamite.com.au>
Subject: Re: Perl is bad at (very) simple math!
Message-Id: <aX2d6.41$aR.1177@news0.optus.net.au>

"Michael Stopp" <stopp@eye.ch> wrote in message
news:3A6EB808.D80DD247@unibas.ubaclu.ch...
> Can anybody explain why a perl script as simple as this can fail?
> $a = 5.1;
> $b = 5;
> print $a-$b, "\n";
> This produces:
> 0.0999999999999996

Yep, binary representation.

There are arbitrary precision maths modules available:

#perl -w
use strict;
use Math::BigFloat;
my $a = Math::BigFloat->new('5.1');
my $b = Math::BigFloat->new('5.0');
my $c = $a->fsub($b);
printf "%3.2f", $c;
__END__





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

Date: Sun, 28 Jan 2001 23:09:24 GMT
From: bits101010@my-deja.com
Subject: Re: Perl on 98
Message-Id: <9528r0$gp6$1@nnrp1.deja.com>

Anton,

If you installed Perl before PWS, you should try to reinstall Perl.

Is your version from ActiveState? If not, you should get it from
http://www.activestate.com/Products/ActivePerl/Download.html

Winston.

In article <3A7496EE.CC24E059@chello.nl>,
  Anton Pieters <a.pieters@chello.nl> wrote:
> I seem to have a problem running Perl on windows 98. As soon as I
start
> a CGI-script it bursts out in a DOS window and closes again. I have
got
> WPS installed and running. I just can't get it going. Is there someone
> who can help me with this?
>
> ANton
>
>


Sent via Deja.com
http://www.deja.com/


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

Date: Sun, 28 Jan 2001 20:47:36 -0500
From: "Richard Muller" <rlmuller(at)msn.(dot)(deletethis).com>
Subject: Problem renaming under Win32
Message-Id: <OMtDLUZiAHA.281@cpmsnbbsa07>

Hi all,

Sorry for posting so many questions, but I just decided to concentrate more
Perl than my "native language" C++, hence more questions as I try to come up
to speed.

The following code is intended to rename files I downloaded in the past when
two-digit years were adequate. But names like that don't sort
satisfactorily.  I decided to try and rename them automatically.  But my
rename  command failed.

Can anyone suggest why rename failed?

 ...
while ( glob($dir . "\\*") )
{
     if( /WDJ-099/i )
    {
          print "$_\n";
          $RevisedName = s/WDJ-099/WDJ1999./i;
          my $nRet = rename($_, $RevisedName);
          print "$_ <== " . ($nRet?"":"not") . " changed\n";
          $nFilesChanged++ if( $RevisedName !~ /WDJ-099/i );
    }
}

This produced:

K:\_Downloads\_Publications\WDJ\WDJ-09901.zip
K:\_Downloads\_Publications\WDJ\WDJ1999.01.zip <== not changed
K:\_Downloads\_Publications\WDJ\WDJ-09902.zip
K:\_Downloads\_Publications\WDJ\WDJ1999.02.zip <== not changed

Windows Explorer confirms that the rename failed.

Regards,
Richard




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

Date: Mon, 29 Jan 2001 09:09:12 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: ternary conditional operator
Message-Id: <952fv8$kfn@netnews.hinet.net>

"Uri Guttman" wrote
> >>>>> "JH" == John Hall writes:
>
>   JH> Why does this print no? I can't figure it out:
>   JH> $director = "else";
>   JH> $director =~ /else/ ? $redirto = "yes" : $redirto = "no";
>
> your precedence is wrong. ?: binds tighter than =

I couldn't figure it out.  I [ use O 'Deparse' ] to get this deparsing

$director =~ /else/ ? ($redirto = "yes") : $redirto = "no";

It looks good.  Just like a normal [ =~ ? ( = ) : ( = ) ] .
Could you further explain what's wrong here?

Thank you.

John Lin





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

Date: 29 Jan 2001 01:27:09 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: ternary conditional operator
Message-Id: <952gtd$cmt$4@bob.news.rcn.net>

John Lin <johnlin@chttl.com.tw> wrote:
> "Uri Guttman" wrote
>> >>>>> "JH" == John Hall writes:
>>
>>   JH> Why does this print no? I can't figure it out:
>>   JH> $director = "else";
>>   JH> $director =~ /else/ ? $redirto = "yes" : $redirto = "no";
>>
>> your precedence is wrong. ?: binds tighter than =

> I couldn't figure it out.  I [ use O 'Deparse' ] to get this deparsing

> $director =~ /else/ ? ($redirto = "yes") : $redirto = "no";

> It looks good.  Just like a normal [ =~ ? ( = ) : ( = ) ] .
> Could you further explain what's wrong here?

Your "normal" example has two sets of parens.  The deparsed output has 
only one set.  What Uri was saying is that the *entire* ?: operator 
(which, as you remember, has three operands) binds tighter than =.  The 
$redirto="yes" will be evaluated properly because it's the second operand 
of the ternary conditional, but the $redirto="no" won't be evaluated as 
such because the $redirto gets parsed as the third operand of the 
conditional, and the entire conditional is taken as the left-hand sign of 
the final =.



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

Date: 29 Jan 2001 01:27:29 GMT
From: chenb@blue.seas.upenn.edu (Benjamin Chen)
Subject: Unicode and URL encoding
Message-Id: <952gu1$rtm$1@netnews.upenn.edu>

Hi,

  I was trying to create a script which will take in foreign language character
sets that use Unicode (Chinese, Korean, etc) and ran into a slight snag.
When the user enters in the characters into the textfield and submit the form
(I use a POST method) the majority of the time, I get something like this as
the outcome: &#19971;
The outcome should have been a "random" assortment of ascii characters.  
But, on certain types of input, the correct ascii characters are printed
out.  Is there something I would have to do to get the correct things to
print out?  Thanks!

-Ben

--


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

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 V10 Issue 163
**************************************


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