[18316] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 484 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 13 21:05:36 2001

Date: Tue, 13 Mar 2001 18:05:10 -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: <984535509-v10-i484@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 13 Mar 2001     Volume: 10 Number: 484

Today's topics:
    Re: "uninitiatlized value" errors? <jazrant@zsc.nrcan.zc.ca>
    Re: "uninitiatlized value" errors? <mjcarman@home.com>
        An oddity with 'redo'? <bernie@fantasyfarm.com>
    Re: An oddity with 'redo'? <elijah@workspot.net>
    Re: Behavior of => after newline nobull@mail.com
        Best Perl for Newbie <martin@kirtleym.greatxscape.net>
    Re: Best Perl for Newbie (Tad McClellan)
    Re: Can a regex do this? <bart.lateur@skynet.be>
    Re: converting text to hex? <bart.lateur@skynet.be>
        core dump with DBI connect <bing-du@tamu.edu>
    Re: difference between <> and <ARGV> <galen.menzel@mail.utexas.edu>
    Re: Does Perl have an un-getc (Greg Bacon)
    Re: LWP problem (Charles DeRykus)
    Re: LWP problem <djmarcus@ex-pressnet.com>
    Re: LWP problem (Randal L. Schwartz)
    Re: LWP problem <djmarcus@ex-pressnet.com>
    Re: LWP problem <djmarcus@ex-pressnet.com>
        oraperl to dbd <syndi@ucalgary.ca>
        PerlBuilder 2.0 <djmarcus@ex-pressnet.com>
        reference problems <hammy@charter.net>
        reference problems <hammy@charter.net>
        Run a combination of programs <johnlin@chttl.com.tw>
        use URI::URL; <jhall@ifxonline.com>
    Re: use URI::URL; <tony_curtis32@yahoo.com>
    Re: Using the 'use' directive, and page reloading in a  <galen.menzel@mail.utexas.edu>
    Re: Why glob doesn't take a list? (Martien Verbruggen)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 13 Mar 2001 18:32:21 -0500
From: "John A. Grant" <jazrant@zsc.nrcan.zc.ca>
Subject: Re: "uninitiatlized value" errors?
Message-Id: <98mars$5tm17@nrn2.NRCan.gc.ca>

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9asvgb.vs3.tadmc@tadmc26.august.net...
> John A. Grant <jazrant@zsc.nrcan.zc.ca> wrote:
>
> >    to this:
> >        sub somefunc($$$)
> >        {
> >            my ($a,$b,$c)=@_;
> >        }
> >
> >    It was either that or this:
> >        sub somefunc
> >        {
> >            my ($a,$b,$c)=@_;
> >        }
>
>
> (This last one (no prototype) gets my vote)
    [...]
> Stand on the shoulders of a giant, and read:
>    http://www.perl.com/pub/language/misc/fmproto.html
> wherein all will be revealed.

    INDEED! Add my vote to yours.  I have just removed all
    (PROTO) from my functions.

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here






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

Date: Tue, 13 Mar 2001 16:56:03 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: "uninitiatlized value" errors?
Message-Id: <3AAEA583.756F0AEA@home.com>

First, a quick summary of this branch of the thread:

John>  if($cc) ...

Tad>   if( defined $cc ) ...

Garry> There's something else going on here.

John A. Grant <jazrant@zsc.nrcan.zc.ca> wrote:
>
> [A]fter I agreed with Tad's "if(defined $cc)" suggestion,
> I see you [Garry] are disagreeing with with him and saying it 
> is ok. Both stances seem reasonable to me, but I don't know
> enough about it.  Who is right?

Obi-wan might say that they both are, depending on your point of view.

In this case, I'd vote with Garry. That's not to say that Tad was wrong,
just maybe a little overzealous. A simple boolean test will suffice
because it looks like $cc shouldn't ever have a defined but false value.
(i.e. 0, '0', or '') It's really a matter of preference, and Tad's
advice is simply indicitive of his.

In general, though, that's not always the case. Sometimes you need to
test definedness. Sometimes (with hash keys) you need to check for
existance. Perl draws subtle distinctions between truth, definedness,
and existance, and you would do well to learn them. If you can get your
hands on a copy of  the Cookbook, look at recipe 5.2. It does a good job
of explaining this.

-mjc


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

Date: Tue, 13 Mar 2001 18:58:41 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: An oddity with 'redo'?
Message-Id: <55ctatc2uvg9eor8ma3aguqevbu47t4guq@news.supernews.net>

'redo' apparently does a *little*bit* of the conditional, rather than
omitting it entirely.  I tried this [w/ Perl 5.004]:

while (defined (my $l = <F>))
{
	[...process $l ...]
    redo if $l ;  # Reprocess the line if there's anything left
}

It appears that it *undefs* the value of the vbl as it does the redo,
although without actually doing the <FILEHANDLE> again..  This isn't a
serious problem to deal with [I just moved the 'my' to being in front of
the while loop] but I was a bit surprised...  Why is the vbl getting
undef'ed?

[REAL CODE:

while (defined (my $l = <STDIN>))
{
    print "Top: $l"  ;
    $l = <STDIN> ;
    last unless $l ;
    print "Bottom: $l" ;
    redo;
}

$ echo -e "abc\ndef\nghi" | perl t.pl 2>&1
Top: abc
Bottom: def
Use of uninitialized value at t.pl line 6, <STDIN> chunk 2.
Top: Bottom: ghi
Top: ghi

I don't understand why I got the 'initialized' the first time I did the
'redo... nor do I understand why I *didn't* get it the second time I did
the redo.  What am I missing?  Tnx...

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: 14 Mar 2001 00:28:12 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: An oddity with 'redo'?
Message-Id: <eli$0103131919@qz.little-neck.ny.us>

In comp.lang.perl.misc, Bernie Cosell  <bernie@fantasyfarm.com> wrote:
> 'redo' apparently does a *little*bit* of the conditional, rather than
> omitting it entirely.  I tried this [w/ Perl 5.004]:

I doubt that.

> while (defined (my $l = <STDIN>))
> {
>     print "Top: $l"  ;
>     $l = <STDIN> ;
>     last unless $l ;
>     print "Bottom: $l" ;
>     redo;
> }

I think what you are seeing here is that since $l is scoped to
this block with 'my' and since 'my' has a runtime effect of 
setting the variable (even if the is to 'undef') that you are
seeing that happen.

Since 'redo' is block oriented, even when there is no conditional,
try this as a fix:

  while (defined (my $l = <STDIN>))
  {{
      print "Top: $l"  ;
      $l = <STDIN> ;
      last unless $l ;
      print "Bottom: $l" ;
      redo;
  }}

The 'redo' will restart the inner block, but the 'my' is for the
outer block.

Elijah
------
sees potential for a JAPH in this obscure tidbit


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

Date: 13 Mar 2001 23:38:23 +0000
From: nobull@mail.com
Subject: Re: Behavior of => after newline
Message-Id: <u9n1apb5ow.fsf@wcl-l.bham.ac.uk>

ansok@alumni.caltech.edu (Gary E. Ansok) writes:

> I discovered something about the behavior of => when the statement
> is broken across two lines, and was wondering whether there is a
> reason for this behavior.

> But I'm still curious whether this behavior was deliberate or
> just a parser artifact.  "perlop" says that => quotes the word
> to its left, which is consistent with the observed behavior.
> But it seems to go against the feeling of "newline is just like
> other whitespace (except in specific line-oriented contexts)."

It is a parser artifact.  The qouting action of => is implemented by
an ugly hack.

I noticed this a few weeks back when I patched the parser so that the
=> would quote words that look like version number constants.

print v65 => 1; # Without my patch this prints a1

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 12 Mar 2001 23:18:26 -0000
From: "Martin" <martin@kirtleym.greatxscape.net>
Subject: Best Perl for Newbie
Message-Id: <98m9jv$pih$1@news5.svr.pol.co.uk>

Hi,

Can anybody tell what the best perl book available is which targets someone
who knows nothing/little about programming.

Ideally a book which starts of gradual and refer to again and again.

Thanks
Martin




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

Date: Tue, 13 Mar 2001 19:52:38 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Best Perl for Newbie
Message-Id: <slrn9atg6m.1ek.tadmc@tadmc26.august.net>

Martin <martin@kirtleym.greatxscape.net> wrote:

>Can anybody tell what the best perl book available is which targets someone
>who knows nothing/little about programming.


   perldoc -q book

Offers info on Perl books.

"Elements of Programming with Perl" [1] by Andrew Johnson 
is often recommended.


Perl book stuff:

   "Camel Critiques":
      http://language.perl.com/critiques

   "Choosing a Perl Book"
      http://www.perl.com/pub/2000/06/27/perlbook.html

   Randal's book page:
      http://www.stonehenge.com/books/

   Uri's book page:
      http://www.sysarch.com/cgi-bin/perl_books

   O'Reilly's Perl page:
      http://perl.oreilly.com/

   Manning's Perl page:
      http://www.manning.com/perl.html



[1] I work for the publisher though, so take my recommendation
    with the appropriate amount of skepticism, though I
    recommended the book even before I started with Manning.

-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 13 Mar 2001 23:57:30 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Can a regex do this?
Message-Id: <g0dtat42mvpjbkgupm01qdhdg85j7irtil@4ax.com>

Tad McClellan wrote:

>>Operators do things. The pattern match operator does the matching,
>>the regex is just one of the operands.
>                              ^^^^^^^^
>Errr, arguments?

Parameters!

Gee, what a choice. I never really know for sure which word to use.

-- 
	Bart.


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

Date: Wed, 14 Mar 2001 00:05:39 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: converting text to hex?
Message-Id: <23dtats4i03lkbfqsr486m696v0t21n6ck@4ax.com>

Eric wrote:

>how do i convert text to hex code?
>like to covert "a" to "61" etc...

Here's one good possible use for the old style ( unpack 'C' ) instead of
ord: because it can accept a string of any length, and returns a list of
character codes.

	@charcodes = unpack 'C*', $string;

Sure beats ( map { ord } split //, $string ), wouldn't you think?

	local($,,$\) = (" ", "\n");
	open IN, shift || $0 or die "Cannot open file: $!";
	binmode IN;
	while(read IN, $_, 24) {
	    print map { sprintf '%02X', $_ } unpack 'C*', $_
	}

-- 
	Bart.


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

Date: Tue, 13 Mar 2001 17:34:44 -0600
From: Bing Du <bing-du@tamu.edu>
Subject: core dump with DBI connect
Message-Id: <3AAEAE94.9DB596AD@tamu.edu>

I run the following script and got 'zsh: bus error (core dumped)'.  Can
anybody tell me what is wrong with this script?

=================
#!/usr/local/bin/perl -w

use strict;
use DBI;
use DBD::Oracle;

my $db = "TAMU";
$ENV{ORACLE_HOME} = "/oracle/app/oracle/product/8.0.5";
my $username = "dbread";
my $password = "xxxx";

# Connect to Oracle database
my $dbh = DBI->connect("dbi:Oracle:$db", $username, $password) || die
"failed\n";

print "connected\n";
=================

The server should be running because

% sqlplus dbread/xxxx@TAMU

works just fine.    Any ideas?

Thanks,

Bing



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

Date: Tue, 13 Mar 2001 18:24:48 -0600
From: Galen Menzel <galen.menzel@mail.utexas.edu>
Subject: Re: difference between <> and <ARGV>
Message-Id: <3AAEBA50.E810E2C0@mail.utexas.edu>

John Lin wrote:
> 
> Dear all,
> 
> Is there any difference between <> and <ARGV>?

From Programming Perl, 2nd Edition:

ARGV: The special filehandle that iterates over command line filenames in
@ARGV.  Usually written as the null filehandle in <>.

> 
> P.S.  This question is aroused from a bug in my program
> which processes input from @ARGV
> 
>     while(<>) { print }
> 
> It will hang there to wait for STDIN inputs when @ARGV is empty.
> I just want @ARGV not STDIN, so I cutesily modified it into
> 
>     while(<ARGV>) { print }
> 
> thinking that ARGV is only related to @ARGV, not STDIN.

What about something like

if (scalar @ARGV) {
    while (<>) {
	print;
    }
}

galen


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

Date: Tue, 13 Mar 2001 23:14:02 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Does Perl have an un-getc
Message-Id: <tatadq86q9u218@corp.supernews.com>

In article <tjvr6.57615$Fz.12400366@typhoon.austin.rr.com>,
    Tim Tracy <ttracy@houston.rr.com> wrote:

: Thanks for your prompt reply. It will experiment with your suggestions.

Actually my program has a bug.  I thought the getc() in the while
condition had an implicit defined() check, but it doesn't.  The code
should be

    #! /usr/local/bin/perl -w

    use strict;

    use Fcntl qw/ SEEK_CUR /;

    open IN, "input" or die "$0: open input: $!\n";

    my $back_that_ass_up = 1;

    # add check for defined()-ness; was
  # while (my $c = getc IN) {
    while ( defined(my $c = getc IN) ) {
        printf "GOT: '$c' (0x%02x)\n", unpack "C" => $c;

        if ($c eq '3' && $back_that_ass_up) {
            seek IN, -2, SEEK_CUR or die "$0: seek: $!\n";
            $back_that_ass_up = 0;
        }
    }

To tickle the bug, try an input file with '120123abc' on a line.

Greg
-- 
If there be any among us who wish to dissolve the Union or to change its
republican form, let them stand undisturbed, as monuments of the safety
with which error of opinion may be tolerated where reason is left free to
combat it.    -- Thomas Jefferson


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

Date: Tue, 13 Mar 2001 23:53:32 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: LWP problem
Message-Id: <GA5uD9.9r5@news.boeing.com>

In article <taslrnclsis004@corp.supernews.com>,
David J. Marcus <djmarcus@ex-pressnet.com> wrote:
>Hi
>
>I am new to Perl (very impressed and love it so far). I do have a lot of
>experience in other languages (c/c++, java, mumps, etc).
>
>I am trying to access a common website (www.yahoo.com).
>
>I downloaded 5.6 (for Windows) and CPAN.
>
>I tried the simple program provided on CPAN:
>    use LWP:Simple;
>    my $content = get("http://www.yahoo.com");
>    print "LWP::Simple: get of Yahoo: ", $content, "\n";
>
>I get an error (apparently after the operation times out):
>    Request failed: Can't connect to www.yahoo.com:80 <Bad hostname
>'www.yahoo.com'>
>
>I am running on Windows 2000.
>
>I am able to access the internet via the browser and other programs
>including custom ones written in C++/MFC.
>
>I have tried using a network sniffer to see what packets go out, but it
>doesn't look like anything goes out.
>
>I am wondering if there are some settings that I need to initialize to get
>things to work.
>
Could a proxy setting be absent... ? LWP::Simple just grabs
the proxy setting from the environment.

hth,
--
Charles DeRykus


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

Date: Tue, 13 Mar 2001 19:22:31 -0500
From: "David J. Marcus" <djmarcus@ex-pressnet.com>
Subject: Re: LWP problem
Message-Id: <tatee2ovjjvk48@corp.supernews.com>

Hi

Thanks for the idea...

While waiting for some more feedback from the group I looked into the proxy
possibility. My desktop is sharing an internet connection (to my
cable-modem) through a Windows 98 proxy system. Originally, I didn't think
about the proxy because my MFC/C++ applications work without any proxy
specification but in afterthought I realize that MFC uses the same objects
that the browser does and the browser setting did include a proxy setting.

Now when I set the proxy:
    $agent->proxy(http => "proxyname:80");

The $response->message becomes:
    Protocol scheme '' is not supported.

I am trying to find out what the message means by searching my entire Perl
directory structure. So far, not much luck.

Any ideas would be welcomed.

-TIA
David


"Geoffrey C Kinnel" <Geoffrey.Kinnel@bms.com> wrote in message
news:3AAE6F93.2DF8C4C1@bms.com...
> "David J. Marcus" wrote:
>
> > I tried the simple program provided on CPAN:
> >     use LWP:Simple;
> >     my $content = get("http://www.yahoo.com");
> >     print "LWP::Simple: get of Yahoo: ", $content, "\n";
> >
> > I get an error (apparently after the operation times out):
> >     Request failed: Can't connect to www.yahoo.com:80 <Bad hostname
> > 'www.yahoo.com'>
>
> While the error implies DNS failure, if you can get there by other means,
then
> it's probably not DNS. Do you use an http proxy? If you do, you have to
let
> LWP::Simple know.
>
> gk
>




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

Date: 13 Mar 2001 16:34:32 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: LWP problem
Message-Id: <m14rwxi3xj.fsf@halfdome.holdit.com>

>>>>> "David" == David J Marcus <djmarcus@ex-pressnet.com> writes:

David> Now when I set the proxy:
David>     $agent->proxy(http => "proxyname:80");

David> The $response->message becomes:
David>     Protocol scheme '' is not supported.

Just guessing, but I think you have to say:

        $agent->proxy(http => 'http://proxyname:80');

I'm sure I'll be corrected rapidly if I'm wrong. :)

-- 
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: Tue, 13 Mar 2001 19:43:58 -0500
From: "David J. Marcus" <djmarcus@ex-pressnet.com>
Subject: Re: LWP problem
Message-Id: <tatfm9h8t3uqe9@corp.supernews.com>

EUREKA!

Thanks folks... problem solved. By specifying the 'http://' as part of the
firewall name my script is working.

I guess my only lamentation is what would I have done without this group?

By the way... how does one look up the meanings behind any particular error
message?

-Thanks again
David

"Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
news:m14rwxi3xj.fsf@halfdome.holdit.com...
> >>>>> "David" == David J Marcus <djmarcus@ex-pressnet.com> writes:
>
> David> Now when I set the proxy:
> David>     $agent->proxy(http => "proxyname:80");
>
> David> The $response->message becomes:
> David>     Protocol scheme '' is not supported.
>
> Just guessing, but I think you have to say:
>
>         $agent->proxy(http => 'http://proxyname:80');
>
> I'm sure I'll be corrected rapidly if I'm wrong. :)
>
> --
> 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: Tue, 13 Mar 2001 20:04:25 -0500
From: "David J. Marcus" <djmarcus@ex-pressnet.com>
Subject: Re: LWP problem
Message-Id: <tatgsld0aafn85@corp.supernews.com>

My personal thanks to Randal for being so helpful (and so quickly).

To all: Thanks for taking the time to reply. It turns out that your
suggestions were on the mark. My script is now working as advertised... now
I can get back to learning Perl. Hopefully I will be able to solve future
stumbles directly.

I am impressed by the quality of the responses (and how quickly) by the
group. Re-enforces my belief in the process.

-Thanks again
David



"David J. Marcus" <djmarcus@ex-pressnet.com> wrote in message
news:tatfm9h8t3uqe9@corp.supernews.com...
> EUREKA!
>
> Thanks folks... problem solved. By specifying the 'http://' as part of the
> firewall name my script is working.
>
> I guess my only lamentation is what would I have done without this group?
>
> By the way... how does one look up the meanings behind any particular
error
> message?
>
> -Thanks again
> David
>
> "Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
> news:m14rwxi3xj.fsf@halfdome.holdit.com...
> > >>>>> "David" == David J Marcus <djmarcus@ex-pressnet.com> writes:
> >
> > David> Now when I set the proxy:
> > David>     $agent->proxy(http => "proxyname:80");
> >
> > David> The $response->message becomes:
> > David>     Protocol scheme '' is not supported.
> >
> > Just guessing, but I think you have to say:
> >
> >         $agent->proxy(http => 'http://proxyname:80');
> >
> > I'm sure I'll be corrected rapidly if I'm wrong. :)
> >
> > --
> > 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: Tue, 13 Mar 2001 16:30:08 -0800
From: "Joseph Mak" <syndi@ucalgary.ca>
Subject: oraperl to dbd
Message-Id: <98mee1$j76$1@nserve1.acs.ucalgary.ca>

Hi,

I'm moving some cgi files from oraperl to dbd and I was wondering if anyone
could help me with a line of code that I'm not sure of how to change.  I'm
not exactly sure what the DBD equivalent of "Ora_do" is.


sub Remove_Favorite {
    &ora_do ($lda, "DELETE FROM UserProducts WHERE
(Email='$fields{'EMAIL'}') AND (ProductID='$fields{'PRODID'}')");

    &Show_Favorites;
}


sub Add_Favorite {
    &ora_do ($lda, "INSERT INTO UserProducts (Email, ProductID, DateAdded)
VALUES ('$fields{'EMAIL'}', '$fields{'PRODID'}', sysdate)");

    &Show_Favorites;
}


any help is very appreciated.

Thanks,

Joe





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

Date: Tue, 13 Mar 2001 20:09:32 -0500
From: "David J. Marcus" <djmarcus@ex-pressnet.com>
Subject: PerlBuilder 2.0
Message-Id: <tath68733kb82d@corp.supernews.com>

Hi

I am new to Perl (but not to programming). I have decided to get serious
with Perl. Consequently I just downloaded for evaluation PerlBuilder 2.0 as
an IDE for working in Perl.

Before I actually plunk my money on the product, I would love some feedback
on:
    1) Quality of the product (how complete, reliable, ...)
    2) Whether the 'Pro' version is worth the extra money
    3) Whether there is a better product out there (I'm running Windows
2000)
    4) What are the products deficiencies/limitations that *are not*
mentioned in their literature
    5) Quality of the product support
    6) Any other comments you think are helpful

-TIA
David




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

Date: Tue, 13 Mar 2001 18:27:10 -0600
From: "Eric Schultz" <hammy@charter.net>
Subject: reference problems
Message-Id: <tatenso78j3pe1@corp.supernews.com>

I'm having a problem with a program. Everytime I run this code:

for ($j=0;$j<@workingmatches;$j++){
($workingname,$workingpart,$workingnote) = split(/\+/,$workingmatches[$j]);
$thisnum = $j+1;
$thisthingone = $thisnum . "match1";
$thisthingtwo = $thisnum . "match2";
$thisthingthree = $thisnum . "match3";

$$thisthingone = "$workingname";
$$thisthingtwo = "$workingpart";
$$thisthingthree = "$workingnote";
}

I get an error message that says I'm trying to change read only variable at
these lines:

$$thisthingone = "$workingname";
$$thisthingtwo = "$workingpart";
$$thisthingthree = "$workingnote";

Can anyone tell me why and how I can fix this? Thanks in advance...

Eric






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

Date: Tue, 13 Mar 2001 20:01:05 -0600
From: "Eric Schultz" <hammy@charter.net>
Subject: reference problems
Message-Id: <tatk8c435il4f6@corp.supernews.com>

I'm having a problem with a program. Everytime I run this code:

for ($j=0;$j<@workingmatches;$j++){
($workingname,$workingpart,$workingnote) = split(/\+/,$workingmatches[$j]);
$thisnum = $j+1;
$thisthingone = $thisnum . "match1";
$thisthingtwo = $thisnum . "match2";
$thisthingthree = $thisnum . "match3";

$$thisthingone = "$workingname";
$$thisthingtwo = "$workingpart";
$$thisthingthree = "$workingnote";
}

I get an error message that says I'm trying to change read only variable at
these lines:

$$thisthingone = "$workingname";
$$thisthingtwo = "$workingpart";
$$thisthingthree = "$workingnote";

Can anyone tell me why and how I can fix this? Thanks in advance...

Eric





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

Date: Wed, 14 Mar 2001 09:43:02 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Run a combination of programs
Message-Id: <98mi8f$3j6@netnews.hinet.net>

Dear all,

One day my colleague asked me, can you run several programs at a time?

He means:

perl prog1.pl prog2.pl prog3.pl

You can also change the combination

perl prog3.pl prog1.pl prog2.pl

to get different running sequence.

He thought of an answer:

perl -n -e eval prog1.pl prog2.pl prog3.pl

But only works for "line by line" programs.

Witty me use "slurp mode" to solve it:

perl -e "local $/; eval <>" prog1.pl prog2.pl prog3.pl

Hey, it only runs prog1.pl, why?

Is there an existing perl idiom for this?

Thank you.

John Lin





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

Date: Tue, 13 Mar 2001 23:09:37 GMT
From: "John Hall" <jhall@ifxonline.com>
Subject: use URI::URL;
Message-Id: <RMxr6.26996$o7.1007677@news1.rdc1.sdca.home.com>


Am using URI::URL so that I can use LWP:UserAgent to check a web-page for
me.

The code works properly, grabbing the page and parsing it, however whenever
I run the script I get this:

Prototype mismatch: sub main::url vs ($;$) at C:/Perl/lib/Exporter.pm line
57.
 Exporter::import('url') called at C:\work\lalala\cgi-bin\adri\login.pl line
8
 main::BEGIN() called at C:\work\lalala\cgi-bin\adri\login.pl line 8
 eval {...} called at C:\work\lalala\cgi-bin\adri\login.pl line 8

I'm not sure what to make of it. Thanks in advance for any suggestions.

my code snippet:

6:    use CGI ':standard';
7:    use LWP::UserAgent;
8:    use URI::URL;

 ...

sub ver_SID {

 $ua = new LWP::UserAgent;
 $verdll = new
URI::URL("http://www.lalala.com/app/cgi/Franchise.dll?Cmd=VerifySession&UID=
$UID&CID=$CID&SessionId=$SID");
 $request = new HTTP::Request('GET', $verdll);
 $response = $ua->request($request);
 $content = $response->content;
 unless ($content =~ /<H1>VALID<\/H1>/) { &output("Bad SID"); }

}




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

Date: 13 Mar 2001 17:19:28 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: use URI::URL;
Message-Id: <87wv9t2r5r.fsf@limey.hpcc.uh.edu>

>> On Tue, 13 Mar 2001 23:09:37 GMT,
>> "John Hall" <jhall@ifxonline.com> said:

> Am using URI::URL so that I can use LWP:UserAgent to
> check a web-page for me.

> The code works properly, grabbing the page and parsing
> it, however whenever I run the script I get this:

> Prototype mismatch: sub main::url vs ($;$) at
> ...

> 6: use CGI ':standard';
> 7: use LWP::UserAgent;
> 8: use URI::URL;

Noth CGI and URI::URL are exporting a method called "url".
One solution would be to make explicit what you want to
use in URI::URL by "require"ing it instead and qualifying
the method names.  Or maybe you could use the URI module,
since the perldoc for URI::URL says

    DESCRIPTION
        This module is provided for backwards compatibility with
        modules that depend on the interface provided by the
        `URI::URL' class that used to be distributed with the
        libwww-perl library.

hth
t
-- 
Just reach into these holes.  I use a carrot.


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

Date: Tue, 13 Mar 2001 18:04:24 -0600
From: Galen Menzel <galen.menzel@mail.utexas.edu>
Subject: Re: Using the 'use' directive, and page reloading in a perl script
Message-Id: <3AAEB588.2D621EFA@mail.utexas.edu>

The NewsBrowser wrote:
> 
> In order to retrieve the values submitted to the script
> via the post method, I put the following line near the top of
> the script:
> 
> use CGI;
> 
> I am told that this enables me to import a package that
> does parsing of the content submitted by the browser.
> 
> However, when I use the param function that is part of this
> package to extract these entered values, it doesn't work;
> nothing at all is displayed.
> 
> When I change the directive above to
> 
> use CGI qw(:all);
> 
> then all is sweetness and light. Does anyone know why this is?

CGI.pm supports object oriented programming and function oriented programming. 
"use CGI;" is used for the OO style and "use CGI qw/:whatever/;" is used for FO
style.  By default CGI.pm doesn't really import much (or maybe anything) into a
script's namespace.  You are expected to create a CGI object and access all of
the functions in CGI.pm as methods on that object.  Arguments to the CGI use
directive tell perl which methods to import into the main namespace as normal
functions.  When these functions are called, they are implicitly called on a
default CGI object which you don't really mess with directly.  Do

perldoc CGI

for more information.  Documentation for CGI.pm can also be found on the web
here:

http://stein.cshl.org/WWW/software/CGI/

I haven't looked at this stuff for a long time, but last time I checked, the
documentation on the web was *much* better than the perldoc stuff.  At a glance
it looks like the perldoc has gotten better, though.

> Also, does anyone know if it is possible to get a perl script
> to cause a new page to be loaded in a browser? For example, if
> on submitting a form, a perl script is invoked, is it possible
> to get the perl script to load one page if certain values are
> entered in the form and another page if they aren't? (Kind of
> like ASP's Response.Redirect(...) or javascript's
> location.href = "...")

I don't know how to do it with CGI.pm, but this will work:

print "Location: http://<URL>\n\n";

Hope that helps.
galen


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

Date: Tue, 13 Mar 2001 23:24:45 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Why glob doesn't take a list?
Message-Id: <slrn9atb1u.nts.mgjv@verbruggen.comdyn.com.au>

On Tue, 13 Mar 2001 10:27:50 GMT,
	Bart Lateur <bart.lateur@skynet.be> wrote:
> Martien Verbruggen wrote:
> 
>>One thing I can think of is that it maybe would be a bit ambiguous
>>what 
>>
>>undef @array;
>>
>>would mean if undef took a list. is it 'undefine all the elements of
>>@array', or is it 'undefine @array itself'.
> 
>>Apart from taking into account how prototyping works in Perl right
>>now, I'd be a bit hard pressed to come up with parsing rules that
>>would always do the Right Thing(TM). And if you take prototyping into
>>account, then I wouldn't even know whether it would be possible
>>without making undef the great exception to the rule (unless it
>>already is :)).
> 
> The parsing rule can be pretty straightforward: make it the same as with
> "local".

You're right. Didn't think of that. my() and our() are two others.

Martien
-- 
Martien Verbruggen                      |
Interactive Media Division              | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

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


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