[16772] in Perl-Users-Digest
Perl-Users Digest, Issue: 4184 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 31 00:05:27 2000
Date: Wed, 30 Aug 2000 21:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967694709-v9-i4184@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 30 Aug 2000 Volume: 9 Number: 4184
Today's topics:
About reading the chinese file. <chaptera@hotmail.com>
Re: Bulk add to a hash.. Thanks for the help! <uri@sysarch.com>
Re: Connect to HP3000 using PERL ??? (David Efflandt)
Re: Emulating a browser. (David Efflandt)
Re: Finding a file in a huge filesystem <tina@streetmail.com>
Re: Functions which modify thier parameters? <rbank@csf.edu>
Re: Getting slices of this ...(not pizza) <rick.delaney@home.com>
Re: help..I don't know what is this??? <tim@ipac.caltech.edu>
How are hashes stored internally? <chris@spagnet.com>
Re: Just another silly post. <rick.delaney@home.com>
Just Cant Get The File Upload Thing paul5544@my-deja.com
Re: Just Cant Get The File Upload Thing (brian d foy)
Re: legal date eastking@my-deja.com
newbie question: formatting user input for HTML output <perspiring@nuts.com>
Re: newbie question: formatting user input for HTML out <bwalton@rochester.rr.com>
Re: Oracle, sqlplus, DBI - help <cushard@attglobal.net>
Re: Parsing a Excell table - or - a "Tab New_Line" text <bwalton@rochester.rr.com>
Passing arrays from subroutines. <carter@aodinc.com>
Re: pattern matching question (in plain ASCII) (Keith Calvert Ivey)
Re: problems installing DBD::oracle for oracle-db-acces <cushard@attglobal.net>
Re: regexp and accentuated letters (Keith Calvert Ivey)
Sorting a Tab Delimited Text File By Second Field <smc150@buffnet.net>
Sorting question: I think I am missing something obviou <landman@sgi.com>
Re: Sorting question: I think I am missing something ob (Martien Verbruggen)
Re: Were are all the executibles? <cushard@attglobal.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 31 Aug 2000 09:19:40 +0800
From: Tom <chaptera@hotmail.com>
Subject: About reading the chinese file.
Message-Id: <39ADB2AC.BB9270A5@hotmail.com>
Dear all,
I wrote a perl program which is read a chinese character file, then
redirect the
output for the web page.
But when on the web page, it will show the ÁÙ¤£«Hªº¸Ü,ºô¥D·|© code,
Does anyone know how to solve this problems?
1.pl
print header();
........
open(INFILE, "$filenm") || err("Error on opening files: $!");
while (<INFILE>)
{
print "$_\n";
}
close(INFILE);
Thank you very much.
------------------------------
Date: Thu, 31 Aug 2000 03:45:14 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Bulk add to a hash.. Thanks for the help!
Message-Id: <x78zteqek5.fsf@home.sysarch.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> In article <1eg77nq.1n7gxnz1ykyfdqN@[192.168.88.117]> on Wed, 30 Aug
LR> 2000 22:27:20 +0200, Jakob Schmidt <sumus@aut.dk> says...
>> Jakob Schmidt <sumus@aut.dk> wrote:
>>
>> > x => y is equivalent to "x", y (and "x" => y) for all x =~ /\w+/
>>
>> make that /^\w+\z/
LR> Even that isn't true. Try 1x => 'foo' for example.
LR> Perhaps /^[^\W\d]\w*\z/ .
and of course there is another special case. a leading - is allowed in
the tokens (can't call it a bareword then) autoquoted by =>. this comes
from the common use of -foo as a key/attribute in sub calls.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Thu, 31 Aug 2000 02:39:26 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Connect to HP3000 using PERL ???
Message-Id: <slrn8qrha8.34g.efflandt@efflandt.xnet.com>
On Wed, 30 Aug 2000 17:06:50 -0700, Raymond W Yu <raymond_w_yu@hp.com> wrote:
>I am trying to connect to a HP3000 MPE/ix system using PERL to automate
>some tasks.
>
>Is there a module that I can use to connect to the HP3000?
>
>I tried Net::Telnet and it doesn't work. Then I tried telnet
>hp3000-host 1537,
>I got garbage.
>
>I was able to use Reflection via OLE to connect to the HP3000, but the
>performance is
>very slow.
>
>Any help or pointers will be appreciated.
>
>
>Ray
>650-236-5998
There was a Unix program called freevt floating around somewhere that
might give you some ideas from its source, but I cannot locate it at the
moment. I just posted subject: "freevt or other vt-mgr unix terminal?"
in comp.sys.hp.mpe asking if anyone there knows where to find freevt or
any Perl modules that could access it. So you might keep an eye on that.
I don't know about your hp3k, but ours uses an add-on to Reflection called
VT-MGR for access, which is a somewhat different protocol from telnet.
I had freevt working when compiled in an older Slackware Linux, but not
with the newer libs in RedHat (compile error about getc or something no
longer recommended).
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: Thu, 31 Aug 2000 03:17:37 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Emulating a browser.
Message-Id: <slrn8qrjhr.34g.efflandt@efflandt.xnet.com>
On Wed, 30 Aug 2000 11:24:17 +0200, Erik Terpstra <erik@solidcode.net> wrote:
>Hi,
>
>I am using the source below to emulate a browser (I know there are
>already lots of tools doing this, I also have seen LWP, but this is just
>
>for educational purposes).
>The problem is when I try to connect to my local web server using:
>
>./browser localhost 80
>
>I get a useful response, but when I try to access any other domain name
>like:
>
>./browser www.google.com 80
>
>I don't get anything back at all. I have a direct connection to the
>internet and I get a ping reply from those domain names.
>Does anybody know what I am doing wrong here?
I tried your script and it works fine, even for www.google.com. Maybe you
have something wrong with your DNS.
If you are dealing with a webserver that has virtual hosts, it might not
know which virtual host you are referring to. So you should include a
Host: header after the GET request before terminating the headers with the
double newline.
>TIA,
>
> Erik.
>
>------ sourcecode for 'browser' ----------------------------------
>
>#!/usr/bin/perl
>
>use Socket;
>
>$SIG{'INT'}='suicide';
>socket(S,2,1,6) || die "socket: $!";
>connect(S,sockaddr_in($ARGV[1],inet_aton($ARGV[0]))) || die("connect:
>$!");
>select(S);$|=1;select(STDOUT);
>print S "GET / HTTP/1.0\n\n";
>print '-'x80;print "\n";
>foreach(<S>){
> print;
>}
>print '-'x80;print "\n";
>&suicide;
>
>sub suicide{
> defined(S) && close(S);
> print "Exiting now...\n";
> exit;
>}
>
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: 31 Aug 2000 01:48:56 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Finding a file in a huge filesystem
Message-Id: <8okdi8$au5tb$1@ID-24002.news.cis.dfn.de>
hi,
nkhan75@hotmail.com wrote:
> I need to find a file, say foo.txt, in a file tree that contains
> several thousand files. Just traversing through the tree takes over 2
> hours on a strong machine. Hence I need to come up with Perl code
> which, as soon as it finds the file, stops the search. Ofcourse, if the
> file does not exist the code will step through all the files in the
> tree looking for foo.txt.
well, at least if you're on a unix system you could use the
system call "locate".
show a little of your code if you have already tried out File::Find
as others pointed out.
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: Wed, 30 Aug 2000 19:49:35 -0600
From: "Robin Bank" <rbank@csf.edu>
Subject: Re: Functions which modify thier parameters?
Message-Id: <8okds5$19t9$1@reader.nmix.net>
Out of curiousity, why are you doing this? What's it for?
-Robin
"Arcadio Sincero" <asince1@irix1.gl.umbc.edu> wrote in message
news:8ojals$shn$1@news.umbc.edu...
> I'm trying to write functions in Perl which are able to modify its
> parameters. The way I'm doing that now is:
>
> sub foo($$)
> {
> my $p1 = \$_[0];
> my $p2 = \$_[1];
>
> $$p1 = 4;
> $$p2 = 11;
> }
>
> What I'd really like to do, though, is something like this:
>
> sub foo($$)
> {
> my ($p1, $p2) = @_;
>
> $$p1 = 4;
> $$p2 = 11;
> }
>
> But of course, this doesn't work because $p1 and $p2 in the second example
> are no longer references to the elements of @_. Does anybody know the
> correct way to do what I'm trying to do in the second example? Or is the
> way I'm doing it in the first example the only way?
>
> Thanks in advance for any help on this!
>
> ---
>
============================================================================
===
> Arcadio A. Sincero Jr.
> Computer Science Major at the University of Maryland Baltimore County,
> Linux systems administrator, wanna-be Windows and Linux software
developer,
> amateur competitive bodybuilder and all-around nice guy.
>
> WWW: http://www.sincero.com/~asincero (COMING REAL SOON NOW(tm)!)
> E-mail: mailto:asincero@sincero.com (THIS IS BROKE TOO! damn ...)
>
> "There are three kinds of people in this world: those who can count, and
those
> who can't."
>
------------------------------
Date: Thu, 31 Aug 2000 03:18:46 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Getting slices of this ...(not pizza)
Message-Id: <39ADD0FE.618F4727@home.com>
[posted & mailed]
Ren Maddox wrote:
>
> BTW, could someone clarify this bit from perldata for me:
>
> A slice of an empty list is still an empty list. Thus:
>
> @a = ()[1,0]; # @a has no elements
> @b = (@a)[0,1]; # @b has no elements
> @c = (0,1)[2,3]; # @c has no elements
>
> But:
>
> @a = (1)[1,0]; # @a has two elements
> @b = (1,undef)[1,0,2]; # @b has three elements
>
> In particular, I don't understand why "@a = (1)[1,0]" results in @a
> having two elements rather than one.
That's just the way it is. If any slice index refers to an existing
scalar element of the list, then all indices are assumed to point to
actual scalar values. If the index is outside the bounds of the list
(like 1 in this case), then an undef value springs into existence.
> The best I could come up with is that a list slice has magic that if
> the slice is comprised entirely of undefs, then the result is an empty
> list rather than a list of undefs, but if any of the resulting
No, that's the way it used to behave in v5.005.
> elements are not undef, then all of the undefs are left in place.
>
> So ()[1,0] becomes (undef, undef) becomes (), but (1)[1,0] becomes
> (undef, 1) and stays that way. Maybe???
>
> Nope-- I just tried @a=(undef)[0], but @a gets one element. So it
> must be a little more subtle, some sort of "unexist" value or
> something.... ()[1,0] becomes (unexist, unexist) becomes (), but
> (1)[1,0] becomes (unexist, 1) becomes (undef, 1). How does that
> sound?
That's one way to look at it but it's nothing so complicated. If you
try to grab a slice from an area that has no scalars (such as from an
empty list) then Perl gives you back an empty list. The other choice
would be to give you back a list of undefs, but then this example from
perldata wouldn't work:
while ( ($home, $user) = (getpwent)[7,0]) {
printf "%-8s %s\n", $user, $home;
}
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Wed, 30 Aug 2000 19:16:01 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: help..I don't know what is this???
Message-Id: <39ADBFE1.610512F@ipac.caltech.edu>
eduardo_m@my-deja.com wrote:
> $sth->execute();
>
> if ($@) {
> $dbh->rollback();
> }
>
> I know how works this, but I want to know what the "$@" means...Is
> something like a way to know if an error has ocurred????....
Are you sure that wasn't
eval { $sth->execute() };
if ($@) {
$dbh->rollback();
}
???
In addition to the comments of others in this thread, read the DBI
documentation; it contains an example like the above for doing safe
transactions.
--
-- Tim Conrow tim@ipac.caltech.edu 626-395-8435
------------------------------
Date: Wed, 30 Aug 2000 23:02:37 -0400
From: Chris Barnabo <chris@spagnet.com>
Subject: How are hashes stored internally?
Message-Id: <MPG.141794dcd9b5d2e59896ad@news.supernews.com>
Just curious ... how does perl store hashes internally? I've read perldoc
perlguts and it indicates that the actual data nodes (perhaps not the right
term) are stored in linked lists, which makes sense for iterating over the
hash elements, returning all values or keys, etc. But it doesn't seem to
discuss how the hash keys themselves are stored or searched - I would guess
that for efficiency there must be some sort of structure other than the
linked lists that holds the keys so they can be quickly searched and
inserted?
Interested from a performance standpoint ... I just spent the morning
writing code to build & search a balanced binary tree in another language
and thought perl hashes would've been a neat solution to the problem if I
could've used perl for that project.
-- Chris
________*________ Chris Barnabo, chris@spagnet.com
____________ \_______________/ www.spagnet.com
\__________/ / /
__\ \_______/ /__ "The heck with the Prime Directive,
\_______________/(- let's destroy something!"
------------------------------
Date: Thu, 31 Aug 2000 03:23:00 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Just another silly post.
Message-Id: <39ADD1FC.9001183D@home.com>
Steve Mading wrote:
>
> That's a command-line switch. I was referring to a regular-expression
> switch
And I was referring to an equally relevant switch.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Thu, 31 Aug 2000 03:36:34 GMT
From: paul5544@my-deja.com
Subject: Just Cant Get The File Upload Thing
Message-Id: <8okjs1$6ao$1@nnrp1.deja.com>
Was hoping someone could give me a hand. I have read the CGI docs,
looked at the forums for days, reviewed several freeware code samples
and just cannot get this thing through my thick skull.
Here is the code I am trying to use to upload a file.
NOTE: $pFIle1 variable is a value grabbed from a parsed input form. The
value is something to the effect of C:\My Documents\graphic.gif or
whever their file resides.
The results of this rounting are that it creates the file, but
transfers nothing so if I disable the unlink, I end up with a filename
with a size of 0.
I would really apprecaite any help on this.
Anyway, here is the subrountine
use CGI;
my $bytesread;
my $size;
my $fileName = $pFile1;
if ($pFile1 ne "")
{
$fileName =~ s!^.*(\\|\/)!!;
open (OUTFILE, ">$basedir/$fileName");
binmode OUTFILE;
print "$basedir/$fileName<br>";
while ($bytesread = read($pFile1,$buffer,1024))
{
print OUTFILE $buffer;
$total_size += $size;
}
close OUTFILE;
}
if ($total_size > 0)
{
#file was transferred
&create_main_form('File Upload was sucessfull.');
exit(0);
}
else
{
#file was not transferred
unlink "$basedir/$short_name";
&create_main_form('Warning! File Upload was NOT sucessfull. Please Try
Again.');
exit(0);
}
I apprecaite anyones help..
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 30 Aug 2000 23:56:45 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Just Cant Get The File Upload Thing
Message-Id: <brian-ya02408000R3008002356450001@news.panix.com>
In article <8okjs1$6ao$1@nnrp1.deja.com>, paul5544@my-deja.com posted:
> Here is the code I am trying to use to upload a file.
> NOTE: $pFIle1 variable is a value grabbed from a parsed input form. The
really? it looks like it isn't anything.
> use CGI;
> my $bytesread;
> my $size;
> my $fileName = $pFile1;
> if ($pFile1 ne "")
> {
perhaps you should put something in $pFile1
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Thu, 31 Aug 2000 03:35:54 GMT
From: eastking@my-deja.com
Subject: Re: legal date
Message-Id: <8okjqp$6ag$1@nnrp1.deja.com>
In article <slrn8qcjfh.27o.marcel@gandalf.local>,
marcel@codewerk.com wrote:
> On Fri, 25 Aug 2000 08:53:33 GMT, eastking@my-deja.com
> <eastking@my-deja.com> wrote:
>
> >I want to get a legal day most close(forward) to the day encrypted by
> >the three variable '19990931'. In this case it should be '19990930'.
>
> If you want the next _forward_ date, shouldn't it be '19991001'?
>
> Anyway, localtime and Time::Local's timelocal() do that for you:
>
> $ cat legaldate.pl
>
> #!/opt/perl/bin/perl
>
> use warnings;
> use strict;
> use Time::Local;
>
> my ($year, $month, $day) = @ARGV;
>
> ($day, $month, $year) =
> (localtime(timelocal(0, 0, 0, $day, $month - 1, $year -
1900)))[3..5];
> $month++;
> $year += 1900;
>
> my $legaldate = sprintf("%04d%02d%02d", $year, $month, $day);
>
> print "$legaldate\n";
> __END__
>
> $ ./legaldate.pl 1999 09 31
> 19991001
> $ ./legaldate.pl 1999 09 30
> 19990930
> $ ./legaldate.pl 1999 08 31
> 19990831
> $ ./legaldate.pl 2000 02 29
> 20000229
> $ ./legaldate.pl 2000 02 30
> 20000301
>
> It will cope with days in the range 1..31, and months in the range of
1..12:
>
> $ ./legaldate.pl 2000 12 35
> Day '35' out of range 1..31 at ./legaldate.pl line 9
> $ ./legaldate.pl 2000 13 31
> Month '12' out of range 0..11 at ./legaldate.pl line 9
>
> (Remember that months are counted from 0.)
>
> --
> Marcel Gr\"unauer - Codewerk plc . . . . . . . . . . .
<http://www.codewerk.com>
> Perl Consulting, Programming, Training, Code review . . .
<marcel@codewerk.com>
> mod_perl, XML solutions - email for consultancy availability
> sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print}
Just_Another_Perl_Hacker();
>
But , I can NOT find Time::Locale in CPAN
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 30 Aug 2000 21:19:30 -0400
From: "perspiring goth" <perspiring@nuts.com>
Subject: newbie question: formatting user input for HTML output
Message-Id: <39adb18c_2@news.newsfeeds.com>
HI -
Here's a softball for someone... but I need the help!
How do I format form text so that CGI outputs it to an HTML document but
where I can see the commas and not comma%27s ?
The parse code I used follows which, I'm told, is pretty common...
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
} else {
print "Content-type: text/html\n\n";
print "<P>Use Post or Get";
}
foreach $pair (@pairs) {
($key, $value) = split (/=/, $pair);
$key =~ tr/+/ /;
$key =~ s/%([a-fA-F0-9] [a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9] [a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~s/<!--(.|\n)*-->//g;
if ($formdata{$key}) {
$formdata{$key} .= ", $value";
} else {
$formdata{$key} = $value;
}
}
The perl script....
$objective = $formdata{'objective'};
<p>
<font size=+1 face="arial">Objective:</font><p>
$objective
<p>
Thanks for the help!
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Thu, 31 Aug 2000 01:50:42 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: newbie question: formatting user input for HTML output
Message-Id: <39ADB9E4.60BE26CD@rochester.rr.com>
perspiring goth wrote:
...
> Here's a softball for someone... but I need the help!
>
> How do I format form text so that CGI outputs it to an HTML document but
> where I can see the commas and not comma%27s ?
...
<code deleted>
You can quit perspiring so much if you would just:
use CGI;
It handles all that stuff for you no sweat. See:
perldoc CGI
or read a good Perl CGI book.
Regarding what is wrong with the code you posted: you have an extraneous
space character between the hex digit patterns in your regex.
--
Bob Walton
------------------------------
Date: Wed, 30 Aug 2000 23:09:55 -0400
From: Todd Cushard <cushard@attglobal.net>
Subject: Re: Oracle, sqlplus, DBI - help
Message-Id: <g0jrqso75svslhabndev50ja6cgq978h3t@4ax.com>
On 18 Aug 2000 17:07:24 GMT, Erik van Roode
<newsposter@cthulhu.demon.nl> wrote:
>Michael Heir <NOSPAMheir@home.net> wrote:
>
>> Here is a sample sqlplus query that works from the command line:
>
>> SET pagesize 2100
>> COL AN format a40
>> SELECT /* FULL(raw) PARALLEL(raw, 4) */
>> sf_raw2name(number) AN, count(*)
>> FROM raw
>> WHERE (site = 'S') and (time >= ( sf_date2time(sysdate) - 86400))
>> GROUP BY sf_alarm2name(alarmnumber)
>> ORDER BY count(*) desc;
>
>
>> I have tried many things to get that to work via DBD::Oracle.
>
>Did you try without the SET pagesize 2100 and COL AN format a40 ?
>Could you show the actual code that you tried, _and_ the errors
>you got?
>
>> Is there any way to submit queries that work from the sqlplus command line
>> through the Perl DBI with DBD::Oracle?
>
> If you mean: everything that works for sqlplus: most likely not.
>sqlplus does preprocessing/postprocessing on the queries you type
>before passing the quer[y|ies] on to the database engine. DBI does
>not do that.
>
>Erik
In my experience with Oracle DBD in the DBI module shows that it will
only respond to pure SQL or PL/SQL. Some of the commands you listed,
such as "SET pagesize 2100" and so on are not SQL or PL/SQL. Instead
they are SQLPlus commands.
Hope this helps.
Todd Cushard
------------------------------
Date: Thu, 31 Aug 2000 01:34:36 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Parsing a Excell table - or - a "Tab New_Line" text file?
Message-Id: <39ADB61E.9F4E4AC@rochester.rr.com>
Etienne Laverdiere wrote:
>
> Yes you are right. I have the same problem now.
> "Mixed numbers and text in a given column don't work.!"
> I must find a way to import any data of any type, like reading for all field
> 'type=>text' for a number or a real text.
> I will continue searching. If you have a solution don't hesitate to write it
> here.
>
> Best Regards,
>
> Etienne Laverdiere
> Montreal
>
...
Etienne, please see my reply to your note time-stamped Saturday at 11:51
PM EDT for how to do what you want to do using OLE. That method returns
whatever the contents of each cell is. If you can't find that note,
here is the code:
use Win32::OLE;
use Data::Dumper;
# use existing instance if Excel is already running
eval {$ex = Win32::OLE->GetActiveObject('Excel.Application')};
die "Excel not installed" if $@;
die "Excel not running" unless defined $ex;
$wb=$ex->Workbooks(1);
$ws=$wb->Worksheets(1);
$ref=$ws->Range("B2:E10")->Value;
print Dumper($ref);
That uses the first worksheet of the first workbook.
--
Bob Walton
------------------------------
Date: Wed, 30 Aug 2000 21:39:28 -0600
From: "Carter" <carter@aodinc.com>
Subject: Passing arrays from subroutines.
Message-Id: <8okjr8$s1r$1@news.chatlink.com>
First I'd like to thank everyone for helping with my sorting problem
earlier. I learned a lot on that one. But, obviously, not enough.
Since that first endeavor, I am now re-writing my script to avoid using
global variables, and utilizing more of an object-oriented approach. This
has shown some new problems. I am a little confused on referencing arrays,
and would like to make sure I am passing the array from the subroutine
correctly.
--begin script --
#!/usr/bin/perl -w
use strict;
my (@stuff, $reference);
my $var=5;
($reference, $var) = &get_data($var);
@stuff = @$reference;
print "The subroutine passed back: ",$var,"\n";
foreach my $element (@stuff) {
print $element,"\n";
}
sub get_data {
# this routine increments the value passed to it, #
# creates an array of fish, and sends both back #
# to whatever called it. #
my $value = $_[0];
my @data = ('yellow tang', 'clown trigger', 'cleaner wrasse');
print "Main sent me: ",$value++,"\n";
return(\@data, $value);
}
--end script--
Is this right?
Thanks for your time.
--
carter
------------------------------
Date: Thu, 31 Aug 2000 01:33:10 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: pattern matching question (in plain ASCII)
Message-Id: <39afb1f9.4188650@news.newsguy.com>
"Lauren Smith" <lauren_smith13@hotmail.com> wrote:
>You can do it with:
>
>$text =~ s#</td>(.*?)<a href#$1#;
>
>but that will only catch the first occurence of '</td>...<a href>', and it
>will obliterate the rest of $text.
Note that it matches from the first '</td>' to the first
'<a href', so there could be additional occurrences of '</td>'
in the middle. Also, it needs the /s modifier if it is to match
across lines.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Wed, 30 Aug 2000 22:50:40 -0400
From: Todd Cushard <cushard@attglobal.net>
Subject: Re: problems installing DBD::oracle for oracle-db-access
Message-Id: <lshrqsovn5el1uqnv178c4aahv8857ejmq@4ax.com>
On 18 Aug 2000 08:08:07 +0100, Jonathan Stowe
<gellyfish@gellyfish.com> wrote:
>On Thu, 17 Aug 2000 10:29:01 GMT rudi_runkel@my-deja.com wrote:
>>
>>> > I thought that there is no need to install any oracle-software when I
>>> > want to connect to a oracle-db via perl on my suse-linux system. Am I
>>> > wring or what do I make wrong?
>>> >
>>>
>>> You are wrong - you need the Oracle client libraries.
>>>
>>>
>> And where do I get those libaries?
>>
>
><http://www.oracle.com> at a guess - I would ask in comp.databases.oracle
>for a better answer though.
>
>/J\
You need Oracle with the Oracle Listener running, along with a valid
TNS file. You address your database connection using an account
defined in your TNS file. I hope I didn't tell you any info you
already knew.
------------------------------
Date: Thu, 31 Aug 2000 02:55:18 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: regexp and accentuated letters
Message-Id: <39b4c303.8551573@news.newsguy.com>
Stéphane BAUSSON <stephane.bausson@free.fr> wrote:
>I would like to know if it is possible in perl to grep a file with word
>with accentuated letter but without giving accentuated word in the
>regexp
>
>Exemple: with pattern e, the result should be e, e acute accent, e grave
>accent, et ...
Unless there's some Unicode-related magic I'm not aware of, I
think you're going to have to preprocess your search pattern
(or else preprocess the whole file to get rid of the diacritical
marks). You could do something like this (apologies to 8-bit-
challenged readers):
my %equiv = (
a => '[AaÀÁÂÃÄÅÆàáâãäåæ]',
e => '[EeÈÉÊËèéêë]',
i => '[IiÌÍÎÏìíîï]',
o => '[OoÒÓÔÕÖØòóôõöø]',
u => '[UuÙÚÛÜùúûü]',
y => '[YyÝýÿ]',
c => '[CcÇç]',
n => '[NnÑñ]',
);
my $letters = '[' . join('', sort keys %equiv) . ']';
my $pattern = 'Ecole';
$pattern =~ s/($letters)/$equiv{lc $1}/gi;
and then use $pattern in your regex. If you want to use more
than one ASCII character to match a Latin 1 character (say, 'ae'
for 'æ', 'ue' for 'ü', 'aa' for 'å', or 'th' for 'þ'), then
you'll have to use something a little more complicated, with
alternations rather than character classes, and worry about the
order of substitutions.
[posted and mailed, as requested]
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Wed, 30 Aug 2000 21:36:52 -0400
From: "Shawn M. Crowley" <smc150@buffnet.net>
Subject: Sorting a Tab Delimited Text File By Second Field
Message-Id: <39adb7a3_1@news3.buffnet.net>
What is the best way to sort a tab delimited file with many records by the
second field, in this situation a date?
Thanks in advance.
------------------------------
Date: Wed, 30 Aug 2000 21:20:32 -0400
From: Joseph Landman <landman@sgi.com>
Subject: Sorting question: I think I am missing something obvious
Message-Id: <39ADB2E0.FE5C3146@sgi.com>
Folks:
Here is my problem, and approximately how I am solving it. The issue
for me is that my solution does not appear to be working. Any
thoughts/advice would be welcome.
I have several arrays which are indexed from 0 .. n_seq, containing
sequence lengths (an integer), sequences (lots of text), and accession
numbers (also text). Call the these arrays
@string_length[0 .. $n_seq]
@complete_sequence[0 .. $n_seq]
@complete_accession[0 .. $n_seq]
These are in no particular order, though the $ith element of each array
is related (e.g. the $complete_accession[$ith] is the accession number
for the $complete_sequence[$ith] element, and the length of the
$complete_sequence[$ith] element is $string_length[$ith]). What I want
to do for a particular little experiment I am working on, is to sort the
arrays by string length (smallest to largest).
Fine, so I look in the texts, man pages, and other such things, and the
following is suggested:
keys my %cache = @string_length;
foreach $len (@string_length)
{
$cache{$len} = $len;
}
@new_accession= sort {$cache{$a} <=> $cache{$b}} @complete_accession;
@new_sequence = sort {$cache{$a} <=> $cache{$b}} @complete_sequence;
@new_string_length = sort {$cache{$a} <=> $cache{$b}} @string_length;
@complete_accession=@new_accession;
@complete_sequence=@new_sequence;
@string_length=@new_string_length;
Now, I can print out all the elements of @string_length, and it looks to
be in the correct order. The problem is that when I look at the
elements of @complete_sequence (whose lengths are represented by the
elements of @string_length) they do not appear to be in order! That is,
I will have one string that has length 70 followed by one of length 63
and followed by one of 130, etc.
What I really really want (I probably cannot have) is to create an array
named @index where the $ith element of @index is the $ith smallest
value. Then I can index my arrays with
$accession_I_want_now = $complete_accession[$index[$ith]];
This would make my coding easier (I think).
However, I am not fixed in my ways. Could anyone suggest a fix? Is my
code broken (likely)? How would you do this? Basically it is using one
array to determine the indexing of another after sorting. I would hate
to have to resort to writing an old algorithm out (especially one of the
non N*log(N) ones) to get what I want...
Am I SOL or is there a way out? Thanks!
--
Joseph Landman, Ph.D., | SGI Americas Technology Center
email: landman@sgi.com | Bioinformatics, Linux, and Clusters
voice: +1 248 848 4469 |
fax: +1 248 848 5600 |
------------------------------
Date: Thu, 31 Aug 2000 02:46:39 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: Sorting question: I think I am missing something obvious
Message-Id: <slrn8qrhns.2cp.mgjv@verbruggen.comdyn.com.au>
On Wed, 30 Aug 2000 21:20:32 -0400,
Joseph Landman <landman@sgi.com> wrote:
>
> I have several arrays which are indexed from 0 .. n_seq, containing
> sequence lengths (an integer), sequences (lots of text), and accession
> numbers (also text). Call the these arrays
>
> @string_length[0 .. $n_seq]
> @complete_sequence[0 .. $n_seq]
> @complete_accession[0 .. $n_seq]
Note that $n_seq is available as $#string_length. I won't keep a
separate variable for it.
> These are in no particular order, though the $ith element of each array
> is related (e.g. the $complete_accession[$ith] is the accession number
> for the $complete_sequence[$ith] element, and the length of the
> $complete_sequence[$ith] element is $string_length[$ith]). What I want
> to do for a particular little experiment I am working on, is to sort the
> arrays by string length (smallest to largest).
You should probably consider storing this stuff in a data structure..
Maybe an array of hashes, or if legibility isn't a problem, an array
of array references. The perldsc and perllol documentation tells you
more about this.
If changing your data structure is too much work, then something like
the following probably will do the job:
my @order = sort
{ $string_length[$a] <=> $string_length[$b] }
(0 .. $#string_length);
@string_length = @string_length[@order];
@complete_sequence = @complete_sequence[@order];
@complete_accession = @complete_accession[@order];
This uses array slices, which are documented in the perldata
documentation.
> Fine, so I look in the texts, man pages, and other such things, and the
> following is suggested:
>
> keys my %cache = @string_length;
> foreach $len (@string_length)
> {
> $cache{$len} = $len;
> }
You store the length of the string in a hash with the keys being equal
to the values. You have basically not gained much now :)
> @new_accession= sort {$cache{$a} <=> $cache{$b}} @complete_accession;
$cache{$a} where $a is an element of @complete_accession will just be
undefined (unless accidentally one of the strings in
@complete_accession is equal to the stringified version of one of the
elements of @string_length, in which case it will be equal to $a
anyway).
> @new_sequence = sort {$cache{$a} <=> $cache{$b}} @complete_sequence;
same here.
> @new_string_length = sort {$cache{$a} <=> $cache{$b}} @string_length;
For this one is\t would work, but so would
@new_string_length = sort {$a <=> $b} @string_length;
Since $cache{$a} is equal to $a (apart maybe from some
stringification, details, details. Functionally, in this case, they're
equal).
> @complete_accession=@new_accession;
> @complete_sequence=@new_sequence;
> @string_length=@new_string_length;
These assignments could have been done in one go.
> What I really really want (I probably cannot have) is to create an array
> named @index where the $ith element of @index is the $ith smallest
> value. Then I can index my arrays with
See the array @order, above.
> $accession_I_want_now = $complete_accession[$index[$ith]];
>
> This would make my coding easier (I think).
Not sure. I think it would be easiest if you kept the stuff in a
sorted single array or array references.
> However, I am not fixed in my ways. Could anyone suggest a fix? Is my
> code broken (likely)? How would you do this? Basically it is using one
> array to determine the indexing of another after sorting. I would hate
> to have to resort to writing an old algorithm out (especially one of the
> non N*log(N) ones) to get what I want...
If you don't want to resort, the only thing you can do is insert in
sorted order. ;) [1]
Martien
[1] I know.. Bad puns are offtopic and a shootable offense.
--
Martien Verbruggen |
Interactive Media Division | The gene pool could use a little
Commercial Dynamics Pty. Ltd. | chlorine.
NSW, Australia |
------------------------------
Date: Wed, 30 Aug 2000 23:22:31 -0400
From: Todd Cushard <cushard@attglobal.net>
Subject: Re: Were are all the executibles?
Message-Id: <mnjrqssiftaa1ef6b89kurnbiobvo00bjs@4ax.com>
On Sun, 20 Aug 2000 02:23:04 -0500, "Dale Emmons"
<dale@emmons.dontspamme.com> wrote:
>> Why is Perl a scripting language?
>
>Why is the moon that large object that orbits the earth?
>
>> Why one can't make executibles (this
>> is, *.exe files)?
>
>You can...
>
>> Wouldn't compiling be much more intelligent than
>> interpreting? That way anybody could drive a perl program without
>> having perl interpreter!
>
>Depends on your definition of intelligent (be carful with that word, you can
>easily offend people).
>I use perl because it is a scripting language... it makes development much
>faster and in many cases easier than compiling code every time I make a
>change.
>
>> Thanks for answering!
>>
>> John S. Brown.
>>
>>
>> Sent via Deja.com http://www.deja.com/
>> Before you buy.
>
This seems like such a silly question. Dale Emmons did a good job
with it though. Your question is very subjective and depends upon
your needs and experience. I was a C programmer before I programmed
in Perl, and I didn't miss the compiler one bit. But like Dale said,
if you want an executable, you can achieve that, after you've
developed and debugged.
Todd Cushard
------------------------------
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 V9 Issue 4184
**************************************