[23666] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5873 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 29 21:05:45 2003

Date: Sat, 29 Nov 2003 18:05:12 -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           Sat, 29 Nov 2003     Volume: 10 Number: 5873

Today's topics:
    Re: Array Indexing problem <krahnj@acm.org>
        ASPN vs. CPAN modules naming <smith2222@hayoo.com>
    Re: ASPN vs. CPAN modules naming <matthew.garrish@sympatico.ca>
    Re: DBI error handling <REMOVEsdnCAPS@comcast.net>
    Re: DBI error handling <r_reidy@comcast.net>
        hash key evaluation creates an entry ! <eddGallary2@hotmail.com>
    Re: hash key evaluation creates an entry ! <REMOVEsdnCAPS@comcast.net>
    Re: hash key evaluation creates an entry ! <eddGallary2@hotmail.com>
    Re: hash key evaluation creates an entry ! <REMOVEsdnCAPS@comcast.net>
    Re: hash key evaluation creates an entry ! <eddGallary2@hotmail.com>
    Re: Ignore quoted text in reg exp <REMOVEsdnCAPS@comcast.net>
        Memory Allocation Error when to fetching BLOB field fro <Admin@goMonitor.com>
    Re: Newsgroup Searching Program <mikeflan@earthlink.net>
    Re: Newsgroup Searching Program <mikeflan@earthlink.net>
    Re: open/print or sys commands to write to a named pipe <tobert@NOSPAMtobert.org>
    Re: Reading Dates from Excel-file (bruno)
    Re: Seeking Perl / Linux tutor <djo@pacifier.com>
    Re: traping a request termination from a browser <nospam@bigpond.com>
    Re: traping a request termination from a browser (Malcolm Dew-Jones)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 29 Nov 2003 19:19:01 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Array Indexing problem
Message-Id: <3FC8F112.7A8391D8@acm.org>

Harish wrote:
> 
> I am having a problem while indexing an element in perl.
> 
> Problem Details:
> 
> [snip]
> 
> if i have $x=4 then when i say $temp[$x] it prints the previous line
> but when i say $temp[4] it prints the line that i'm interested in.
> This does not happen for all the lines.It is just happening for few
> lines.

You are running in to the classical problem of representing floating
point numbers on a binary computer.  When you use a floating point
number as an array index, perl will convert it to an integer by removing
everything after the decimal point.

$ perl -e'
my @array = 0 .. 10;
my $x = 4 - 1e-15;
print  "$x\n";
printf "%.18f\n", $x;
print  "$array[$x]\n";
'
4
3.999999999999999112
3


This FAQ from perlfaq4.pod will help explain it:

perldoc -q "Why am I getting long decimals"



John
-- 
use Perl;
program
fulfillment


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

Date: Sun, 30 Nov 2003 08:36:35 -0800
From: "smithJ." <smith2222@hayoo.com>
Subject: ASPN vs. CPAN modules naming
Message-Id: <3fc91217$1@dnews.tpgi.com.au>

Hello

just installed ActiveState on my W2K.
looking to install GD::Graph, there is non, or maybe it is called by a
different name.

any idea.

thanks a lot




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

Date: Sat, 29 Nov 2003 17:00:31 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: ASPN vs. CPAN modules naming
Message-Id: <xF8yb.28940$Eq1.2459171@news20.bellglobal.com>


"smithJ." <smith2222@hayoo.com> wrote in message
news:3fc91217$1@dnews.tpgi.com.au...
> Hello
>
> just installed ActiveState on my W2K.
> looking to install GD::Graph, there is non, or maybe it is called by a
> different name.
>

You need to add a repository with the module (using ppm):

rep add uwinnipeg http://theoryx5.uwinnipeg.ca/ppms

You should then be able to install it.

Matt




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

Date: Sat, 29 Nov 2003 13:31:26 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: DBI error handling
Message-Id: <Xns944293DF8C4B5sdn.comcast@216.196.97.136>

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

Tore Aursand <tore@aursand.no> wrote in
news:pan.2003.11.29.17.53.19.537901@aursand.no: 

> IMO, it's a bad habit to try to find out if your application, or a
> module it's using, dies if there are ways to handle the errors in a
> better way. With the DBI module - and most other modules - that's not
> a problem (as explained in a previous post from me).

I humbly disagree.  In other languages, "die" is called "throwing an 
exception", and eval{} is called a "try block".  It's a useful technique 
and can result in much cleaner code.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP8j0OWPeouIeTNHoEQJnyQCfal8tGLSqZR+KLb+r/3+Nv8GDN24AoO+3
RGCmf1dpJ00uDyEM7xyO2WHJ
=alvr
-----END PGP SIGNATURE-----


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

Date: Sat, 29 Nov 2003 14:33:57 -0700
From: Ron Reidy <r_reidy@comcast.net>
Subject: Re: DBI error handling
Message-Id: <3FC910C5.6000806@comcast.net>

Well, my suggestion is to use the RaiseError flag and to trap errors 
using eval blocks.  The original question was how to best handle errors 
in CGI.  CGI or non-CGI doesn't matter.  In my 20+ years of RDBMS 
development and admin, the eval block method is the most straight 
forward to understand and implement.

Tore Aursand wrote:
> On Sat, 29 Nov 2003 07:41:03 -0700, Ron Reidy wrote:
> 
>>>>>[...]
>>>>>See 'perldoc DBI' for more information.
>>>>
> 
>>>>And perldoc -f eval
>>>
> 
>>>Why?
>>
> 
>>To trap errors and continue processing.
> 
> 
> No need for that in this case.  Avoid using 'eval', if possible, is my
> suggestion.
> 
> 


-- 
Ron Reidy
Oracle DBA



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

Date: Sun, 30 Nov 2003 06:24:56 +1100
From: Edo <eddGallary2@hotmail.com>
Subject: hash key evaluation creates an entry !
Message-Id: <3FC8F288.8040500@hotmail.com>

Hello

this line
40:    if ($#{$set{'1'}} == $enf) {
creates an entry

p Dumper %set
$VAR1 = '1';
$VAR2 = [];


man, I am lost. why is that, I want to just find out if there is a key 
== 1 in the hash set.why it just creates it like that? how then can I 
check the condition?
e.g.

main::(path:40):      if ($#{$set{'1'}} == $enf) {
   DB<5> p %set

   DB<6> n
main::(path:40):      if ($#{$set{'1'}} == $enf) {
   DB<6> p %set

   DB<7> n
main::(path:44):      load (...)
   DB<7> p %set
1ARRAY(0x84d4940)
   DB<8>

40:    if ($#{$set{'1'}} == $enf) {
41:        exit;
42:    }
43:
44:    load (...)


thanks



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

Date: Sat, 29 Nov 2003 13:39:41 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: hash key evaluation creates an entry !
Message-Id: <Xns944295453E94Bsdn.comcast@216.196.97.136>

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

Edo <eddGallary2@hotmail.com> wrote in news:3FC8F288.8040500@hotmail.com:

> Hello
> 
> this line
> 40:    if ($#{$set{'1'}} == $enf) {
> creates an entry
> 
> p Dumper %set
> $VAR1 = '1';
> $VAR2 = [];
> 
> 
> man, I am lost. why is that, I want to just find out if there is a key 
> == 1 in the hash set.why it just creates it like that? how then can I 
> check the condition?
> e.g.

It's a feature.  It's called "autovivification", and in most sane code, 
it's The Right Thing to do.

To check for the existence of a hash key, use the exists() function.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP8j2J2PeouIeTNHoEQJuxQCdF++kvBTRFFBbJ/oZMiK9Zlw3WsMAn3Sx
+ip2u2MPpUkwL9AbXl+cMYbG
=ntLb
-----END PGP SIGNATURE-----


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

Date: Sun, 30 Nov 2003 09:17:39 +1100
From: Edo <eddGallary2@hotmail.com>
Subject: Re: hash key evaluation creates an entry !
Message-Id: <3FC91B03.3080404@hotmail.com>

Eric J. Roode wrote:
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
> 
> Edo <eddGallary2@hotmail.com> wrote in news:3FC8F288.8040500@hotmail.com:
> 
> 
>>Hello
>>
>>this line
>>40:    if ($#{$set{'1'}} == $enf) {
>>creates an entry
>>
>>p Dumper %set
>>$VAR1 = '1';
>>$VAR2 = [];
>>
>>
>>man, I am lost. why is that, I want to just find out if there is a key 
>>== 1 in the hash set.why it just creates it like that? how then can I 
>>check the condition?
>>e.g.
> 
> 
> It's a feature.  It's called "autovivification", and in most sane code, 
> it's The Right Thing to do.
> 
> To check for the existence of a hash key, use the exists() function.

thanks,
what about == $enf, that is checking the the count of entries using this 
key.





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

Date: Sat, 29 Nov 2003 17:46:29 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: hash key evaluation creates an entry !
Message-Id: <Xns9442BF1B83D25sdn.comcast@216.196.97.136>

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

Edo <eddGallary2@hotmail.com> wrote in
news:3FC91B03.3080404@hotmail.com: 

> Eric J. Roode wrote:
>> 
>> Edo <eddGallary2@hotmail.com> wrote in
>> news:3FC8F288.8040500@hotmail.com: 
>>>man, I am lost. why is that, I want to just find out if there is a
>>>key == 1 in the hash set.why it just creates it like that? how then
>>>can I check the condition?
>>>e.g.
>> 
>> 
>> It's a feature.  It's called "autovivification", and in most sane
>> code, it's The Right Thing to do.
>> 
>> To check for the existence of a hash key, use the exists() function.
> 
> thanks,
> what about == $enf, that is checking the the count of entries using
> this key.

When you dereference $foo{bar}, and the key 'bar' does not exist in %foo,  
an empty reference is created automagically for you.  This is so you can 
do things like:

    for (something)
    {
        push @{ $foo{bar} }, $somevalue;
    }

without having to do backflips to see if you've initialized $foo{bar} to 
an array reference yet.  This is not a feature of hash values; it's a 
feature of scalars in general:

    for (something)
    {
        push @$foo, $somevalue;
    }

will work just fine if $foo has not been initialized.

So to answer your question, the code

    if (@{$foo{bar}} == $enf)

will in fact create an empty array reference at $foo{bar} if it had not 
been previously initialized to anything.  If that's not acceptable, then 
you should check with exists:

    if (exists $foo{bar})

or if you're not quite sure what might be stored there:

    if (exists $foo{bar}  &&  ref $foo{bar} eq 'ARRAY')

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP8kv/WPeouIeTNHoEQKuFQCgnaa0RQS+YCsMP12f8j8xZsmalpMAn0Pc
urjBqyL2BjdL4BN+BIKUEdmg
=h8ap
-----END PGP SIGNATURE-----


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

Date: Sun, 30 Nov 2003 13:09:02 +1100
From: Edo <eddGallary2@hotmail.com>
Subject: Re: hash key evaluation creates an entry !
Message-Id: <3FC9513E.1010803@hotmail.com>

> 
> When you dereference $foo{bar}, and the key 'bar' does not exist in %foo,  
> an empty reference is created automagically for you.  This is so you can 
> do things like:
> 
>     for (something)
>     {
>         push @{ $foo{bar} }, $somevalue;
>     }
> 
> without having to do backflips to see if you've initialized $foo{bar} to 
> an array reference yet.  This is not a feature of hash values; it's a 
> feature of scalars in general:
> 
>     for (something)
>     {
>         push @$foo, $somevalue;
>     }
> 
> will work just fine if $foo has not been initialized.
> 
> So to answer your question, the code
> 
>     if (@{$foo{bar}} == $enf)
> 
> will in fact create an empty array reference at $foo{bar} if it had not 
> been previously initialized to anything.  If that's not acceptable, then 
> you should check with exists:
> 
>     if (exists $foo{bar})
> 
> or if you're not quite sure what might be stored there:
> 
>     if (exists $foo{bar}  &&  ref $foo{bar} eq 'ARRAY')
> 
I know that there is an array there, but I want to find out how many 
aref are there under the key 1 of the hash. and if more than $enf then 
splice it to be equal to $enf. I am having hard time doing that.

     if ( exists $set{1}) {
         if ($#(ref $set{$1}) > $enf) {
             splice @{$set{1}}, $enf;
         }
         print Dumper %set;
     }

ref $set{1} puts out ARRAY in the debugger.



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

Date: Sat, 29 Nov 2003 13:34:35 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Ignore quoted text in reg exp
Message-Id: <Xns9442946838A6Csdn.comcast@216.196.97.136>

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

nickgieschen@hotmail.com (nick) wrote in
news:305cab98.0311291007.20905477@posting.google.com: 

> What I'm doing is searching for the tag <script runat="server"> and
> replacing it with <TAG><script runat="server"></TAG>. However, the
> runat="server" cannot be quoted, as in <script 'runat="server"'>.
> There can also be other parameters in the runat tag, such as <script
> language="jscript" runat="server">. In this case the replacement would
> be <TAG><script language="jscript" runat="server"></TAG>. So, I can't
> simply strip out the quoted text.
> 
> Any ideas?

If you're parsing HTML(XML), use a module for parsing HTML(XML).  Regexes 
are going to be a lot of work for that task, and will likely not handle 
all the cases you need it to.

Also, it seems very strange that you're putting a tag pair around just a 
start tag.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP8j09WPeouIeTNHoEQIacgCeMXPy/H4wmCraJDneKDhICLGo54kAn3r7
+Z/VZU92BaFlKO0Pa+dK3dRo
=N91t
-----END PGP SIGNATURE-----


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

Date: Sat, 29 Nov 2003 20:33:04 -0500
From: "Bazil" <Admin@goMonitor.com>
Subject: Memory Allocation Error when to fetching BLOB field from MS-SQL server Table
Message-Id: <aObyb.29566$Eq1.2517935@news20.bellglobal.com>

If anyone has experience in fetching a Blob field on MS-SQL(7) please have a
look at this.

I am trying to fetch a Blob column (Image) from a MS-SQL(7) table.
The select terminates with and error:
"Could not allocate enough memory (-1 bytes) for column 1."
 it dies on line 14.

Thanks for any suggestion.

Bazil

Here is the Code:

1    use Win32::ODBC;
2    if (!($dbh = new Win32::ODBC("DSN=CameraSQL;UID=***;PWD=***" )))
3   {
4     $Err   ='ODBC';
5     $ErrMsg='ODBC:'. "new(): " . Win32::ODBC::Error();
6     print $ErrMsg <BR>;
7     die;
8    }
9    $SqlString = " Select viewcontent  from NewProfile where  ID='Prof2' ";
10   if(($dbh->Sql( $SqlString )))
11  {
12    $ErrMsg = 'SQL-Err:'.$dbh->Error();
13    print "SQL ERR on: $SqlString $ErrMs
14   die
15  };
16   $dbh->FetchRow();
17   {
18   undef %Data;
19   %Data       = $dbh->DataHash();
10   $FldContent=$Data{$_[1]};




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

Date: Sun, 30 Nov 2003 00:42:57 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Newsgroup Searching Program
Message-Id: <3FC93DD1.E27C5F5B@earthlink.net>


James Willmore wrote:

>
> Go to Google and use the following keywords to search for the thread:
> "comp.lang.perl.misc View NG with Net::NNTP"
>
> Thread is dated 2 Sept 2003.

Thank you Mr. Willmore.  I'm giving your script a try
right now (or soon).

The thread I found was dated 9/19 and 9/3:
http://dbforums.com/arch/95/2003/9/905414

Hard to believe I missed that post.  I think I was too green
at the time to be interested in that "hard" stuff  :-)


Mike




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

Date: Sun, 30 Nov 2003 02:02:23 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Newsgroup Searching Program
Message-Id: <3FC9506E.B0825C4E@earthlink.net>


James Willmore wrote:

> Go to Google and use the following keywords to search for the thread:
> "comp.lang.perl.misc View NG with Net::NNTP"
>
> Thread is dated 2 Sept 2003.

Hmmm.  It acts like it's working, but for some reason
the group function doesn't return anything.  When I
run the script below, it just prints:

last =
first =
newsgroup name =
:    0 articles  (0       to
0      )


I'm guessing the problem has something to do with my
host server "news.west.earthlink.net".


Mike



use strict;
use Net::NNTP;

#set lexical variables
my($SERVER, $nntp, $articles, $first, $last, $ng_name);

#define NNTP server
$SERVER = 'news.west.earthlink.net';
#declare new Net::NNTP object - or die with a connection failure
#message
$nntp = Net::NNTP->new($SERVER, Debug=>0)
or die "Can't connect to server $SERVER: $!\n";

#define what newsgroup to use -
#get the newsgroup name, amount of article, the first article number
#and last article number
($articles,$first,$last,$ng_name) =
$nntp->group('comp.lang.perl.misc');
#$nntp->group('linus.redhat.misc');
#$nntp->group('rec.gambling.poker');
#print the information out
print "last = $last\n";
print "first = $first\n";
print "newsgroup name = $ng_name\n";
printf("%s: %5d articles (%-5d to
%-5d)\n",$ng_name,$articles,$first,$last);

#declare a messages counter
my $x = 1;
#set the nntpstat marker to the last message in the newsgroup
$nntp->last;
#while we can go to the next message ....
while($nntp->next){
#print what number message we're on
print "num: $x\n";
#declare a file handle for the article
my $fh = $nntp->articlefh;
#print the file handle
while(<$fh>){
print;
}
#limit how many messages you want
last if $x == 1;
#increment messages counter
$x++;
}

#close the connection to the NNTP server
$nntp->quit;

__END__





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

Date: Sat, 29 Nov 2003 21:18:31 GMT
From: Al Tobey <tobert@NOSPAMtobert.org>
Subject: Re: open/print or sys commands to write to a named pipe?
Message-Id: <87f72c45e4aa1c6b9b5f809b717e5be5@news.teranews.com>

On Wed, 12 Nov 2003 17:22:34 +0000, Jim Mozley wrote:

> Ben Morrow wrote:
> 
> 
>>>I current do the following to write to the pipe:
>>>
>>>open (PIPE, "> $pipe") or die "Cannot open pipe $!";
>>>flock(PIPE,2);
>> 
>> 
>> AAARGH! Don't do that! Use the constants defined in Fcntl.pm.
>> 
>> use Fcntl qw/:flock/;
>> 
>> flock PIPE, LOCK_EX;
> 
> point taken
> 
>>>print PIPE "$cmd";
>>>close PIPE or die "Cannot close pipe $!";
>>>
>>>I was wondering if I should use the following code below (taken from an 
>>>example I saw for writing to a pipe that I propose to put in a package):
>>>
>>>my $fh = new IO::File;
>>>sysopen( $fh, $pipe, O_SYNC|O_WRONLY|O_APPEND )
>>>     or croak "could not open $cmdfile for writing: $!";
>>>flock( $fh, LOCK_EX );
>>>seek( $fh, 0, SEEK_END );
>> 
>> 
>> What? Pipes aren't seekable...
> 
> I'll take your word for that.
The above code will also be sure to write to the end of a regular file. 
Yes, you can open in APPEND mode, but that doesn't guarantee anything if
you keep the file open for multiple writes.  The seek may not have any
effect on a pipe, but does not break on a pipe, either.  So, the above
also works on regular files.

>>>my $numofbytes = syswrite( $fh, $cmd,
length($cmd) ); flock( $fh,
>>>LOCK_UN );
>>>carp "No data written!" unless $numofbytes;
>>>
>>>Is one better than the other for this purpose?
>> 
>> 
>> No. The second appears to have been written by a C programmer.

Actually, I'm not a C programmer - I was trying to avoid buffering.  It's
probably not worth it once autoflush is on, so I've removed it.

> I don't know about that, but it is from a module on CPAN (Nagios::Cmd)
> to interact with the application I'm trying to through messages at
> (Nagios a network/system/service monitor)
> 
>> What you need to do is sleep() for a couple of seconds after each
>> message, to give the reading program a chance to register that the pipe
>> has been closed.
> 
> I tried this by sleeping for 1 second and still saw the problem. This
> puzzled me as I thought using flock's LOCK_EX would be honoured by any
> other invocations of my script also using LOCK_EX. I guess I could
> increase the time in the sleep, I'm not sure about the mechanism for
> reading from the other end (its written in C) and how often it does this
> (or even if it is time based).

Nagios only reads the pipe at whatever interval you set in nagios.cfg.  It
could be 1 second, but I think the default is 15 seconds.

Of course, flock/LOCK_EX only works for programs that use it for every
access to the file.  If you're using Nagios::Cmd, for instance, it should
keep a storm of writes for clobbering each other.

> I thought that
the module on CPAN (published after I'd created my
> script) could be the answer and wanted to check which approach was
> valid.
> 
>> A better answer would have been to have used a Unix-domain socket, but
>> I doubt you have control over that... :)
> 
> I think the author of the app may be moving to this but cannot be sure.

Nagios uses a fifo so that you can use standard unix tools to write to the
fifo (Yes, netcat can probably do it, too).  It's about simplicity - I can
simply echo "MY_COMMAND ARGS" >>fifo.file instead of having to deal with
a bunch of network code.

> Thanks for the help,
> 
> Jim



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

Date: 29 Nov 2003 14:44:22 -0800
From: bskorepa@yahoo.com (bruno)
Subject: Re: Reading Dates from Excel-file
Message-Id: <f542e1ac.0311291444.6f7fd283@posting.google.com>

As I was told to provide a code sample, here it is:
This function returns an array of lines, where every line 
contains the cells of the excel spreadsheet seperated by tabs.

Cells that contain simple text or numbers are exported as expected,
cells that contain date values are exported as:
Win32::OLE::Variant=SCALAR(0x20d341c)

eg:

number	text	date
491	Stammdaten	Win32::OLE::Variant=SCALAR(0x20d341c)
487	Abrechnung	Win32::OLE::Variant=SCALAR(0x20d25e0)
482	Audiometrie	Win32::OLE::Variant=SCALAR(0x20d1274)


#############################################################
# start of sample
# just paste and provide valid filename 

use Win32::OLE::Const 'Microsoft Excel';
use strict;

my $excelfile = "test.xls";

sub readexcelfile {
	my $source = $_[0];
	
	my @all;
	my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
	    || Win32::OLE->new('Excel.Application', 'Quit');  
	my $Book = $Excel->Workbooks->Open("$source"); 	     
	my $Sheet = $Book->Worksheets(1);                      
	
	my $rows = $Sheet->UsedRange->Rows->Count;
	my $blatt = $Sheet->Range("A1:K$rows")->{'Value'};   
	$Book->Close(0);

	foreach my $ref_zeile (@$blatt) {                    
		my $line = "";
		for my $item (@$ref_zeile) {
			$line.=$item."\t"; 
		}
		push(@all,$line);
	} 
	#@all = reverse sort buildvgl @all;
	return @all;
}


#dummy main to read the file and dump the lines:
{
	my @lines = readexcelfile($excelfile);
	foreach(@lines) {
		print "$_\n";
	}
}

# end of sample
#############################################################

If there is a better way, or an easy way to directly access the file
(without excel needed to be installed on that particular workstation)
please let me know.

thanks, Bruno


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

Date: Sat, 29 Nov 2003 23:41:21 GMT
From: "David Oswald" <djo@pacifier.com>
Subject: Re: Seeking Perl / Linux tutor
Message-Id: <B8ayb.138$Zu5.226649@news3.news.adelphia.net>


"Felix Smith" <vvz2@yahoo.com> wrote in message
news:901f024b.0311281156.68938ac5@posting.google.com...
> I am looking for a Linux/ Perl tutor who I can contact via Yahoo
> Instant Messenger to obtain instant advice when needed. Compensation
> will be on an incident by incident basis. Fluency in English is
> required.

Why not start an account at http://www.perlmonks.org?  It's web based.
There is an instant message box there, as well as a "Seekers of Perl Wisdom"
bulliten board section.





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

Date: Sun, 30 Nov 2003 08:48:53 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: traping a request termination from a browser
Message-Id: <3368890.zbijW4l4sA@gregs-web-hosting-and-pickle-farming>

It was a dark and stormy night, and John Michael managed to scribble:

> Say I were to write a script that would server a large file through a web
> interface and record somewhere the file size.
> 
> Is it possible for me to know if the user downloading the file terminated
> the connection early so that I could record the correct size?
> 
> How would I trap this situation so that I could do some sort of roll back
> or clean up if this were to happen?
> 
> 
> Thanks
> JM

I have a similar problem - I download large files via the web (eg http://www.ipo-australia.com/download/20031128.txt via Perl/Apache/rewrite rules/cgi) and want to stop when the user hits stop on the browser. I have posted questions to various groups in the past month with no success.

I do know
1. it is possible - I was using an ISP at one stage that stopped the cgi when the user hit stop
2. Apache knows the user has hit stop, as I see that no bytes are being sent on the ethernet port
3. I have tried trapping SIGPIPE within Perl with no success

So if anybody can provide code that works (rather than describing what should work) I would be very interested.

gtoomey


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

Date: 29 Nov 2003 15:01:06 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: traping a request termination from a browser
Message-Id: <3fc92532@news.victoria.tc.ca>

Gregory Toomey (nospam@bigpond.com) wrote:

: 2. Apache knows the user has hit stop, as I see that no bytes are being
sent on the ethernet port

I think this is a wrong interpretation.  The network cannot send data
until it receives the correct confirmations from the remote system.  The
network is waiting for that confirmation.



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

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


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