[21892] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4096 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 11 03:06:23 2002

Date: Mon, 11 Nov 2002 00: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)

Perl-Users Digest           Mon, 11 Nov 2002     Volume: 10 Number: 4096

Today's topics:
        "Can't coerce array into hash" (theIrish1)
    Re: "Can't coerce array into hash" <joe+usenet@sunstarsys.com>
    Re: Convert form input by using a hash <bwalton@rochester.rr.com>
        Filehandles within a sub, passed ot main <jesse_diskill@NOSPAM.hotmail.com>
    Re: Filehandles within a sub, passed ot main <derek@wedgetail.com>
    Re: Filehandles within a sub, passed ot main <mgjv@tradingpost.com.au>
    Re: Filehandles within a sub, passed ot main <derek@wedgetail.com>
    Re: Filehandles within a sub, passed ot main <derek@wedgetail.com>
    Re: Filehandles within a sub, passed ot main <jesse_diskill@NOSPAM.hotmail.com>
    Re: LWP and https <mbudash@sonic.net>
    Re: newbie LWP redirect/cookie question (Bryan Castillo)
    Re: newbie LWP redirect/cookie question (Alan Barclay)
    Re: Object in @INC returning Tie::Handles from INC meth (Bryan Castillo)
        Perl CGI Java help <g0khaasa@cdf.toronto.edu>
        Pls recommend me a good Perl programming environment (Peter Wu)
    Re: Pls recommend me a good Perl programming environmen <tk@WINDOZEdigiserv.net>
    Re: Pls recommend me a good Perl programming environmen <phlipcpp@yahoo.com>
    Re: Pls recommend me a good Perl programming environmen <phlipcpp@yahoo.com>
    Re: Simple array question <bwalton@rochester.rr.com>
        subroutine <rwh2100@hotmail.com>
    Re: subroutine <tk@WINDOZEdigiserv.net>
    Re: subroutine <ak@freeshell.org.REMOVE>
    Re: use strict and my()... <tk@WINDOZEdigiserv.net>
    Re: use strict and my()... (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 10 Nov 2002 20:22:22 -0800
From: irish@babybrains.net (theIrish1)
Subject: "Can't coerce array into hash"
Message-Id: <119f52ad.0211102022.963fd42@posting.google.com>

I'm sure this problem has been visited many many times, but I can't
seem to get past this error:

Can't coerce array into hash at dump.pl line 90.

Any ideas would be appreciated. 

Here is a snippet:

80  my $ref = $orasql->fetchrow_hashref;
81  my @columns = sort keys %$ref;
82  my $mysqlInsert = "INSERT INTO $table (";
83  $mysqlInsert .= join(",", @columns);
84  $mysqlInsert .= ") VALUES (";
85  $mysqlInsert .= join(",", (map {'?'} @columns));
86  $mysqlInsert .= ")";
87  my $insert = $mysql->prepare($mysqlInsert);
88  do {
89  $counter++;
90  $insert->execute(map {$ref->{$_}} @columns); 
91  } while ($ref = $orasql->fetchrow_arrayref);


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

Date: 11 Nov 2002 00:20:46 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: "Can't coerce array into hash"
Message-Id: <m33cq8lm1d.fsf@mumonkan.sunstarsys.com>

irish@babybrains.net (theIrish1) writes:

> Can't coerce array into hash at dump.pl line 90.

[...]

> 80  my $ref = $orasql->fetchrow_hashref;
                                  ^^^^


> 81  my @columns = sort keys %$ref;

[...]

> 88  do {
> 89  $counter++;
> 90  $insert->execute(map {$ref->{$_}} @columns); 
                       ^^^^^^^^^^^^^^^^^^^^^^^^^

That's a hash slice:       @$ref{@columns}

> 91  } while ($ref = $orasql->fetchrow_arrayref);
                                        ^^^^^

The first time through the do {...} block, $ref is
a hashref.  The second time through, $ref is an arrayref.
I'm pretty sure you want to use fetchrow_hashref here 
instead.

-- 
Joe Schaefer        "Code and data are the same, or at least they can be."
                                               -- Rob Pike



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

Date: Mon, 11 Nov 2002 02:42:47 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Convert form input by using a hash
Message-Id: <3DCF191A.60006@rochester.rr.com>

J.C.Castro wrote:

> The script below is an example of what I want to do, although I will
> not work with month names. But it has something wrong.
> _______________________________________________________________
> 
> #!/usr/bin/perl
> 
> &hent_input;
> &conversion;


You call sub conversion before you have defined variable $test, or for 
that matter, %longMonthName.  Try moving your call to sub conversion to 
after the $test= statement.

And BTW, I agree 100% with Alan Flavell's comments -- you should

     use CGI;

and avoid most of the hassle and bugs associated with CGI stuff.  Your 
code does have a distinctively Perl-4'ish flavor to it.  Time to upgrade?


> 
> %longMonthName = ("Jan", "January",
>     "Feb", "February",
>     "Mar", "March",
>     "Apr", "April",
>     "May", "May",
>     "Jun", "June",
>     "Jul", "July",
>     "Aug", "August",
>     "Sep", "September",
>     "Oct", "October",
>     "Nov", "November",
>     "Dec", "December");
> 
> $test = $input{n};


Put call to sub conversion here.


> 
 ... <crappy broken CGI decoding skipped>


> 
> sub conversion {
> print "Content-type: text/html\n\n";
> print "$longMonthName{$test}\n";
> }
 ...


-- 
Bob Walton



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

Date: Mon, 11 Nov 2002 05:03:38 GMT
From: "Jesse" <jesse_diskill@NOSPAM.hotmail.com>
Subject: Filehandles within a sub, passed ot main
Message-Id: <KSGz9.1700$Zp3.445@sccrnsc04>

Hello,

    I'm trying to open a series of files within a sub, then pass those
filehandles + one scalar back to the main namespace. Unfortunately I cannot
think of a way to pass all the filehandles back. In  C or C++ I'd
pass-by-reference, but I don't know if Perl does this.

Neither perlfaq5 nor perlfaq7 seem to touch on this & I cannot find a
reference in a prior post. (Not that I can see them all...)

A kick in the right direction would be great.

thanks,
--jesse




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

Date: Mon, 11 Nov 2002 05:42:27 GMT
From: Derek Thomson <derek@wedgetail.com>
Subject: Re: Filehandles within a sub, passed ot main
Message-Id: <7rHz9.201$8%5.18930@news.optus.net.au>

Jesse wrote:
> Hello,
> 
>     I'm trying to open a series of files within a sub, then pass those
> filehandles + one scalar back to the main namespace. Unfortunately I cannot
> think of a way to pass all the filehandles back. In  C or C++ I'd
> pass-by-reference, but I don't know if Perl does this.
> 
> Neither perlfaq5 nor perlfaq7 seem to touch on this & I cannot find a
> reference in a prior post. (Not that I can see them all...)
> 
> A kick in the right direction would be great.

TMTOWTDI.

However, IMHO, it's best just to use the IO::File module for all file 
operations. Using this module, you get to assign a file to a scalar when 
you open it, and then you can pass it around, or return it, any way you 
like.

And thank to the magic of Perl, you can use these references anywhere 
you could use a file handle. For example "<$in>" and "print $out 'A 
string'" work exactly as you would expect.

In fact this is so much better than all the alternatives that I *only* 
teach the use of IO::File to newbies, and don't bother with the built in 
"open" function. This way the file handle stuff is never an issue - they 
don't ever need it or need to know about it.

So, in your case you might have something like the open_files subroutine 
in the following example:


#!/usr/bin/env perl

use warnings;
use strict;

use IO::File;

sub open_files;

my @files = open_files @ARGV;

for my $file (@files) {
     while (<$file>) {
	print;
     }
}

sub open_files
{
     my @file_names = @_;

     my @files = ();

     for my $file_name (@file_names) {
	my $file = IO::File->new($file_name);
	push @files, $file;
     }

     return @files;
}


Note that this only works in Perl 5.6, as I've used the "use warnings" 
pragma. To run with Perls that are two years out of date, change the 
start of this program to something like:

#!/usr/bin/perl -w

use strict;

 ... which was the style at the time.

--
D



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

Date: Mon, 11 Nov 2002 05:54:04 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Filehandles within a sub, passed ot main
Message-Id: <slrnasuhkc.2kt.mgjv@verbruggen.comdyn.com.au>

On Mon, 11 Nov 2002 05:42:27 GMT,
	Derek Thomson <derek@wedgetail.com> wrote:
> Jesse wrote:
>> Hello,
>> 
>>     I'm trying to open a series of files within a sub, then pass those
>> filehandles + one scalar back to the main namespace. Unfortunately I cannot
>> think of a way to pass all the filehandles back. In  C or C++ I'd
>> pass-by-reference, but I don't know if Perl does this.
>> 
>> Neither perlfaq5 nor perlfaq7 seem to touch on this & I cannot find a
>> reference in a prior post. (Not that I can see them all...)
>> 
>> A kick in the right direction would be great.
> 
> TMTOWTDI.
> 
> However, IMHO, it's best just to use the IO::File module for all file 
> operations. Using this module, you get to assign a file to a scalar when 
> you open it, and then you can pass it around, or return it, any way you 
> like.
> 
> And thank to the magic of Perl, you can use these references anywhere 
> you could use a file handle. For example "<$in>" and "print $out 'A 
> string'" work exactly as you would expect.
> 
> In fact this is so much better than all the alternatives that I *only* 
> teach the use of IO::File to newbies, and don't bother with the built in 
> "open" function. This way the file handle stuff is never an issue - they 
> don't ever need it or need to know about it.

[SNIP]

> 
> Note that this only works in Perl 5.6, as I've used the "use warnings" 
> pragma. To run with Perls that are two years out of date, change the 
> start of this program to something like:

Euhmmmmm...

Did you know that in Perl 5.6.0, you can do

open my $fh, "some_file" or die $!;
while (<$fh>)
{
    # do stuff
}

? I don't see what the advantage of using IO::File (the way you show)
over the built in open() is, given your requirement to use 5.6.0
anyway.

If your point is that IO::File can give you lexically scoped file
handles before 5.6.0, then ok, but then you should write 5.005_03
code, or not?

Am I misunderstanding your point, or didn't you know about the
all-new-and-improved open() in 5.6?

Martien
-- 
                        | 
Martien Verbruggen      | 
Trading Post Australia  | The gene pool could use a little chlorine.
                        | 


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

Date: Mon, 11 Nov 2002 05:58:35 GMT
From: Derek Thomson <derek@wedgetail.com>
Subject: Re: Filehandles within a sub, passed ot main
Message-Id: <3DCF4709.2010203@wedgetail.com>

Derek Thomson wrote:
> Jesse wrote:
> 
>> Hello,
>>
>>     I'm trying to open a series of files within a sub, then pass those
>> filehandles + one scalar back to the main namespace. Unfortunately I 
>> cannot
>> think of a way to pass all the filehandles back. In  C or C++ I'd
>> pass-by-reference, but I don't know if Perl does this.
>>
>> Neither perlfaq5 nor perlfaq7 seem to touch on this & I cannot find a
>> reference in a prior post. (Not that I can see them all...)
>>
>> A kick in the right direction would be great.
> 
> 
> TMTOWTDI.

[snip answer involving IO::File]

> Note that this only works in Perl 5.6, as I've used the "use warnings" 
> pragma. To run with Perls that are two years out of date, change the 
> start of this program to something like:
> 
> #!/usr/bin/perl -w
> 
> use strict;
> 
> ... which was the style at the time.
> 

Looking at perlfaq5 at http://perldoc.com (which is different from the 
perlfaq5 I have installed, for some reason), if you've got Perl 5.6 you 
don't even need IO::File any more. "open" can deal with scalars directly.

sub open_files
{
     my @file_names = @_;

     my @files = ();

     for my $file_name (@file_names) {
	open my $file, $file_name;
	push @files, $file;
     }

     return @files;
}

You learn a new thing every day. And it's another way to make people 
*finally* trade up to 5.6 :)

--
D.



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

Date: Mon, 11 Nov 2002 06:02:32 GMT
From: Derek Thomson <derek@wedgetail.com>
Subject: Re: Filehandles within a sub, passed ot main
Message-Id: <YJHz9.202$8%5.18931@news.optus.net.au>

Martien Verbruggen wrote:
> 
> Euhmmmmm...
> 
> Did you know that in Perl 5.6.0, you can do
> 
> open my $fh, "some_file" or die $!;
> while (<$fh>)
> {
>     # do stuff
> }
> 
> ? I don't see what the advantage of using IO::File (the way you show)
> over the built in open() is, given your requirement to use 5.6.0
> anyway.

Because I didn't know about it (see my other post).

> Am I misunderstanding your point, or didn't you know about the
> all-new-and-improved open() in 5.6?

Exactly. That's very nice. Unfortunately, 5.005 is rather hard to get 
rid of. I'd been writing code using "use warnings" to force failure with 
5.005, but people wre able to take that out far too easily - this is 
even better, as I can use it in almost every program I write :)

--
D.

"I am not a crackpot"



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

Date: Mon, 11 Nov 2002 06:13:30 GMT
From: "Jesse" <jesse_diskill@NOSPAM.hotmail.com>
Subject: Re: Filehandles within a sub, passed ot main
Message-Id: <eUHz9.4460$3Z4.6322@sccrnsc02>

Thanks for the answers from both of you. I appreciate it greatly. I actually
found a page that discusses saving filehandles in scalars (even discusses
IO::File), but the examples are perfect.

my thanks,
--jesse



"Derek Thomson" <derek@wedgetail.com> wrote in message
news:3DCF4709.2010203@wedgetail.com...
> Derek Thomson wrote:
> > Jesse wrote:
> >
> >> Hello,
> >>
> >>     I'm trying to open a series of files within a sub, then pass those
> >> filehandles + one scalar back to the main namespace. Unfortunately I
> >> cannot
> >> think of a way to pass all the filehandles back. In  C or C++ I'd
> >> pass-by-reference, but I don't know if Perl does this.
> >>
> >> Neither perlfaq5 nor perlfaq7 seem to touch on this & I cannot find a
> >> reference in a prior post. (Not that I can see them all...)
> >>
> >> A kick in the right direction would be great.
> >
> >
> > TMTOWTDI.
>
> [snip answer involving IO::File]
>
> > Note that this only works in Perl 5.6, as I've used the "use warnings"
> > pragma. To run with Perls that are two years out of date, change the
> > start of this program to something like:
> >
> > #!/usr/bin/perl -w
> >
> > use strict;
> >
> > ... which was the style at the time.
> >
>
> Looking at perlfaq5 at http://perldoc.com (which is different from the
> perlfaq5 I have installed, for some reason), if you've got Perl 5.6 you
> don't even need IO::File any more. "open" can deal with scalars directly.
>
> sub open_files
> {
>      my @file_names = @_;
>
>      my @files = ();
>
>      for my $file_name (@file_names) {
> open my $file, $file_name;
> push @files, $file;
>      }
>
>      return @files;
> }
>
> You learn a new thing every day. And it's another way to make people
> *finally* trade up to 5.6 :)
>
> --
> D.
>




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

Date: Mon, 11 Nov 2002 06:34:33 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: LWP and https
Message-Id: <mbudash-15A802.22344310112002@typhoon.sonic.net>

In article <3b7960ec.0211100527.501063e4@posting.google.com>,
 jason.alphonse@alum.dartmouth.org (Triniman) wrote:

> "Kevin Bilbee" <kbilbee@pictureflipper.com> wrote in message 
> news:<YGgz9.3216$Dl1.260997266@newssvr21.news.prodigy.com>...
> > The following code produces the following error message seemingly from the
> > server.
> > 501 Protocol scheme 'https' is not supported
> > But when I go directly to the url from a web browser it functions without
> > issue
> > 
> > The server requires 128bit SSL. I am stumped.
> > 
> > OS for the script is W2K
> > Web server IIS
> > The per version is 5.2.2 I have asked Intenland to update but to no avail.
> > 
> > Does LWP support 128bit SSL?
> > If not how can I accomplish communicating with a 128bit SSL site over 
> > HTTPS?
> > If it does what am I doing wrong?
> > 
> > Thank you in advance for any help.
> > Kevin Bilbee
> > 
> > [snip]
> > 
> >  # this is where we sent the request and get the response from the server
> >  $ua = LWP::UserAgent->new;
> >  $response = $ua->request(POST
> > 'https://tools.standardabrasives.com/tools/test.asp', [%hash]);
> > 
> > #---------------------------------------------------------------------------
> > ----------------------------#
> > # This is the response to the user after processing the card and placing 
> > the
> > data into the database     #
> > #---------------------------------------------------------------------------
> > ----------------------------#
> >  print $response->status_line . "\n";
> >  print "<html><head><title></title></head><body>";
> >  print $response->content;
> >  print "</body></html>";
>
> LWP doesn't currently support the HTTPS scheme.
> 
> What you might want to check out is Net::SSLeay.
> Available on CPAN as per normal, it lets you do https requests.

that is utter nonsense. of course it supports https, although not alone 
as distributed. i have personally made it happen many times.

'perldoc lwpcook' yields:

HTTPS
       URLs with https scheme are accessed in exactly the same
       way as with http scheme, provided that an SSL interface
       module for LWP has been properly installed (see the
       README.SSL file found in the libwww-perl distribution for
       more details).  If no SSL interface is installed for LWP
       to use, then you will get "501 Protocol scheme 'https' is
       not supported" errors when accessing such URLs.

       Here's an example of fetching and printing a WWW page
       using SSL:

         use LWP::UserAgent;

         my $ua = LWP::UserAgent->new;
         my $req = HTTP::Request->new(GET => 'https://www.helsinki.fi/');
         my $res = $ua->request($req);
         if ($res->is_success) {
             print $res->as_string;
         } else {
             print "Failed: ", $res->status_line, "\n";
         }


and the so-noted README.SSL yields:

SSL SUPPORT
-----------

The libwww-perl package has support for using SSL/TLSv1 with its HTTP
client and server classes. This support makes it possible to access
https schemed URLs with LWP. Because of the problematic status of
encryption software in general and certain encryption algorithms in
particular, in several countries, libwww-perl package doesn't include
SSL functionality out-of-the-box.

Encryption support is obtained through the use of Crypt::SSLeay or
IO::Socket::SSL, which can both be found from CPAN. While libwww-perl
has "plug-and-play" support for both of these modules (as of v5.45),
the recommended module to use is Crypt::SSLeay. In addition to
bringing SSL support to the LWP package, IO::Socket::SSL can be used
as an object oriented interface to SSL encrypted network sockets.

There is yet another SSL interface for perl called Net::SSLeay. It has
a more complete SSL interface and can be used for web client
programming among other things but doesn't directly support LWP.

The underlying SSL support in all of these modules is based on OpenSSL
<http://www.openssl.org/> (formerly SSLeay). For WWW-server side SSL
support (e.g. CGI/FCGI scripts) in Apache see <http://www.modssl.org/>.


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

Date: 10 Nov 2002 20:21:04 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: newbie LWP redirect/cookie question
Message-Id: <1bff1830.0211102021.762b6d2c@posting.google.com>

> Well, the server is expecting a POST, so the first idea is ruled out. 

The url you are using:

http://www.expedia.com/pub/agent.dll?tovr=2002051103&ps3u=&temptrpt=2&defdate=10/26/2002&pcit1=&city1=LAX&airp1=&pctd1=&citd1=SEA&dair1=&date1=12/21/02&time1=362&date2=12/30/02&time2=362&bund=1&load=1&cAdu=1&cSen=0&cChi=0&tktt=3&stkc=1&stkp=1&stkr=1&flcr=&qscr=fexp&flag=q&subm=&cemd=0&chgf=0&wsds=&trpt=2&qryt=8&diag=


I may be a little naive, but that looks like a GET to me.  Using GET
(pasting that url into my address bar, I was able to pull up the page.
 If it was a POST, all of your parameters would not be appended to the
end of the url.

(Unless you can submit data in both GET and POST style. I don't know
if that can be done or not.)


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

Date: 11 Nov 2002 05:32:27 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: newbie LWP redirect/cookie question
Message-Id: <1036992747.327286@elaine.furryape.com>

In article <1bff1830.0211102021.762b6d2c@posting.google.com>,
Bryan Castillo <rook_5150@yahoo.com> wrote:
>(Unless you can submit data in both GET and POST style. I don't know
>if that can be done or not.)

You can certainly append values to the end of the URL. It's still a
POST though.


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

Date: 10 Nov 2002 21:00:04 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Object in @INC returning Tie::Handles from INC method
Message-Id: <1bff1830.0211102100.76469513@posting.google.com>

> Well, ordinary open filehandles and tied handles *should* work about the
> same.  Objects derived from IO::Handle are, in fact, ordinary open
> handles, except that in addition to being able to use the builtin io
> operators, you can use object-oriented methods on them, too.
> 
> PerlIO layers are a bit different... however, there should be little
> enough need for you to concern yourself there, since you generally don't
> have to deal with PerlIO objects directly; they're hidden inside the
> internal data of the IO-ref part of the filehandle.

Do you have any idea then, why PerlIO layers work as returned values
for INC while tied filehandles don't.

I thought I might be able to dump the call stack (is that the right
term) to see
how and from where the INC method or (sub ref in @INC) is called. 
But, all I can tell is that another eval is called. I'm __GUESSING__
that perl enters some core code in C (since I can't step into a use or
require with the debugger, I just end up in the INC callback) and the
work is being done at a fairly low level inside the perl executable or
shared library and it won't deal with a higher level abstraction like
tied handles.  It seems to me that if I want to understand this, I
will have to look in perl source.  I've looked at it before, but it
scares me a little (OK alot).


  push(@INC, sub { 
    my $code = shift;
    my $file = shift;
    Carp::cluck("Someone wants file: $file\n"); 
    print "Lets give them: $fh\n"; # $fh is a tied handle
    return $fh; 
  });
  eval ('use Foo::Bar;');


[output]
Someone wants file: Foo/Bar.pm
	main::__ANON__('CODE(0x17d2b20)', 'Foo/Bar.pm') called at (eval 9)
line 1
	main::BEGIN() called at (eval 9) line 1
	eval {...} called at (eval 9) line 1
	eval 'use Foo::Bar;' called at TestGR.pm line 48
Lets give them: GLOB(0x177f158)


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

Date: Mon, 11 Nov 2002 04:47:13 GMT
From: Asad <g0khaasa@cdf.toronto.edu>
Subject: Perl CGI Java help
Message-Id: <Pine.LNX.4.30.0211102346360.20055-100000@seawolf.cdf>

Hi! I am basically working on a mock up of a e-commerce site. I have an
XML file that stores posters information. I have users come in to my site
and they select a category (such as Sports) and I need to display all the
posters that are in the Sports category. There is also a JAVA Server
running, that when run initially loads XML and stores poster information
in memory data structure. Now when users click say sports from main page,
I run this perl script, that in turn calls a function in Server.java that
fetches all sports posters from memory, create an HTML page, and send it
back to perl script which in turn displays this result HTML to user on the
browser. What I don't understand is how to have PERL script call the Java
function? I am using PERL, CGI and Java Server btw.



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

Date: 10 Nov 2002 19:52:14 -0800
From: peterwu@hotmail.com (Peter Wu)
Subject: Pls recommend me a good Perl programming environment
Message-Id: <9acc2ac1.0211101952.7acfe2@posting.google.com>

Can anyone pls recommend me a good Perl programming environment? I
would like to develop in Perl on Win32 platform and test the program
on FreeBSD environment.

Any suggestion is appreciated! Thanks!


- Peter


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

Date: Mon, 11 Nov 2002 03:57:39 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: Pls recommend me a good Perl programming environment
Message-Id: <1kausuc23rglq7m4j68vupmmm0cckfrnc2@4ax.com>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

In a fit of excitement on 10 Nov 2002 19:52:14 -0800,
peterwu@hotmail.com (Peter Wu) managed to scribble:

| Can anyone pls recommend me a good Perl programming environment? I
| would like to develop in Perl on Win32 platform and test the program
| on FreeBSD environment.
| 
| Any suggestion is appreciated! Thanks!

I do all my coding (regardless of language) in UEdit32 on windoze NT5,
and depending what FreeBSD I'm using, either VIM for the server, or
Anjuta for the workstation as it's GUI.

HTH.


Regards,

  tk

-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3

iQA/AwUBPc8q8CjNZg8h4REKEQLPkACeNmqZiJqJOLJNaBpE2pyZddE27KkAn0A4
LI6p20IIdkZhDUpu/wBwkoiN
=f/ck
-----END PGP SIGNATURE-----

--
+--------------------------+
|     digiServ Network     |
|      Web solutions       |
| http://www.digiserv.net/ |
+--------------------------+

  Remove WINDOZE to reply


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

Date: Mon, 11 Nov 2002 04:01:10 GMT
From: Phlip <phlipcpp@yahoo.com>
Subject: Re: Pls recommend me a good Perl programming environment
Message-Id: <aYFz9.8102$dO2.2799@newssvr19.news.prodigy.com>

Peter Wu wrote:

> Can anyone pls recommend me a good Perl programming environment? I
> would like to develop in Perl on Win32 platform and test the program
> on FreeBSD environment.
> 
> Any suggestion is appreciated! Thanks!

I'm successfully using Test-Unit as my environment.

(Recall that the key to portability is a comprehensive test suite run 
relenlessly.)

Also I hot-wired TU so at failure time it sends 

        filename(linenumber): complain

out OutputDebugString. This lets me tap <F4> to navigate automatically to 
the failure.

To launch the Perl, I write a C++ program with one line:

        system ("perl myTests.pl");

Together, these two features give me "One Button Testing", which is a good 
way to establish flow without grabbing the Mouse every single time you run.

-- 
  Phlip
   http://www.greencheese.org/InMildDefenseOfTheGnats
  --  Shock Value Added  --



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

Date: Mon, 11 Nov 2002 04:07:19 GMT
From: Phlip <phlipcpp@yahoo.com>
Subject: Re: Pls recommend me a good Perl programming environment
Message-Id: <X1Gz9.8105$dO2.8007@newssvr19.news.prodigy.com>

Phlip wrote:

> Peter Wu wrote:
> 
>> Can anyone pls recommend me a good Perl programming environment? I
>> would like to develop in Perl on Win32 platform and test the program
>> on FreeBSD environment.
>> 
>> Any suggestion is appreciated! Thanks!
> 
> I'm successfully using Test-Unit as my environment.
> 
> (Recall that the key to portability is a comprehensive test suite run
> relenlessly.)
> 
> Also I hot-wired TU so at failure time it sends
> 
>         filename(linenumber): complain
> 
> out OutputDebugString. This lets me tap <F4> to navigate automatically to
> the failure.
> 
> To launch the Perl, I write a C++ program with one line:
> 
>         system ("perl myTests.pl");

Forgot to mention here I'm editing with VC++.

> Together, these two features give me "One Button Testing", which is a good
> way to establish flow without grabbing the Mouse every single time you
> run.
> 

-- 
  Phlip
       http://www.greencheese.org/LucidScheming
  --  I'l have my Web site call your Web site...  --



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

Date: Mon, 11 Nov 2002 02:17:28 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Simple array question
Message-Id: <3DCF132B.7040909@rochester.rr.com>

Brian wrote:

> I have an array with, say 100 elements. I want to check to see if any of the
> elements matches a particular string. For example (a shorter array):
> 
> @array = ('red','white','blue');
> 
> And I want to know if the array contains the string 'white' as one of the
> elements. I know how to do this with a foreach loop and comparing each
> element,
> 
> foreach $item(@array){
>          if ($item eq 'white'){
>          ## do something
>          }
> }
> 
> But is there an easier (faster) way than looping through the whole array?
> 

Try:
         my %hash;
         @hash{@array}=0;
         if(exists $hash{white}){
             #white is there
         }
         else {
             #white is not there
         }

-- 
Bob Walton



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

Date: Mon, 11 Nov 2002 14:32:50 +1100
From: "Rodney Hunter" <rwh2100@hotmail.com>
Subject: subroutine
Message-Id: <HwFz9.26494$Sr6.768627@ozemail.com.au>

newbie question using Perl - i have passed parameters into a subroutine OK -
in the subroutine i have declared an array and filled it with values - how
do i get the array values back out to the main program?

thanks
Rodney Hunter





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

Date: Mon, 11 Nov 2002 03:45:08 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: subroutine
Message-Id: <cl9usu8af9ohfr43r36g8jiei2t98bm40m@4ax.com>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

In a fit of excitement on Mon, 11 Nov 2002 14:32:50 +1100, "Rodney
Hunter" <rwh2100@hotmail.com> managed to scribble:

| newbie question using Perl - i have passed parameters into a
| subroutine OK - in the subroutine i have declared an array and filled
| it with values - how do i get the array values back out to the main
| program?
| 
| thanks
| Rodney Hunter
| 
| 

#!d:\perl\bin\perl -w

use strict;
my @ret = foo();

sub foo {
  my @yourarray = ('this', 'that', 'etc');
  return @yourarray;
}

foreach (@ret) {
  print $_ . "\n";
}


 ...produces...

[d:\home\tk]$ perl.pl
this
that
etc


HTH.


Regards,

  tk

-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3

iQA/AwUBPc8n+yjNZg8h4REKEQI3QACeI3RyktMOW27Lt5jGD9d676y2HSAAoOrD
TXgkUupbxNsp6zKoIoniT+yg
=SewM
-----END PGP SIGNATURE-----

--
+--------------------------+
|     digiServ Network     |
|      Web solutions       |
| http://www.digiserv.net/ |
+--------------------------+

  Remove WINDOZE to reply


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

Date: Mon, 11 Nov 2002 03:52:00 -0000
From: Andreas =?iso-8859-1?Q?K=E4h=E4ri?= <ak@freeshell.org.REMOVE>
Subject: Re: subroutine
Message-Id: <slrnasuaat.m48.ak@otaku.freeshell.org>

Submitted by "Rodney Hunter" to comp.lang.perl.misc:
> newbie question using Perl - i have passed parameters into a subroutine OK -
> in the subroutine i have declared an array and filled it with values - how
> do i get the array values back out to the main program?
> 
> thanks
> Rodney Hunter
> 
> 
> 

sub foo {
    my $len = shift;

    my @arr;

# whatever
    for (my $i = 0; $i < $len; ++$i) {
	$arr[$i] = rand()/($i + 1);
    }

    return @arr;
}

my @arr = foo(20);
print join "\n", @arr;



-- 
Andreas Kähäri               --==::{ Have a Unix: netbsd.org
                             --==::{ This post ends with :wq


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

Date: Mon, 11 Nov 2002 02:16:47 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: use strict and my()...
Message-Id: <qn4usu0btqsgn7kt23sh522hmlp7l7ss9i@4ax.com>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

In a fit of excitement on Mon, 11 Nov 2002 02:02:30 GMT, Martien
Verbruggen <mgjv@tradingpost.com.au> managed to scribble:

[snip]

| > If I declare my $answer at the beginning of the sub, then all works
| > fine.
| 
| It wouldn't, unless you also get rid of the lexical scopes within the
| blocks of the if/then/else.

Oops, indeed.


| 
| > Any pointers/URLs/reasons as to why this is the case is more than
| > grateful =)
| 
| For the scoping rule:
| $ perldoc -f my
| 
| For the definition of if/then/else:
| $ perldoc perlsyn

Will take a look and learn some more.

Thanks for your reply =)


Regards,

  tk

-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3

iQA/AwUBPc8TTCjNZg8h4REKEQIb0QCg5gWAWv5v/Y1RlPPz5jUbwgEtMmYAoI4O
FCCiSRsoZZE7oIy9SI822CJx
=+Zbp
-----END PGP SIGNATURE-----

--
+--------------------------+
|     digiServ Network     |
|      Web solutions       |
| http://www.digiserv.net/ |
+--------------------------+

  Remove WINDOZE to reply


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

Date: Sun, 10 Nov 2002 22:26:26 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: use strict and my()...
Message-Id: <slrnasucbi.26u.tadmc@magna.augustmail.com>

tk <tk@WINDOZEdigiserv.net> wrote:

> I thought I understood how the my() function worked.


What made you think that?

Did you _read_ about how the my() function worked?


> sub call_me {
> 	my @array = @_;
> 	if ($array[0] eq 'bar') {
> 		my $answer = 'yes';
> 	} else {
> 		my $answer = 'no';
> 	}
> 	return $answer;
> }

> Global symbol "$answer" requires explicit package name at


> Any pointers/URLs/reasons as to why this is the case is more than
> grateful =)


   perldoc -f my

      A "my" declares the listed variables to be local
                                                 ^^^^^
      (lexically) to the enclosing block...
                  ^^^^^^^^^^^^^^^^^^^^^^

(my underlining)


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


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

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


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