[18175] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 343 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 23 14:06:03 2001

Date: Fri, 23 Feb 2001 11:05:15 -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: <982955114-v10-i343@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 23 Feb 2001     Volume: 10 Number: 343

Today's topics:
    Re: *** DBI module to access MySql under Windows ? *** <jdlwrightNOSPAM@yahoo.com>
    Re: ??? _BIZARRE_ sendmail problem (Malcolm Ray)
    Re: ??? _BIZARRE_ sendmail problem <seanr@visi.net>
    Re: ??? _BIZARRE_ sendmail problem (Eric Bohlman)
    Re: calling other executables from a perl script (Jayant V Rajan)
    Re: Difficult Split Question (Damian James)
    Re: Difficult Split Question <ianb@ot.com.au>
    Re: Disabling debugging support in Perl? <Joshua.Cope@Compaq.com>
    Re: expression help.... <ianb@ot.com.au>
        File Writing Error / Where are the Buffers? <youngb@uclink.berkeley.edu>
        filehandle in subroutine? <stueber@mpiz-koeln.mpg.de>
    Re: filehandle in subroutine? (Jay)
    Re: filehandle in subroutine? <bart.lateur@skynet.be>
    Re: Help required (Peter L. Berghold)
    Re: Help required <len.green@ntlworld.com>
    Re: Help required <Steve_Alpert@idx.com>
    Re: Help! <mjcarman@home.com>
        iis/cgi/perl invoking applications from... (erb)
        Importing Excel data? (Wyatt R Johnson)
    Re: Importing Excel data? (Peter L. Berghold)
    Re: Importing Excel data? <graham.wood@iona.com>
        Is an array of hashes the best way to do this? <ewald@certifichecks.com>
    Re: knifflige perl probleme ... (Damian James)
    Re: knifflige perl probleme ... (Rafael Garcia-Suarez)
    Re: knifflige perl probleme ... <ahoehma@inatec.com>
    Re: knifflige perl probleme ... <mjcarman@home.com>
    Re: Perl and Java applet <jdlwrightNOSPAM@yahoo.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 23 Feb 2001 09:31:47 -0800
From: "Jim" <jdlwrightNOSPAM@yahoo.com>
Subject: Re: *** DBI module to access MySql under Windows ? ***
Message-Id: <H6xl6.125518$Ch.23314819@newsrump.sjc.telocity.net>

try typing

ppm DBI

at your dos prompt, (whilst you are connected to the net) or goto cpan.org
and find it yourself.
Jim

Werner Hofer wrote in message <9741bn$alm$1@duba04h09-0.dplanet.ch>...
>Hi all
>
>i use Perl and i installed Mysql. My Operating System is Windows NT 4.0.
>I would like access from Perl to Mysql. Where can i get the drivers ( DBI &
>DBD )
>for MySql under Windows ?
>
>Thanks a lot for your help in advance !
>
>Werner
>
>
>




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

Date: 23 Feb 2001 17:16:56 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: ??? _BIZARRE_ sendmail problem
Message-Id: <slrn99d6o8.epe.M.Ray@carlova.ulcc.ac.uk>

On Fri, 23 Feb 2001 11:46:27 -0500, Sean Robertson <seanr@visi.net> wrote:
>Can anyone tell me what's wrong with this cgi script?  When it goes through
>the values and prints them to an email, for 'fromwhere' it prints '>From
>Where' instead of 'FromWhere'.  I can't tell where in the hell that '>' is
>coming from, can you?  It's just frickiin _wierd_!  The CGI is attached.
>Any form of enlightenment would be greatly appreciated - this one's just got
>me complately baffled (and then some!).

That's normal behaviour.  A common Unix mailbox format uses lines matching
/^From / as message separators.  So an MTA delivering to a mailbox in that
format will check the message for lines which match that, and escape any
with a '>', to avoid it being mistaken for a message separator.

Solution: if you're bothered by it, don't send lines which match that
pattern!

By the way, please don't send uuencoded files to comp.lang.perl.misc.
It's not fair to expect readers to decode them before helping you,
and will cause your article to magically disappear on some news servers.
-- 
Malcolm Ray                           University of London Computer Centre


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

Date: Fri, 23 Feb 2001 13:21:01 -0500
From: "Sean Robertson" <seanr@visi.net>
Subject: Re: ??? _BIZARRE_ sendmail problem
Message-Id: <uSxl6.4580$jl.44703@sydney.visi.net>

> That's normal behaviour.  A common Unix mailbox format uses lines matching
> /^From / as message separators.  So an MTA delivering to a mailbox in that
> format will check the message for lines which match that, and escape any
> with a '>', to avoid it being mistaken for a message separator.

Thanks.

> By the way, please don't send uuencoded files to comp.lang.perl.misc.
> It's not fair to expect readers to decode them before helping you,
> and will cause your article to magically disappear on some news servers.

How do I not do that?  I just attached it to the message in Outlook Express.
Is there an option to chane that buried in the program somewhere?





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

Date: 23 Feb 2001 18:53:55 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: ??? _BIZARRE_ sendmail problem
Message-Id: <976bk3$a6q$1@bob.news.rcn.net>

Sean Robertson <seanr@visi.net> wrote:
>> By the way, please don't send uuencoded files to comp.lang.perl.misc.
>> It's not fair to expect readers to decode them before helping you,
>> and will cause your article to magically disappear on some news servers.

> How do I not do that?  I just attached it to the message in Outlook Express.
> Is there an option to chane that buried in the program somewhere?

Don't send the code as an attachment: copy-and-paste it into the body of 
your post.




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

Date: 23 Feb 2001 16:21:05 GMT
From: jrajan@red.seas.upenn.edu (Jayant V Rajan)
Subject: Re: calling other executables from a perl script
Message-Id: <9762lh$8q7$1@netnews.upenn.edu>

Abigail-

I just wanted to say thanks for the help. As it turns out, the problem 
was _not_ Perl but, rather, misinformation. I had been incorrectly told 
what to expect in terms of output from the program that I was doing the 
system calls for. Thanks again.

JR


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

Date: 23 Feb 2001 14:32:54 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Difficult Split Question
Message-Id: <slrn99ct3f.i0o.damian@puma.qimr.edu.au>

I was horrified, how could Gwyn Judd so confidently extemporise:
>I was shocked! How could Christopher Burke <craznar@hotmail.com>
>say such a terrible thing:
>>So in short you get get fscked..
>
>What is that sound? I do believe it is the sound of a million killfile
>entries. You lose.
>

Hell, my first public plonking, and a sympathy plonk at that. Oh well.

cya, Chris.
*bloip*

-- 
#!/usr/bin/perl -w
use strict;$|=1;$:=79;for $; (split//,<DATA>){print" "x($:-$_),
$;,"\x"x600,"\b"x($:-$_+1)for 0..--$:;print$;}; __END__
Just another Perl Hacker 


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

Date: Sat, 24 Feb 2001 02:04:52 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: Difficult Split Question
Message-Id: <3A967C13.60532D39@ot.com.au>

Bertilo Wennergren wrote:

> "PRINTED RESULTS:
> ________________
>
> Benchmark: timing 30000 iterations of name1, name2, name3...
>   name1: 17 wallclock secs (16.25 usr +  0.00 sys = 16.25 CPU) @ 1846.15/s
>   name2: 25 wallclock secs (25.00 usr +  0.00 sys = 25.00 CPU) @ 1200.00/s
>   name3: 11 wallclock secs (12.53 usr +  0.00 sys = 12.53 CPU) @ 2394.25/s
>          ^^
> Now who's the man, huh?

Well, if we ignore the fact that different techniques will perform better given

different input data, that Benchmark's results are not always consistent, we
have each made different assumptions about the form of the input data, etc,
that's pretty impressive.

But hey, mine's faster.

I just know his is inviting a war I couldn't possibly hope to stay interested
in long
enough to win, but when I stuck my previously posted version (name4 here) in
for
comparison, I got these results:

#! /usr/bin/perl

print "Content-type: text/plain\n\n";

use Benchmark;

timethese (30000,
{
'name1' =>
  '$text = "a,b,c,def(g,h,i),j,k,lmn(o,p,q),r,stu(v,w),xyz";
   do
    {
     $start = index ($text, "(", $start);
     $stop = index ($text, ")", $start);
     $temp1 = substr ($text, $start, $stop - $start);
     $temp1 =~ tr/,/¿/;
     substr ($text, $start, $stop - $start, $temp1);
     $start++;
    }
   until (index ($text, "¿", rindex ($text, "(")) > -1);
   @Array = split (/,/, $text);
   foreach (@Array) { $_ =~ tr/¿/,/; }
#   print "[", join("] [", @Array), "]\n";
',

'name2' =>
  '$text = "a,b,c,def(g,h,i),j,k,lmn(o,p,q),r,stu(v,w),xyz";
   push @new, $+ while
   $text =~ m/([^(,]*\([^\)\\]*(?:\\.[^\)\\]*)*\)),?|([^,]+),?|(),/gx;
#   print "[", join("] [", @Array), "]\n";
',

'name3' =>
  '$_ = q!a,b,c,def(g,h,i),j,k,lmn(o,p,q),r,stu(v,w),xyz!;
   $_ .= ",";
   (@Array) = m/[^(,]*?\([^)]*?\),|[^,]*?,/g;
   for (@Array) {chop}
#   print "[", join("] [", @Array), "]\n";
',

'name4' =>
  '$_ = q!a,b,c,def(g,h,i),j,k,lmn(o,p,q),r,stu(v,w),xyz!;
   $_ .= ",";
   (@Array) = split /,(?![\w,]*\))/;
#   print "[", join("] [", @Array), "]\n";
',

 }
);

exit;


RESULTS:

Benchmark: timing 30000 iterations of name1, name2, name3, name4...
     name1: 12 wallclock secs (12.06 usr +  0.00 sys = 12.06 CPU)
     name2: 26 wallclock secs (22.05 usr +  0.64 sys = 22.69 CPU)
     name3: 11 wallclock secs (10.79 usr +  0.11 sys = 10.90 CPU)
     name4:  9 wallclock secs ( 8.97 usr +  0.00 sys =  8.97 CPU)

You can uncomment the prints and set the iterations to 1 to check that they all

give the same results (at least on this string).

Regards,


Ian




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

Date: Fri, 23 Feb 2001 12:17:55 -0500
From: Joshua Cope <Joshua.Cope@Compaq.com>
Subject: Re: Disabling debugging support in Perl?
Message-Id: <3A969B43.DF56BDD8@Compaq.com>

  Thanks for all the useful responses. Yes, this is a military (security) 
requirement, and it is probably targeted at keeping users from easily 
inspecting compiled Java libraries and the like. 

Chris Stith wrote:
> Perl programs ... carry the whole program in human-readable form, which can
> be bytecode compiled and interpreted by the interpreter system (and then
> debugged at that point).

  So Perl's debugging support does not reveal any information that is not 
already easily accessible (by reading the program). This makes sense, and
should be easy to argue.

Greg Bacon wrote:
> It's crude, but you could remove perl5db.pl.  Keep in mind that there's
> nothing stopping the lusers from providing their own copies. 

  I guess it stops the "casual luser" from using the -d switch. Maybe this
would be a fallback position, but hopefully I can simply explain that the 
requirement doesn't add security -- or even obscurity -- in the case 
of Perl, and that it should not apply.

    Joshua Cope
    Compaq OpenVMS Engineering


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

Date: Sat, 24 Feb 2001 02:41:48 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: expression help....
Message-Id: <3A9684BB.DC55A9E1@ot.com.au>

Greg Miller wrote:

> $PATH = "${HOME}/${FOO}/res.ckt"
>
> If I do this:
> $PATH =~ m/\${.+}/
>
> The match turns out to be this:
> ${HOME}/${FOO}
>
> However I only want to match ${HOME}
> and NOT the /${FOO}
>
> Any help for this regex neophyte ?

Yes. Don't be too hasty using non-greediness, as others have suggested.
In a
simple example like this, it gives the results you want, but when you
extend the
regex a little, you suddenly find it doesn't do what you want any more.

The following example shows two ways of trying to match a parenthesised
word
not followed by "hello". Extending the non-greediness idea fails because
the
context in which the sub-expression is used allows a different match
from the
one intended.

#! /usr/bin/perl

$a = "blah (fred) hello (fred2) there";
if ($a =~ /\(.+?\)(?! hello)/)
{
    print "Matched $&\n";
}
else
{
    print "Failed\n";
}

if ($a =~ /\([^)]+\)(?! hello)/)
{
    print "Matched $&\n";
}
else
{
    print "Failed\n";
}

__END__

Results:
Matched (fred) hello (fred2)
Matched (fred2)


The moral of the story is, "Say what you mean." If you want to match
non-Xs
followed by an X, use a character class that excludes Xs for the non-Xs,
and
don't rely on nongreediness to get it right.

Regards,


Ian




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

Date: Fri, 23 Feb 2001 09:52:40 -0800
From: "Brett Young" <youngb@uclink.berkeley.edu>
Subject: File Writing Error / Where are the Buffers?
Message-Id: <976819$g10$1@agate.berkeley.edu>

Hello All:

One of my Perl scripts threw a shoe earlier this week and I'm trying to
diagnose what went wrong. The function of the script was to upload files to
a server using CGI. The script was working fine for weeks and then abruptly
stopped working and starting creating the files but not filling them, i.e. I
had a bunch of zero-length empty files.

I've contacted the system admin of the server and it appears there was a
problem with disk space in the temporary directories of the server. Here's
the heart of what I'm looking for:

When Perl runs under CGI, where are the contents temporarily buffered? Does
Perl create temp files?

Thanks in advance for your help.
Brett.




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

Date: Fri, 23 Feb 2001 15:53:59 +0000
From: Kurt Stueber <stueber@mpiz-koeln.mpg.de>
Subject: filehandle in subroutine?
Message-Id: <3A968796.BED643C5@mpiz-koeln.mpg.de>

Hi,
Could anyone tell me how to hand over a filehandle to a subroutine?
I would like to write a sub that produces output for different files
and would like to give the sub the currently valid filehandle for the
operation.

The following does NOT work:

sub print_this
        { FILE = $_;
        print FILE "Hello!";
        }

open( OUTFILE, "> myfile.txt")

&print_this( OUTFILE );





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

Date: 23 Feb 2001 15:18:46 GMT
From: jab@realprogrammer.com (Jay)
Subject: Re: filehandle in subroutine?
Message-Id: <90519B6CFjabrealprogrammercom@158.43.128.9>

stueber@mpiz-koeln.mpg.de (Kurt Stueber) wrote in 
<3A968796.BED643C5@mpiz-koeln.mpg.de>:

>Could anyone tell me how to hand over a filehandle to a subroutine?
>I would like to write a sub that produces output for different files
>and would like to give the sub the currently valid filehandle for the
>operation.
>

Try:

perldoc -q filehandles

The basic idea is:

#!/usr/local/bin/perl

use warnings;
use strict;

open FILE_H, "foo"      or die "failed to open 'foo': $!";
process_FH(\*FILE_H); # pass a ref to typeglob
close FILE_H            or die "failed to close 'foo': $!";

sub process_FH {
  my $fh = shift;

  local $_;
  print while $_ = <$fh>;
}


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

Date: Fri, 23 Feb 2001 16:19:39 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: filehandle in subroutine?
Message-Id: <k13d9tgi7kv46paub747qu3g0ldisqknt0@4ax.com>

Kurt Stueber wrote:

>Could anyone tell me how to hand over a filehandle to a subroutine?

>The following does NOT work:
>
>sub print_this
>        { FILE = $_;
>        print FILE "Hello!";
>        }
>
>open( OUTFILE, "> myfile.txt")

	open OUTFILE, ">myfile.txt";
	print_this(\*OUTFILE);

	sub print_this
	{
	    my($FILE) = @_;
	    print $FILE "Hello!";
	}

If you find that obscure, try creating a filehandle based upon the
FileHandle module. The filehandle itself will still have to be kept in a
scalar, but the syntax will at least look somewhat familiar.

	use FileHandle;
	my $handle = new FileHandle;
	open $handle, "> outfile.txt" or die "Cannot open file: $!";
	print $handle "This is some text.\n";

This is one of the more reliable ways even in slightly older versions of
Perl, for storing a file handle opened in a sub, even after the sub has
been exited.

-- 
	Bart.


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

Date: Fri, 23 Feb 2001 16:57:28 GMT
From: peter@uboat.berghold.net (Peter L. Berghold)
Subject: Re: Help required
Message-Id: <slrn99d5jn.1ca.peter@uboat.berghold.net>

On Fri, 23 Feb 2001 11:22:24 -0500, 
	Umair Bajwa <bajwau@nortelnetworks.com> wrote:
>$line = test <test1> test2 -t test3 /test4/<test5> /test6
>
>it will change into:
>$line = test    test2 -t test3 /test4/  /test6
>
>
without more information any guess would be sorta useless. 

I just tried this just for kicks and it didn't give any problems:

----------8< snip 8<-------------
#!/usr/local/bin/perl
#########################################################################


$line1 = " test <test1> test2 -t test3 /test4/<test5> /test6";
print $line1,"\n";

$line2 = ' test <test1> test2 -t test3 /test4/<test5> /test6';
print $line2,"\n";
----------8< snip 8<-------------

produced the output 


----------8< snip 8<-------------

 test <test1> test2 -t test3 /test4/<test5> /test6
 test <test1> test2 -t test3 /test4/<test5> /test6

----------8< snip 8<-------------
so I don't know where you are going wrong.....

-- 
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold                        Peter@Berghold.Net
"Linux renders ships                     http://www.berghold.net
 NT renders ships useless...."           


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

Date: Fri, 23 Feb 2001 17:39:01 -0000
From: "len.green" <len.green@ntlworld.com>
Subject: Re: Help required
Message-Id: <kmxl6.16423$MN.375074@news2-win.server.ntlworld.com>

If you are using the script from the command line it will work fine

BUT if your printing to a browser it wont display < or > nor anything
between cos it thinks they are HTML tags

so if you want to use < or > use &lt; and &gt; instead


better still use a different symbol!!!!



Len


Umair Bajwa <bajwau@nortelnetworks.com> wrote in message
news:3A969CF5.6D1C892E@nortelnetworks.com...
> Well I am trying am reading from a text file and printing it to another
text
> file.
> For example:
>
> open(OUTPUT,   "+> $dir/$id/$output")  or die "Couldn't open file $!";
> open (TEMPFILE,"$tempfile") || print STDERR "Could not open $tempfile
$!\n";
>
>    while (<TEMPFILE>)
>    {
>        $cur_line = $_;
>        print(OUTPUT $cur_line) ;
>    }
> close TEMPFILE;
> close OUTPUT;
>
> and when I open the output file it prints
> test    test2 -t test3 /test4/  /test6          and actually its suppore
to
> print   test <test1> test2 -t test3 /test4/<test5> /test6
>
> Does anyone know how to solve it ?
>
> Umair
>




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

Date: Fri, 23 Feb 2001 12:55:50 -0500
From: Steve Alpert <Steve_Alpert@idx.com>
Subject: Re: Help required
Message-Id: <u19d9tc29hum6icdarnciap1gjc4gbaf28@4ax.com>

Umair Bajwa <bajwau@nortelnetworks.com> wrote:

>I would like to print a a string for example:
>$line = test <test1> test2 -t test3 /test4/<test5> /test6
>
>it will change into:
>$line = test    test2 -t test3 /test4/  /test6
>
>Does any one have any idea why its doing that? Why its not printing text
>in < > brakets. Any suggestion will be most welcome.
>
by any chance, are you viewing the output file in a browser?  If so, try
changing "<" to &lt;

/sra


        Steve Alpert (Steve_Alpert @ i d x . c o m)
        IDX Systems Corp.   Boston, Massachusetts



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

Date: Fri, 23 Feb 2001 08:01:52 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: Help!
Message-Id: <3A966D50.EBC1E01C@home.com>

Orville Bullitt III wrote:
> ERic <egwong@netcom.com> wrote:
>> Orville Bullitt III <o.bullittiii@worldnet.att.net> wrote:
>>>
>>> I hope that this is the correct NG to ask this question:
>>>
>>> I'm using Microsoft's Outlook Express 5.50.
>>>
>> No, it is not.  [...]
> 
> I wrote in this NG because a friend of mine told me that he 
> **THOUGHT** perl could do it but he had no idea how to do it.

You didn't say anything about Perl in your first message. When someone
wanders into this ng and writes a message that makes no mention of
anything Perlish, we assume they've gotten lost.

> He's over 85 years old and I'm over 90.

That's great, but I fail to see how it's relevant.
 
> I guess that this NG is NOT the place where one can get help.

It's not the place to get someone to do work for you, if that's what you
meant. It is the place to get advice when you're having a problem that
you can't solve yourself after consulting the documentation and FAQ.

As Eric told you -- to do this in Perl you probably need to use the
Text::Template module (to create your template and fill in the unique
bits for each recipient) and the Mail::Send module (to actually send the
message). Give it a try.

-mjc


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

Date: 23 Feb 2001 15:21:21 GMT
From: erbmicha@msu.edu (erb)
Subject: iis/cgi/perl invoking applications from...
Message-Id: <975v5h$177f$1@msunews.cl.msu.edu>

i have an application on the server that does statistical analysis on a 
proprietary file format. i need to be able to pass variables from a web form 
to a script which then writes a control file, then executes the proprietary 
application, and then redirects the user. it cannot(!) redirect the user 
before the application is done though.

of course i tried to use:
    	system 'c:\ease3\winease.exe c:\ease3\files\control.bas';
to do it but if i execute the script from IE/Netscape the winease.exe 
program comes back with a:

    	"The instruction at "0x0034afe4" referenced memory at "0x00000000".     
	The memory could not be "read".

and then terminates.

however, if i execute the perl script via the command line, everything works 
like a charm, except the output doesn't "redirect" me obviously.

anyone know how to get around this?

ALSO: when i try this with just:
    	system 'c:\winnt\system32\sol.exe';

it works from the command line but hangs in cgi.

i'm running ActivePerl (latest) on IIS (<- not my idea!)

thanks!!!


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

Date: Fri, 23 Feb 2001 16:28:06 +0000 (UTC)
From: wjohnson@roger.ecn.purdue.edu (Wyatt R Johnson)
Subject: Importing Excel data?
Message-Id: <97632m$1hv$1@mozo.cc.purdue.edu>


Is there a DBI module for importing Excel data (no formulas involved, just
pure text data), or do I need to export spreadsheet in CSV format and use
DBD::CSV?

Wyatt
-- 
You can always tell when a man has lost his soul to flying. The poor bastard
is hopelessly committed to stopping whatever he is doing long enough to look
up and make sure the aircraft purring overhead continues on course and does
not suddenly fall out of the sky. It is also his bound duty to watch every 


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

Date: Fri, 23 Feb 2001 16:58:53 GMT
From: peter@uboat.berghold.net (Peter L. Berghold)
Subject: Re: Importing Excel data?
Message-Id: <slrn99d5md.1ca.peter@uboat.berghold.net>

On Fri, 23 Feb 2001 16:28:06 +0000 (UTC), 
	Wyatt R Johnson <wjohnson@roger.ecn.purdue.edu> wrote:
>
>Is there a DBI module for importing Excel data (no formulas involved, just

I don't think there is a DBI module for this, but I seem to rememer there 
is a module (or two) for reading Excel not having to do with DBI.

Check out http://www.cpan.org and do a search on Excel.


-- 
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold                        Peter@Berghold.Net
"Linux renders ships                     http://www.berghold.net
 NT renders ships useless...."           


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

Date: Fri, 23 Feb 2001 16:52:59 -0000
From: "Graham Wood" <graham.wood@iona.com>
Subject: Re: Importing Excel data?
Message-Id: <97650f$r0j$1@spider.iona.com>


Wyatt R Johnson <wjohnson@roger.ecn.purdue.edu> wrote in message
news:97632m$1hv$1@mozo.cc.purdue.edu...
>
> Is there a DBI module for importing Excel data (no formulas involved, just
> pure text data), or do I need to export spreadsheet in CSV format and use
> DBD::CSV?
>
From a quick wade through the deja news (now google) archive of
comp.lang.perl.modules, it looks like Spreadsheet::ParseExcel would do what
you're looking for.

Graham Wood

> Wyatt
> --
> You can always tell when a man has lost his soul to flying. The poor
bastard
> is hopelessly committed to stopping whatever he is doing long enough to
look
> up and make sure the aircraft purring overhead continues on course and
does
> not suddenly fall out of the sky. It is also his bound duty to watch every




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

Date: Fri, 23 Feb 2001 13:17:43 -0500
From: Ed Waldspurger <ewald@certifichecks.com>
Subject: Is an array of hashes the best way to do this?
Message-Id: <MPG.1500735286cb6f2b98968b@news.mtcibs.com>

I have written a subroutine which reads a file and puts the contents in 
an array of hashes.  The file being read has the following format.

SC_ItemSKU_0    roadhouseg_526_10
SC_ItemQTY_0    1
SC_ItemREGULARPRICE_0   10.000000
SC_CartItemCount        3
SC_ItemVariation_0      Restaurants
SC_ItemTAXABLE_0        0.000000
SC_ItemSKU_1    thirstydog_583_10
SC_ItemQTY_1    1
SC_ItemREGULARPRICE_1   10.000000
SC_ItemVariation_1      Restaurants
SC_ItemTAXABLE_1        0.000000

I am using this sub to read it.

sub readcart {
	my $cartid = shift;
	my $cartpath = '/path/to/carts';
	
	open (CART,"$cartpath/$cartid.sc") || die "Unable to open the cart 
file\n";

	my @cartitems;
	while (<CART>) {
		chomp;
		my ($item, $value) = split /\t/;
		if ($item =~ /SC_Item(\w*)_(\d*)/) {
			$cartitems[$2]{$1} = $value;
		}
	}
	return @cartitems;
}

I needed a way to read the contents of the file, and then test for 
certain conditions.  For example, I want to limit the quantity purchased 
of some products. To do that I am testing like this.

my @cartitems = readcart($cartid);

for (0..(@cartitems-1)) {
	if (exists $cartitems[$_]{'SKU'}) {
		if ($cartitems[$_]{'SKU'} eq "some_product" && 
		    $cartitems[$_]{'QTY'} > 1) {
			# Do something here
		}
	}
}

This seems very cumbersome.  Is there a better data structure I could be 
using, or a more efficient way of testing this condition?  The key I am 
testing on may not always exist in the data, so I have to check for it's 
existence or I get "Use of uninitialized value" warnings.

I have read perldsc and the "References and Nested Data Structures" 
chapter in the Camel book.  I still think, though, that I could be doing 
this more efficiently.

Thank You
Ed Waldspurger


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

Date: 23 Feb 2001 14:08:15 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: knifflige perl probleme ...
Message-Id: <slrn99crl8.i0o.damian@puma.qimr.edu.au>

Entschuldigen Sie bitte, aber Sie muessen auf English sprechen, wenn sie
ein antwort expectieren.

--
#!/usr/bin/perl -w
use strict;$|=1;$:=79;for $; (split//,<DATA>){print" "x($:-$_),
$;,"\x"x600,"\b"x($:-$_+1)for 0..--$:;print$;}; __END__
Just another Perl Hacker




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

Date: Fri, 23 Feb 2001 14:10:52 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: knifflige perl probleme ...
Message-Id: <slrn99crqg.gdl.rgarciasuarez@rafael.kazibao.net>

Andreas Höhmann wrote in comp.lang.perl.misc:
> $rErrors =
> 
>                     key1 => { subkey1=>1, subkey2=>2 },
>                     key2 => { subkey2=>4 }
>                  };
> 
> for $testkey ( 'key1', 'key2', 'key3' )
> {
>         print "before : " , %$rErrors , "\n";
> 
>         if ( exists $rErrors->{$testkey}->{'subkey1'} )
>         {
>                 print "subkey 1 existiert.\n";
>         }
> 
>         print "after  : " , %$rErrors , "\n";
> }
> 
> erzeugt folgende ausgabe : --->
> 
> before : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> subkey 1 existiert.
> after    : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> before : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> after    : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> before : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> after    : key1HASH(0x80fe3c0)key2HASH(0x8109888)key3HASH(0x8109a5c)
> 
> wiso wird beim letzen testfall ein neuer key in den hash eingefügt ?!?
> wiso steigt perl nicht aus, wo es doch ein undef dereferenzieren will ?!?
> 
> effekt tritt unter windows ( intershopperl ) und linux ( perl 5.6 ) auf.

I don't undestand german but I guess I understand your question.
Here is the answer in universal, international UNIX talk :

  cd /usr/lib/perl5/5.6.0/pod
  grep autovivification perlref.pod perlreftut.pod

-- 
Rafael Garcia-Suarez


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

Date: Fri, 23 Feb 2001 15:55:36 +0100
From: "Andreas Höhmann" <ahoehma@inatec.com>
Subject: Re: knifflige perl probleme ...
Message-Id: <975tl9$oave8$1@ID-25523.news.dfncis.de>

ups, wrong language :-)

the problem is test3 ( $testkey == 'key3' ) ...
why, insert perl a new key in the hashref ?

cu andreas

"Rafael Garcia-Suarez" <rgarciasuarez@free.fr> schrieb im Newsbeitrag
news:slrn99crqg.gdl.rgarciasuarez@rafael.kazibao.net...
> Andreas Höhmann wrote in comp.lang.perl.misc:
> > $rErrors =
> >
> >                     key1 => { subkey1=>1, subkey2=>2 },
> >                     key2 => { subkey2=>4 }
> >                  };
> >
> > for $testkey ( 'key1', 'key2', 'key3' )
> > {
> >         print "before : " , %$rErrors , "\n";
> >
> >         if ( exists $rErrors->{$testkey}->{'subkey1'} )
> >         {
> >                 print "subkey 1 existiert.\n";
> >         }
> >
> >         print "after  : " , %$rErrors , "\n";
> > }
> >
> > erzeugt folgende ausgabe : --->
> >
> > before : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> > subkey 1 existiert.
> > after    : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> > before : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> > after    : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> > before : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> > after    : key1HASH(0x80fe3c0)key2HASH(0x8109888)key3HASH(0x8109a5c)
> >
> > wiso wird beim letzen testfall ein neuer key in den hash eingefügt ?!?
> > wiso steigt perl nicht aus, wo es doch ein undef dereferenzieren will ?!?
> >
> > effekt tritt unter windows ( intershopperl ) und linux ( perl 5.6 ) auf.
>
> I don't undestand german but I guess I understand your question.
> Here is the answer in universal, international UNIX talk :
>
>   cd /usr/lib/perl5/5.6.0/pod
>   grep autovivification perlref.pod perlreftut.pod
>
> --
> Rafael Garcia-Suarez




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

Date: Fri, 23 Feb 2001 08:42:06 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: knifflige perl probleme ...
Message-Id: <3A9676BE.D5D3194C@home.com>

"Andreas Höhmann" wrote:
> 
> $rErrors =
> 
>                     key1 => { subkey1=>1, subkey2=>2 },
>                     key2 => { subkey2=>4 }
>                  };
> 
> for $testkey ( 'key1', 'key2', 'key3' )
> {
>         print "before : " , %$rErrors , "\n";
> 
>         if ( exists $rErrors->{$testkey}->{'subkey1'} )
>         {
>                 print "subkey 1 existiert.\n";
>         }
> 
>         print "after  : " , %$rErrors , "\n";
> }
> 
> erzeugt folgende ausgabe : --->
> 
> before : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> subkey 1 existiert.
> after    : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> before : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> after    : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> before : key1HASH(0x80fe3c0)key2HASH(0x8109888)
> after    : key1HASH(0x80fe3c0)key2HASH(0x8109888)key3HASH(0x8109a5c)
> 
> wiso wird beim letzen testfall ein neuer key in den hash eingefügt ?!?
> wiso steigt perl nicht aus, wo es doch ein undef dereferenzieren will ?!?
> 

[My German is not very good; translation (below) provided by
babelfish.altavista.com]

What you're seeing is called "autovivification." In order to test
whether or not $rErrors->{$testkey}->{'subkey1'} exists, Perl must first
create $rErrors->{$testkey} if it doesn't already exist. If you want to
prevent this from happening, test for the existance of the outer key
first:

if (exists $rErrors->{$testkey} &&
    exists $rErrors->{$testkey}->{'subkey1'}) {
    # ...
}

[Mein Deutsch ist nicht sehr gut; Übersetzung stellte durch
babelfish.altavista.com zur Verfügung.]

Was Sie sehen, wird benannt "autovivification.", um zu prüfen, ob oder
nicht $rErrors->{$testkey}->{'subkey1'} existierent, muß Perl zuerst
erstellen $rErrors->{$testkey}, wenn es nicht bereits existierent. Wenn
Sie verhindern möchten, daß dieses geschieht, prüfen Sie auf das
existance der äußeren Taste zuerst:

if (exists $rErrors->{$testkey} &&
    exists $rErrors->{$testkey}->{'subkey1'}) {
    # ...
}

-mjc


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

Date: Fri, 23 Feb 2001 09:30:12 -0800
From: "Jim" <jdlwrightNOSPAM@yahoo.com>
Subject: Re: Perl and Java applet
Message-Id: <c5xl6.125517$Ch.23314082@newsrump.sjc.telocity.net>

yes, open a socket on port 80 in your applet to the URL of your cgi script,
then you can pass
messages to it as if they were form variables.
pretty sure you can find this stuff at java.sun.com by searching for
something like sockets, CGI

Jim

Xu wrote in message <9749hi$4am$1@newsg1.svr.pol.co.uk>...
>Is it possible for a Perl CGI script to respond to a client browser request
>for a page  with a Java applet embedded in its <APPLET> tag?
>.
>
>




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

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


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