[9857] in Perl-Users-Digest
Perl-Users Digest, Issue: 3450 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 14 20:07:28 1998
Date: Fri, 14 Aug 98 17:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 14 Aug 1998 Volume: 8 Number: 3450
Today's topics:
Re: $string = chomp <FILEHANDLE> ??? <uri@sysarch.com>
Re: Apache mod_rewrite, PROBLEM SOLVED (John Moreno)
Re: CGI on Browser <Udownload@NE.Mediaone.net>
Re: clp.moderated setup info? (Greg Bacon)
Re: clp.moderated setup info? <rra@stanford.edu>
convert ascii files <arm@home.net>
Error/exception handling (was: Re: Perl spontaneously j <glew@hf.intel.com>
Re: File updating question <jdporter@min.net>
Re: File updating question (Mark-Jason Dominus)
Re: HELP: asterisk(*) on SYSTEM command (Nestor Florez)
Re: here's an implementation of diff in perl (Mark-Jason Dominus)
Re: here's an implementation of diff in perl (Mark-Jason Dominus)
Re: How can I execute an external program from Perl wit (Matthew Bafford)
How to "flip" a hash of arrays? <tringali@ed.ray.com>
Re: How to "flip" a hash of arrays? (Greg Bacon)
Re: How to append at the top of the logfile ? (Miguel Cruz)
Re: How to append at the top of the logfile ? (Miguel Cruz)
Integration of perl into C <Harry_Andree@smtplink.mssm.edu>
Re: localtime showing wrong info (Abigail)
OLE Perl Excel question olivierh3964@my-dejanews.com
OLE Perl Excel olivierh3964@my-dejanews.com
Re: Perl and NT and SQLServer (Alastair)
Re: Printing large numbers with commas <jdporter@min.net>
Re: Q: How to read all the file name in a directory <upsetter@ziplink.net>
Re: Q: How to read all the file name in a directory <grant.griffin@nospam.com>
Regex Mania - (was Re: X-file (?=...), case postponed.) (Patrick Timmins)
Re: retrieving hash name dnguyen@dejanews.com
Re: retrieving hash name (Craig Berry)
Re: RFA: searching for binary pattern in binary file vi <jdporter@min.net>
Re: testing if file exists <rootbeer@teleport.com>
Re: testing if file exists (Andrew M. Langmead)
Re: timeout or time limiting function <grant.griffin@nospam.com>
Using Perl module without access to Perl installation roguemouse@yahoo.com
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Aug 1998 22:03:02 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: $string = chomp <FILEHANDLE> ???
Message-Id: <x7soj048x5.fsf@sysarch.com>
>>>>> "MA" == Maurice Aubrey <maurice@hevanet.com> writes:
MA> On 13 Aug 1998 11:03:45 GMT, Thomer M. Gil <tmgil@keg.cs.vu.nl>
MA> wrote:
>>
>> $string = chomp <FILEHANDLE>;
MA> from 'perldoc -f chop' :
MA> You can actually chop anything that's an lvalue, including an
MA> assignment:
MA> chop($cwd = `pwd`); chop($answer = <STDIN>);
but he did state chomp, so you should use chomp also. in general chomp
is better than chop since it will work on an array of lines and it
removes the input record separator from a string only if it is at the end
of the string. chop just removes the last char of a string, period.
chomp >> chop.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Fri, 14 Aug 1998 17:05:13 -0400
From: phenix@interpath.com (John Moreno)
Subject: Re: Apache mod_rewrite, PROBLEM SOLVED
Message-Id: <1ddrgef.1nvl6aneg578tN@roxboro0-058.dyn.interpath.net>
Rosenet Technical Support <support@rosenet.net> wrote:
> Rosenet Technical Support wrote:
> >
> > Hello all,
-snip-
>
> I figured it out...
-snip it was the server-
Next time try: comp.infosystems.www.authoring.*
--
John Moreno
------------------------------
Date: Fri, 14 Aug 1998 17:18:14 -0400
From: UDownload <Udownload@NE.Mediaone.net>
Subject: Re: CGI on Browser
Message-Id: <35D4A996.39AC51B@NE.Mediaone.net>
Lawrence Han wrote:
> Hi there,
>
> I am a new perl programmer.
> I am able to run my perl 5.0 on win95. Consider the following:
I'm also mostly new to Perl (although I've done a bit at work on Unix). I'm
trying to get perl to run on Windows NT with peer web services and I'm
having the same problem. It didn't help me, but there were some things on
www.activestate.com (the Active State website.) I did everything there
(took care of the permissions and registry settings). As far as I can tell,
everything should work and does work, but only from the command line.
Through a browser I get the "CGI misbehaving" message.
Has anyone got perl to work with peer web services?
Thanks in Advance,
>
>
> print "Content-type: text/html\n\n";
> print "<html><head><title>Nil</title></head>\n";
> print "<body bgcolor=black text=white>\n";
> print "<br>Hello World!</br></body></html>\n";
>
> When I run on my DOS prompt C:\perl\perl hello.cgi, things seems to be
> running smoothly. However when I launched my Netscape browser with the
> URL pointing to the hello.cgi on my hard disk, the browser doesn't seem
> to execute anything. I get the entire perl code printed out instead.
> Please help.
>
> lawrence_han@post1.com :)
------------------------------
Date: 14 Aug 1998 23:16:24 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: clp.moderated setup info?
Message-Id: <6r2gg9$p50$2@info.uah.edu>
In article <6r1p05$gms$1@marina.cinenet.net>,
cberry@cinenet.net (Craig Berry) writes:
: My ISP's news admin appears to have misconfigured clp.moderated such that
: I can't post to it (well, I can, but it doesn't go to the moderators and
: thus doesn't propagate properly). He's attempting to fix this, but
: neither of us can find the config info needed to install it properly. And
: to compound the problem, I'm not entirely sure what such info consists of.
Well.. uunet has its relay that should always point to the proper
submission address. For clpmod, it's
<comp-lang-perl-moderated@uunet.uu.net>
Notice the easy little C<s/\./-/g>. This applies in the general case.
I believe ISC also provides this sort of relay, but Russ would be the
one to confirm or deny it.
It's also possible to mail a submission directly. Check out the clpmod
FAQ for details on that.
What news server are you using? Is it some piece of Macrotrash? I
thought INN did this automatically when you add a moderated group.
Greg
--
When a man is more right than his neighbor, that constitutes a majority of
one.
-- Thoreau
------------------------------
Date: 14 Aug 1998 16:46:50 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: clp.moderated setup info?
Message-Id: <m33eazi0t1.fsf@windlord.Stanford.EDU>
Greg Bacon <gbacon@cs.uah.edu> writes:
> Well.. uunet has its relay that should always point to the proper
> submission address. For clpmod, it's
> <comp-lang-perl-moderated@uunet.uu.net>
> Notice the easy little C<s/\./-/g>. This applies in the general case.
> I believe ISC also provides this sort of relay, but Russ would be the
> one to confirm or deny it.
The current recommended address is:
comp-lang-perl-moderated@moderators.isc.org
If your ISP is running INN, like many of them are, then there is a news
configuration file called "moderators" and it should end in the following:
# Default
*:%s@moderators.isc.org
This will take care of pretty much all moderated groups magically.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Fri, 14 Aug 1998 23:58:30 GMT
From: Alan Melton <arm@home.net>
Subject: convert ascii files
Message-Id: <35D4CDFB.F81EB3AB@home.net>
I have written a short perl program to convert
individual ascii files arranged vertically into
a single database, comma delimited,then delete the original file.
i.e. original file:
new
Alumnus
NY
November
1997
@
12M
1
0.99
0.99
12M. The "Window Decal", Category: GIFTS
*
0.99
0.00
6.00
0.0
0.00
6.99
the program:
#!/usr/local/bin/perl
# Age and erase stale audit files.
open OUTPUT, ">>source.dat" or die "cannot append to output: $!";
chdir "/home/web/ushop/public_html/audit" or die "Cannot chdir: $!";
for $filename (<*>) { # get all filenames in current directory
open IN, $filename or die "Cannot read $filename: $!";
@a = <IN>; # read all lines of this file
chomp (@vals=@a[1,2,3,4,6,6,7,8]);
print OUTPUT join (",",@vals), "\n"; # print lines 1,3,7 etc (offset
by one)
chomp (@vals=@a[1,2,3,4,11,11,12,13]);
print OUTPUT join (",",@vals), "\n"; # print lines 1,3,7 etc (offset
by one)
chomp (@vals=@a[1,2,3,4,16,16,17,18]);
print OUTPUT join (",",@vals), "\n"; # print lines 1,3,7 etc (offset
by one)
close IN;
unlink $filename or die "Cannot delete $filename: $!";
}
result:
Alumnus,NY,November,1997,12M,12M,1,0.99
Alumnus,NY,November,1997,*,*,0.99,0.00
Alumnus,NY,November,1997,0.00,0.00,6.99
New problem: in the original single file, there is always an @ and a *
new
Student
OH
August
1998
@ <----------------
1002
1
28.25
28.25
Accounting:Conc.+Appl.-Std.Gde.1-14 5th 96 New
1004
1
84.45
84.45
Accounting:Concepts & Application 1st New
* <--------------------
112.70
0.00
12.50
5.75
6.48
131.68
I would like to do the same as before but only pull out the data
after the @ sign and put that into one file
and pull out the data after the * and put that into a different file.
Any suggestions on how to search for the @ and the * and then
read the lines after them as in the original program?
Thanks,
Alan Melton, MD
------------------------------
Date: 14 Aug 1998 21:22:45 GMT
From: "Andy Glew" <glew@hf.intel.com>
Subject: Error/exception handling (was: Re: Perl spontaneously jumps to other Perl code)
Message-Id: <01bdc7c4$74c97880$82dcb58f@aglew2>
> Urgh. Blush. Embarassed.
>
> Uncaught die exceptions in evals...
Okay, I realize that I have unconsciously had a C++, LISP, or even Ada exception handling model
in my mind, as opposed to Perl's eval model - which is a slight improvement on C's.
I.e. Perl by default "catches" and ignores any exception generated inside an eval (by die).
At the eval site, it is necessary to check the return value (for undef), and $@ (in case
it is legitimate for your eval to return undef, as happens to be in my design, since
I am using undef for SQL 'NULL' values), and then do further handling.
Unfortunately, I have lots of eval sites, since my evals need access to lexically scoped variables.
(If Perl had macros, I would use a macro...)
I.e. Perl is ignore by default inside eval,
optionally explicitly catch at eval site and arrange to propagate.
Q: is there anything that more closely approximates the C++/LISP/Ada strategy,
which I might summarize as
"don't ignore by default; propagate by default;
optionally explicitly catch at XXX site and optionally ignore at XXX site"?
{Where XXX site = catch/throw for LISP, or try/accept site for C==, and I forget what for Ada.}
I.e. is there a Perl exception mechanism which is conservative by default,
not optimistic by default?
----
(And, while we are at it, can anyone point me to any other exception/error handling models;
these are a longstanding interest of mine.)
---
Please respond by email,
in addition to replying to these newsgroups.
------------------------------
Date: Fri, 14 Aug 1998 17:47:34 -0400
From: John Porter <jdporter@min.net>
Subject: Re: File updating question
Message-Id: <35D4B076.3EE3@min.net>
Tom Christiansen wrote:
>
> "Perl is to sed as C is to assembly language." -me
It's too bad this quote is stuck permanently in your
quotes file, because it's pathetically inaccurate.
C *is* assembly language, with a sweeter syntax.
I don't think you could rightly characterize the
relationship between Perl ans sed that way.
--
John Porter
------------------------------
Date: 14 Aug 1998 19:23:53 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: File updating question
Message-Id: <6r2gu9$reh$1@monet.op.net>
In article <35D22A95.8307D860@NOSPAMxwebdesign.com>,
Ketan Patel <ketanp@NOSPAMxwebdesign.com> wrote:
>>
>> > open(DATA, ">$datapath")
>> > || print ("Son, it's not my fault.");
>> > flock(DATA, 2);
>>
>> That's not a good way to cooperate with other processes. If another
>> process were writing that file, you just clobbered it!
>>
>
>Can you further explain this statement? How would this ruin the file if
>every other call to open the file also has an exclusive lock?
Suppose programs A and B are running simultaneously.
Someone executes A.
A opens $datapath, which erases it completely.
A locks $datapath.
A A writes a lot of data to $datapath.
Someone executes B.
B opens $datapath, which erases it completely.
B tries to lock $datapath, finds it locked by A, and blocks.
A discovers that the file has been unexpectedly erased and goes berserk.
Locks don't affect `open'; the only affect `flock'.
------------------------------
Date: 14 Aug 1998 23:38:47 GMT
From: nestor@sd.cadence.com (Nestor Florez)
Subject: Re: HELP: asterisk(*) on SYSTEM command
Message-Id: <6r2hq7$r7k$1@news.cadence.com>
OK, I look at the globbing command on page 140 of the camel and it says
that if I use a command as:
@a= </etc/host*>;
This will give me back all the files that start with 'host' in the /etc
directory.
Is there a way in PERL to use the "cp -r /etc/host* /tmp" using a single
command as:
system("cp -r /etc/host* .tmp")
Or do I have no choice but to use a loop?
foreach $file (@a)
{
system("cp $file $directory");
}
Thanks,
Nestor
In article <6r1reh$gms$5@marina.cinenet.net>,
Craig Berry <cberry@cinenet.net> wrote:
>Nestor Florez (nestor@sd.cadence.com) wrote:
>: To list a directory in a UNIX platform you type "ls -l *"
>: The asterisk in a wild card for all the files.
>
>Actually, just plain "ls -l" lists just the current directory. "ls -l *"
>recurses into subdirectories.
>
>: When I try passing the arguments in this small perl program:
>: -----
>: @args = ("ls", "-lt", "*", "\*", "?\*.pl");
> ^ ^
>
>What are these backslashes supposed to be doing? They are meaningless as
The slashes where there, because I was testing the command on a print
statement.
>you've used them; your arg list above is equivalent to ("ls", "-lt", "*",
>"*", "?*.pl") -- which doesn't make a lot of sense.
>
>: if( system(@args) == 0)
>
>The list-of-args form of the system() call specifically disables shell
>wildcard expansion.
>
>: {
>: print "IT WORKED\n";
>: }
>: else
>: {
>: print "IT DID NOT WORK\n";
>: }
>: -----
>:
>: It does not recognize the asterisk.
>: How do I pass the asterisk to the system?
>
>Either glob the files yourself, or use the single-argument form of
>system().
>
>---------------------------------------------------------------------
> | Craig Berry - cberry@cinenet.net
> --*-- Home Page: http://www.cinenet.net/users/cberry/home.html
> | Member of The HTML Writers Guild: http://www.hwg.org/
> "Every man and every woman is a star."
--
______________________________________________________________________
Nestor Alberto Florez Torres | "Authority Gone to one's head is the |
| greatest enemy of thruth." Einstein |
|---------------------------------------
------------------------------
Date: 14 Aug 1998 19:49:36 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: here's an implementation of diff in perl
Message-Id: <6r2ieg$ri2$1@monet.op.net>
In article <35D4343F.4738@min.net>, John Porter <jdporter@min.net> wrote:
>Do you read this newsgroup? Mark-Jason Dominus wrote
>a diff in perl already, and it uses the same algorithm
>(essentially) as the unix one does.
You have to be careful with that. DIfferent versions of `diff' use
different algorithms. For exmlpe, I was just reading up on GNU diff,
and it has an option that makes it run slower but always find the
minimal set of changes. Since mine always does that, it must be using
a different algorithm from the one used by GNU diff if you don't
specify that option.
Eugene's program has some advantages and disadvantages when compared
to mine: My program does not produce diff-compatible output suitable
for feeding to `patch', although this is easy to add, and I hope to
have it done soon. But Eugene's program sometimes generates the wrong
answer (!) and sometimes goes into an infinite loop.
For comparison, my own version is at
<URL:http://www.plover.com/~mjd/perl/diff/>
------------------------------
Date: 14 Aug 1998 19:51:05 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: here's an implementation of diff in perl
Message-Id: <6r2ih9$rjf$1@monet.op.net>
In article <35D4343F.4738@min.net>, John Porter <jdporter@min.net> wrote:
>> while(<FILE1>) {
>> chomp;
>> @filearray1[$i++] = $_;
>> }
>
>This is better:
> @filearray1 = (); # initialize it.
> while (<FILE1>) {
> chomp;
> push @filearray1, $_;
> }
>No counters needed.
chomp(@filearray1 = <FILE1>);
No loop needed.
------------------------------
Date: Fri, 14 Aug 1998 22:08:45 GMT
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: How can I execute an external program from Perl with parameters?
Message-Id: <MPG.103e76c11675a38989699@news.scescape.net>
In article <35D497C7.1F5F93A2@nextel.no> on Fri, 14 Aug 1998
22:02:15 +0200, Xyvind Bangsund (a) felt the following
information to be of use:
> Like:
>
> $output = `externalprogram.exe parameters`;
> print $output;
>
> ???
What's wrong with the example you gave?
???
Works fine on both Win32 & Linux over here...
--Matthew
------------------------------
Date: Fri, 14 Aug 1998 15:20:57 -0400
From: "Scott J. Tringali" <tringali@ed.ray.com>
Subject: How to "flip" a hash of arrays?
Message-Id: <35D48E19.41C6@ed.ray.com>
Say I have a hash of arrays:
%h1 = (
"a" => [ "1", "2" ],
"b" => [ "2", "4" ],
"c" => [ "1", "2", "3", "4" ],
);
Does anyone know a good way of "flipping" the association, so I get:
%h2 = (
"1" => [ "a", "c" ]
"2" => [ "a", "b", "c" ]
"3" => [ "c" ]
"4" => [ "b", "c" ]
);
I have a couple nested "for"s with an inner "push", but it's ugly.
There's gotta be a better way.
Thanks,
Scott
------------------------------
Date: 14 Aug 1998 23:25:41 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: How to "flip" a hash of arrays?
Message-Id: <6r2h1l$p50$3@info.uah.edu>
In article <35D48E19.41C6@ed.ray.com>,
"Scott J. Tringali" <tringali@ed.ray.com> writes:
[set of sets converted to which sets contain which elements]
: I have a couple nested "for"s with an inner "push", but it's ugly.
: There's gotta be a better way.
This is what I came up with:
while (my($k,$v) = each %h1) {
for (@$v) {
push @{ $h2{$_} }, $k;
}
}
Since you didn't post your solution, I don't know how much uglier
mine is. :-) How do they compare?
Greg
--
Those who do not understand UNIX are condemned to reinvent it -- badly.
-- Henry Spencer
------------------------------
Date: 14 Aug 1998 23:04:20 GMT
From: mnc@diana.law.yale.edu (Miguel Cruz)
Subject: Re: How to append at the top of the logfile ?
Message-Id: <6r2fpk$95g$1@news.ycc.yale.edu>
Andre Merzky <am@am.westblaak.spirit.nl> wrote:
> for instance, write a version of "more" that pages backwards through a
> file.
>
>you mean: 'tac | more' ?
Well, well, well... I learn something every day. Thanks!
miguel
------------------------------
Date: 14 Aug 1998 23:07:36 GMT
From: mnc@diana.law.yale.edu (Miguel Cruz)
Subject: Re: How to append at the top of the logfile ?
Message-Id: <6r2fvo$9gj$1@news.ycc.yale.edu>
- wrote:
> To write to the top of a file, simply create a new file, write your
> new first line, then append the original file to this new file and
> rename it to the original file name. use cat to accomplish this
Yes, of course, but when you're adding a line every second or two to a 500K
file, this is going to start to kill your poor system. That was sort of my
point.
miguel
------------------------------
Date: Fri, 14 Aug 1998 17:23:38 -0400
From: Harry Andree <Harry_Andree@smtplink.mssm.edu>
Subject: Integration of perl into C
Message-Id: <6r29ir$gs7$1@news-1.news.gte.net>
I'm trying to speed up some of the perl functions by recoding it in C.
I use the perl.h library.
I retrieve an HV pointer with the perl_get_hv function
Then I retrieve an sv by calling the hv_iterinit function
and hv_iternextsv. The latter call works fine but if I
put the function in a subroutine I get a SEGV error
and core dump: this is the code:
char* totoken(char *var) {
char buffer[50];
char str[5000];
HV* hv = NULL;
SV* sv = NULL;
char *name = NULL;
char *value = NULL;
int maxkeys;
int n, len, len1;
strcpy(buffer, var);
hv = perl_get_hv(buffer, 1);
tohash(hv);
return str;
}
char* tohash(HV* hv) {
char str[5000];
SV* sv = NULL;
HE* he = NULL;
char *name;
char *value = NULL;
int maxkeys;
int n, len, len1;
maxkeys = hv_iterinit(hv);
strcpy(str , "<");
len = 10;
for (n=0;n<maxkeys;n++) {
sv = hv_iternextsv(hv, &name, len);
strcat(str, ":");
strcat(str, ";");
}
strcat(str , ">");
return str;
}
What am I doing wrong?
Harry Andree
------------------------------
Date: 14 Aug 1998 23:50:52 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: localtime showing wrong info
Message-Id: <6r2igs$mlj$2@client3.news.psi.net>
Steve . (syarbrou@ais.net) wrote on MDCCCIX September MCMXCIII in
<URL: news:35d45010.7010213@news.ais.net>:
++ Why does localtime show everything correctly except for the month. My
++ system clock is set to August, but it is showing 7 for the month
++ number. The year shows 98 and the day shows 14. Is the month
++ starting with 0? If so, what's the deal with that? If not, what's
++ going wrong? This is on Solaris. Thanks.
Odd. You think '98' is the correct year, but you're confused about month '7'.
Is there a reason why you didn't read the manual?
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: Fri, 14 Aug 1998 22:00:26 GMT
From: olivierh3964@my-dejanews.com
Subject: OLE Perl Excel question
Message-Id: <6r2c1q$sul$1@nnrp1.dejanews.com>
I am trying to find the perl syntax to read the container instead of the value
of a cell.
Ex: to read the value I would use the following syntax
my $variable = $ex->Range("A1")->{Value};
Assuming that cell A1 points to cell D5. I want to set my variable to "D5" by
reading cell A1
Here is the context. I am trying to write a Perl script that would read cells
in an Excel spreadsheet containing variables names and links to active cells.
The ouput will be another Perl script that could be use by another
application. In another words I am trying to autogenerate a Perl Script based
on the information located in the spreadsheet.
As anybody tried that ?
Thanks in advance for the help
Olivier
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 14 Aug 1998 22:31:11 GMT
From: olivierh3964@my-dejanews.com
Subject: OLE Perl Excel
Message-Id: <6r2drg$viu$1@nnrp1.dejanews.com>
I am trying to read the container of a cell instead of its value in Perl.
To read its value I would do :
my $Variable = $ex->Range("A1")->{Value};
Assuming that A1 point to B5, I want to set my variable to "B5".
Here is the context. I am writing a perl script that would read certain cells
on a spreadsheet containing variable names and links to them ( aka "B5" ).
The ouput will be another perl script. In other word I am trying to
autogenerate a perl script by reading the info from an Excel spreadsheet.
If anybody tried this, what is the syntax ?
Thanks for the help
Olivier
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 14 Aug 1998 22:11:58 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Perl and NT and SQLServer
Message-Id: <slrn6t9h6v.5i.alastair@calliope.demon.co.uk>
aschneid@cmp.com <aschneid@cmp.com> wrote:
>Where can I get a version of Perl for NT and (more importantly) where/how I
>can tap into a SQLServer 6.5 database using Perl. I use Perl 5 on solaris and
>access our Oracle database using OraPerl. Does something like that exist for
>NT/SQLServer??
I guess if you use Perl, you should know about CPAN. I think you'll find links
to everything you need there - including Perl for NT. As far as SQL server goes,
perhaps an ODBC module might help.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Fri, 14 Aug 1998 17:50:07 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Printing large numbers with commas
Message-Id: <35D4B10F.39D9@min.net>
Tom Phoenix wrote:
> On Fri, 14 Aug 1998 heinrich7486@my-dejanews.com wrote:
> > Subject: Printing large numbers with commas
> FAQ.
I sense the robot's patience is finally beginning
to wear thin...
--
John Porter
------------------------------
Date: 14 Aug 1998 21:14:35 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Q: How to read all the file name in a directory
Message-Id: <6r29br$5in@fridge.shore.net>
Ollie Cook <oliver.REMOVE.cook@bigfoot.DELETE.com> wrote:
:>Let me guess: you're a Windows ``programmer'', aren't you? Do you
:>know why Unix programmers make more money than Windows ``programmers''?
:>Because we Unix people know how to read the manual -- and you don't.
: Actually, Perl is the only language, apart from DOS Basic that I've
: ever programmed in.
: Don't you think it's odd how two people answered my answer kindly,
: nicely and to the point, and you flew off the handles?
Unfortunately, it's not odd at all. Some people just can't keep themselves
from (a) second-guessing the newbies on this group or (b) insulting anyone
who does things differently from them (different OS, different syntax,
etc.)
--Art
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Fri, 14 Aug 1998 15:32:03 -0500
From: Grant Griffin <grant.griffin@nospam.com>
Subject: Re: Q: How to read all the file name in a directory
Message-Id: <35D49EC3.98E4CE44@nospam.com>
Tom Christiansen wrote:
> Let's see. You need a function that reads files from directories. Does
> Perl not ship with complete documentation describing its functionality and
> including examples? Is there not a manpage that describes Perl functions?
> Can you not search that document for the relevant keywords you mentioned?
> Does that manpage not contain at least two functions that will help you?
> Do these documents not reside on your own system? Do you know have an
> HTML version? Do you not realize that help is waiting there locally
> for you?
>
> Let me guess: you're a Windows ``programmer'', aren't you? Do you
> know why Unix programmers make more money than Windows ``programmers''?
> Because we Unix people know how to read the manual -- and you don't.
>
> --tom
Tom,
Sorry to do unto you what you do unto others, but...
If there are too many inane messages in this newsgroup, why not just start a
newsgroup for people who should have read the manual? Let's call it
"comp.lang.perl.cantread".
I'm new around here, so I'm still trying to figure out how trashing people is
useful. Evidently it is not only useful, it is _very_ useful, judging by the
amount of effort spent doing it. For example, you just spent twice as much
effort trashing the guy as you would have spent answering his question. Among
the communities of Humanity, Perl, and Your Ego, I can only think of one which
benefits. Also, if money is the criteria, how much money did you just get
paid to blat that guy? Trashing people may be fun, but try to consider how
the Human Being at the other end of the tube feels. Moreover, think about how
those other Human Beings view The Trasher.
Every religion needs its Apostle, and those of us who use Perl owe you a
tremendous debt of gratitude in that sense, but seeing what goes on here makes
me think that Apostle-ing might be carried out in a more positive way--as it
has been in other religions. (I can just hear the Apostle Paul now: "Why are
you asking me some stupid question about morality? Is there not a Ten
Commandments manpage?")
All that aside, this message gives me an opportunity to thank you for all your
great Perl work. Thanks! I hope you got a nice little royalty when I bought
"Programming Perl". (Yes, I even read it!)
=g2
--
while. -- Larry Wall, comment in hash.c
all opinions are mine, not my employer's, and not Larry Wall's.
------------------------------
Date: Fri, 14 Aug 1998 22:40:23 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Regex Mania - (was Re: X-file (?=...), case postponed.)
Message-Id: <6r2ecn$76$1@nnrp1.dejanews.com>
Regarding @arr = split /(?=(.*))/s, "Just another Perl Hacker\n";
Ronald, Abigail, ... Friends ... Romans, countrymen! Lend me your
ears! I come to praise regexes, not to bury them!
Ronald, I swear to you, I *do* understand how the regex engine works.
I *do* know it works left to right. And I *do* know that regexs are
not mathematical expressions. I wish you would stop saying that I don't
in all these matters and just attack my argument instead.
I don't know how many times I've said this, but apparently not often
enough: In *reality* (regardless of *how* the regex engine accomplishes
this), REGEXES *OBEY* MATHEMATICAL RULES OF PARENTHETICAL PRECEDENCE.
That is not to say they come to obey these rules in the same fashion
as mathematical expressions, because they DON'T. Regexes use backtracking
to accomplish it, while mathematical expressions actually go and evaluate
things in the order specified by parentheses from the very start. But
even so, and I must stress it again, REGEXES *OBEY* MATHEMATICAL RULES
OF PARENTHETICAL PRECEDENCE.
By *definition*, by where we place our paretheses, what ends up
in /../ is *dependent* on what ends up in (?=..), and what ends up
in (?=..) is *dependent* on what ends up in (.*). de Facto. By
the use of the parentheses themselves, we are *telling* Perl to make
it so (via backtracking).
Whatever is going to end up in (.*) has to be "finalized", so to
speak, before you can finalize whatever is going to end up in (?=..).
Likewise, whatever is going to end up in (?=..) has to be finalized
before you can finalize whatever is going to end up in /../.
We *told* Perl to "make it so", by how we structured the expression
with the parentheses. I'm sorry if you are not happy about the way Perl
is able to do this in a "left to right" fashion using backtracking,
but please stop taking this out on me! :) The end result is that
regexes obey mathematical rules of parenthetical precedence.
In the illustrations that follows, I mean for the '..' to stand
for "something in between the '(' and ')', NOT two "any character"
symbols:
For example, split/(?=(..))/s, "Just another Perl Hacker\n";
is going to split on some null that is followed by whatever
ends up in (..). Since we don't know yet what (..) is, we currently
cannot know where we are going to split. The split/../ *depends* on
knowing what is in (..) before it can operate.
Now let's suppose we put a 'u' in (..):
@arr = split/(?=(u))/s, "Just another Perl Hacker\n";
We now know there's a 'u' contained in (..), so we then know that
what we need to split on in a null character that is immediately
followed by a 'u'. This gives 'J' and 'ust another Perl Hacker\n',
along with a 'u' thrown in between (which happens just as described
in the documentation regarding parenthetical substrings of delimiters
in the split function).
Elem 0 is J
Elem 1 is u
Elem 2 is ust another Perl Hacker
Isn't it clear that we had to know what was in (..) before we could know
where to split? If this were not the case, then it wouldn't matter what
you put in (..), would it? And this is certainly not the case:
If we had known (..) contained a 't' instead of a 'u', we then would know
that what we need to split on in a null character that is immediately
followed by a 't', which would give:
Elem 0 is Jus
Elem 1 is t
Elem 2 is t ano
Elem 3 is t
Elem 4 is ther Perl Hacker
So again, we have to know what is in (..) before we can know where to
split. Now let's do the same thing for our original example:
@arr = split /(?=(.*))/s, "Just another Perl Hacker\n";
Since it's now clear that we must know what's in (.*) before we can
know where to split, lets evaluate it. It will match the longest
string in EXPR that it can, where you have zero or more of any
character. For our example, this will match the entire line in EXPR,
including the '\n' (thanks to the /s modifier on the end of the regex).
So we now know that we have "Just another Perl Hacker\n" in the (.*).
But wait a minute. According to the split documentation:
"If the PATTERN contains parentheses, additional array elements
are created from each matching substring in the delimiter."
Also, according to the documentation, these additional array elements
are created *as they are encountered* in the EXPR. Again, from the split
documentation:
split(/([,-])/, "1-10,20");
produces the list value (1, '-', 10, ',', 20)
Since we know what is contained in (.*) even before we know what to
split on (as demonstrated above), and since the split docs show that
any parenthetical substring in the delimiter is thrown on to the
array as it is encountered, and since we encounter the parenthetical
substring (.*) instantly when evaluating EXPR, then in the name of the
documentation, logic, mathematical rules of parenthetical precedence,
*and* just plain old common sense, the first element on the array
*should* be 'Just another Perl Hacker\n'.
However, it is not. Instead Perl throws out 'J' as the first element.
This should not be.
Ronald and Abigail, you both just come back with a "you don't understand
how regexes work" or "it's in the documentation" sort of response
to my arguments. For ONCE, could you please attack my argument above
instead of me, and explain to us all where I am mistaken, and then tell
us how it truly works.
Since neither of you has done this to date, I'm beginning to think that
neither of you knows why this odd behavior occurs either, but you're just
afraid to admit it. It's not a sin to be confused about something, or to make
a mistake, you know! Your status isn't going to be hurt by one little mistake
(at least not in the eyes of people that matter). It is a sin, however, to
attack or vilify others in order to cover your own mistakes or confusion. If
this is the case, then you will "drop like a stone" in the eyes of *all*
the people that matter (by definition! :).
Please convince us that this is not the case. Attack the argument above.
It may well be that we have a bug here! For example, how to you explain
the output of @arr = split/(?=(J))/s, "Just another Perl Hacker\n"; ?
This throws out a one element array of 'Just another Perl Hacker\n'. Where
is the additional 'J' element (which, of course, should be thrown on to
the array *prior* to the other element, as I'm sure, by now, you'll
agree :) ?
If we take care of this now, you'll have the additional bonus of not having
to read long posts from me on the topic! :)
Patrick Timmins
U. Nebraska Medical Center
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 14 Aug 1998 22:15:27 GMT
From: dnguyen@dejanews.com
Subject: Re: retrieving hash name
Message-Id: <6r2cu0$u1l$1@nnrp1.dejanews.com>
In article <6r1ajp$9oc$2@csnews.cs.colorado.edu>,
tchrist@mox.perl.com (Tom Christiansen) wrote:
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
> mwilhelm@ccat.sas.upenn.edu (Mark C. Wilhelm) writes:
> :Suppose one "dynamically" names a hash during the course of a script, and
> :then creates a reference to the hash. Is is it possible, using the
> :reference, to retrieve the _name_ of the hash as well as the key/value
> :pairs? If so, how would one do this?
>
> Why oh why would you be creating a name of a hash on the fly?
> This always suggests to me that someone doesn't understand
> hashes. While you could write this:
>
> $name = "fred";
> $name->{WIFE} = "wilma";
>
> $name = "barney";
> $name->{WIFE} = "betty";
>
> Better to write:
>
> $folks{"fred"} {WIFE} = "wilma";
> $folks{"barney"}{WIFE} = "betty";
>
> --tom
> --
>
I can think of a scenario when I would create the name of the hash on the fly.
Suppose I need to parse the following file:
varname = "TV show" {
varname = "Flintstone" {
varname = "family" {
othervar = "other stuff"
varname = "flintstone" {
husband = "fred
wife = "wilma"
} # close of flintstone hash
varname = "rubble" {
husband = "barney"
wife = "betty"
} # close of rubble hash
} # close of family hash
} # close of Flinstone hash
varname = "Simpson" {
{ yadee, yadah, yadah }
} # close of TV show
When reading down, I want %{TV show} to contain the hash %{Flintstone},
%{Simpson}, and so on. If Barney from Simpson gets married, I can't have
2 barney's in the same name table so I create a separate a name table for
each hash level. This is how I first did it. I'm sure there is a cleaner
way to do it using perlob, but I haven't gotten around to revisit it. Perhaps
the original poster runs into the same situation?
Dzuy
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 14 Aug 1998 23:14:13 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: retrieving hash name
Message-Id: <6r2gc5$cfh$2@marina.cinenet.net>
dnguyen@dejanews.com wrote:
: I can think of a scenario when I would create the name of the hash on
: the fly. Suppose I need to parse the following file:
:
: varname = "TV show" {
: varname = "Flintstone" {
: varname = "family" {
: othervar = "other stuff"
: varname = "flintstone" {
: husband = "fred
: wife = "wilma"
: } # close of flintstone hash
So you create a hash of hashes of hashes and so forth, so that e.g.
$stuff{'TV show'}{'Flintstone'}{'family'}{'othervar'} is 'other stuff',
$stuff{'TV show'}{'Flintstone'}{'family'}{'flintstone'}{'husband'}
is 'fred',
and so forth. No need to 'name' the internal hashes other than as keys in
the next higher hashes, with hash references as their values.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Fri, 14 Aug 1998 17:55:52 -0400
From: John Porter <jdporter@min.net>
Subject: Re: RFA: searching for binary pattern in binary file via regex
Message-Id: <35D4B268.5EA9@min.net>
Steve McNabb wrote:
>
> I have one binary file, and I want to search that file for a large pattern
> (actually, it's a whole other binary file -- a trojan horse that some of you
> 1) convert both files to hex to simplify processing
> 2) write a system that will take a chunk out of the middle of Boserv.exe
> (the trojan) and scan the suspect hex-converted binary file for said
> pattern. If this pattern is found, the file gets marked "suspicious"
1. You don't need to convert to hex. Perl's strings are 8-bit clean.
That is, a string in perl is just a length-known byte buffer.
2. use the index() function to find one string inside another. Voila.
--
John Porter
------------------------------
Date: Fri, 14 Aug 1998 21:05:12 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: testing if file exists
Message-Id: <Pine.GSO.4.02.9808141403050.10161-100000@user2.teleport.com>
On Fri, 14 Aug 1998, Daniel Adams wrote:
> As part of a larger perl script, I am trying to write a subroutine which
> conducts an "if, then, else" statement on whether a file exists.
Sounds like you want the -e filetest, documented in perlfunc.
> i.e. in plain language: "If file foobar.htm exists then goto subroutine
> 'exist' else goto subroutine 'notthere'.
Don't say 'goto'. That's a four-letter word. :-) Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 14 Aug 1998 21:23:40 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: testing if file exists
Message-Id: <Exp7FG.Dv6@world.std.com>
"Daniel Adams" <dan@fearsome.net> writes:
>The bit I am stuck on is the "foobar.htm exists" part, the rest I can do,
>the if/then statements etc -but how do I write "if foobar.htm exists" in
>Perl?
You might want to look at the -X tests in the perlfunc man
page. The "-e" (exists) one might do what you want.
if(-e '/disk1/usr/public_html/foobar.htm') {
# do something
}
else {
# do something else
}
The perlfunc man page is probably one of the first places to look when
you want to find the answer to the question "Does perl have a function
to do ..."
If you are writing HTML files into a servers hierarchy at a time where
concurrent access is a possibility, then your "test if a file exists
and if so do this, if not, do that" algorithm may not be the best
idea. You want something that is "atomic" (a single inseparable
action)
--
Andrew Langmead
------------------------------
Date: Fri, 14 Aug 1998 16:29:28 -0500
From: Grant Griffin <grant.griffin@nospam.com>
Subject: Re: timeout or time limiting function
Message-Id: <35D4AC38.2F904263@nospam.com>
Tom Christiansen wrote:
> *WHY* do people come here before grepping in their own documentation?
> Surely they can't *ALL* be brain-demolished Prisoners of the Evil Empire,
> can they? :-(
Just when are these newbies ever gonna learn?
(How about providing a URL next time?)
=g2
------------------------------
Date: Fri, 14 Aug 1998 21:53:58 GMT
From: roguemouse@yahoo.com
Subject: Using Perl module without access to Perl installation
Message-Id: <6r2bll$s1d$1@nnrp1.dejanews.com>
My ISP has Perl installed for use by the ISP's customers.
I want to use a particular Perl module from CPAN which is not not part of the
ISP's Perl installation.
Since my ISP will not allow me to modify their Perl installation, how do I
use the desired Perl module without having to build and install my own
private Perl installation?
Thanks.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 3450
**************************************