[16203] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3615 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 10 21:05:28 2000

Date: Mon, 10 Jul 2000 18:05:16 -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: <963277515-v9-i3615@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 10 Jul 2000     Volume: 9 Number: 3615

Today's topics:
    Re: <newbie>How to determine current location (pwd) in  <peter.sundstrom@eds.com>
        Blat for Win32/Perl <bbgraph@scioto.net>
    Re: Convert integers to strings (lenght) (Abigail)
    Re: Convert integers to strings (Abigail)
    Re: Dealing with #!/crazy/location/perl (Abigail)
        Faster way to do it... sept00@my-deja.com
    Re: Form Processing in NT (David Efflandt)
    Re: Getting a unique machine ID on win32? <thierry.metoudi@netcourrier.com>
    Re: Hash vs. Array memory usage <webmaster@archiTacTic.com>
    Re: Hash vs. Array memory usage <lr@hpl.hp.com>
    Re: Hash vs. Array memory usage (Abigail)
    Re: Hash vs. Array memory usage (Abigail)
    Re: Help with converting part of a page to CGI <russ_jones@rac.ray.com>
        How to display the correct time from a time server on a <Ryin@mailmenot.com>
    Re: How to display the correct time from a time server  greg@apple2.com.invalid
        Language Challenge -- Results <bvoh@sdynamix.com>
    Re: need post/lwp example (Malcolm Dew-Jones)
    Re: need post/lwp example (Malcolm Dew-Jones)
        Newbie in need of 2 scripts... <ecco64@chello.nl>
    Re: OLE and excel <bwalton@rochester.rr.com>
    Re: OLE and excel <matt.stoker@motorola.com>
        Perl piping on NT rsivak@my-deja.com
    Re: Perl piping on NT (Malcolm Dew-Jones)
    Re: print command not found <bwalton@rochester.rr.com>
    Re: print command not found (Tad McClellan)
    Re: print command not found (Malcolm Dew-Jones)
    Re: print command not found <tgederbe@ems.jsc.nasa.gov>
    Re: Redirect messages to a file martinru@my-deja.com
    Re: Redirect messages to a file <nnickee@nnickee.com>
    Re: running system command as root from perl kmhanser@my-deja.com
        Shuffling an array <mouimet@direct.ca>
    Re: Simple Question - Hash and foo.. <russ_jones@rac.ray.com>
    Re: split NONSENSE <kj0@mailcity.com>
    Re: split NONSENSE (Abigail)
    Re: String length? (Abigail)
    Re: String length? (John Stanley)
    Re: String length? <russ_jones@rac.ray.com>
        this newsgroup <reui@fdd.ff>
    Re: this newsgroup (Tad McClellan)
        warning??  <marc@netcontinuum.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 11 Jul 2000 11:00:44 +1200
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: <newbie>How to determine current location (pwd) in CGIscript?</newbie>
Message-Id: <8kdkko$f4m$1@hermes.nz.eds.com>


colinr wrote in message ...
>Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote in message
>news:slrn8m6gan.iha.bernard.el-hagin@gdndev25.lido-tech...
>> On Wed, 5 Jul 2000 07:02:52 -0700, colinr <colinrei@oz.net> wrote:
>> >Thanks.
>>
>> You're welcome.
>>
>> >btw, why is it called "jeopardy quoting"?
>>
>> If you give an answer first and later quote the question you're doing
>> the Alex Trebeck thang which is only welcome on the game show "Jeopardy".
>> On newsgroups it's very annoying.
>>
>> Bernard
>> --
>> perl -e '${qq=\x22=}=qq=\053=;$_="BeJUST_ANOTHERnaPERL_HACKERd\n";
>> ${qq=\x2c=}=qq=\x72=;print split /[AC-Z_]$"/;'
>
>I think it's the fault of the lame newsreader app I'm using... (M$
OutofLuck
>Express)
>Sorry.  And thanks for the etiquette tip...


One more etiquette tip is not quoting sigs.




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

Date: Tue, 11 Jul 2000 01:15:32 GMT
From: "Bob" <bbgraph@scioto.net>
Subject: Blat for Win32/Perl
Message-Id: <Uyua5.501$tC2.4855@news>

I have installed blat 1.85 on Win32/IIS4...the box has a dns entry with a
fixed ip and is currently running third-party email server software. I'd
like to know how enable blat to send mail to users from an EveryAuction
sample site I have running. The auction code runs fine but I am absolutely
stumped as to how to get the perl code to use blat (or the mailhost
software, for that matter) to send registration replies to the users. I'm
hoping to provide this as a free site for the local community.

The perl code that makes the call:

# $config{'mailprog'} = '/usr/lib/sendmail -t';

or

# $config{'mailhost'} = 'localhost';

I've tried $config{'mailprog'} = 'c:/winnt/system32/blat'; and
$config{'mailhost'} = '999.888.777.666:25'; (bogus ip for security's
sake...)

I have blat.exe installed in the cgi-bin dir and also tried it in the
\winnt\system32 dir...

Any help or pushing me in the right direction is sincerely appreciated.

Thanks

Bob






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

Date: 10 Jul 2000 20:45:14 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Convert integers to strings (lenght)
Message-Id: <slrn8mksi9.7v7.abigail@alexandra.delanet.com>

Mark Lardinois (lardinois@ose.nl) wrote on MMDV September MCMXCIII in
<URL:news:3969941e$0$1755@heracles>:
!! Hello,
!! 
!! Because I want to use Length()
!! I have to convert an integer to
!! a string. How can I do that?

I dunno. Perhaps you could write a C program that does atoi and itoa,
and call it with ``.


Abigail
-- 
perl  -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
          for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
          print chr 0x$& and q
          qq}*excess********}'


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

Date: 10 Jul 2000 20:43:46 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Convert integers to strings
Message-Id: <slrn8mksfi.7v7.abigail@alexandra.delanet.com>

Mark Lardinois (lardinois@ose.nl) wrote on MMDV September MCMXCIII in
<URL:news:39698d81$0$1748@heracles>:
 .. Hi,
 .. 
 .. Can someone tell me how to convert
 .. integers to strings. Is there something
 .. like IntToStr() or Str()?


No, but you can easily make then yourself.

    sub IntToStr {shift}

    sub StrToInt {$_ [0]}


HTH. HAND.



Abigail
-- 
perl  -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
          for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
          print chr 0x$& and q
          qq}*excess********}'


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

Date: 10 Jul 2000 20:49:06 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Dealing with #!/crazy/location/perl
Message-Id: <slrn8mkspi.7v7.abigail@alexandra.delanet.com>

kj0 (kj0@mailcity.com) wrote on MMDV September MCMXCIII in
<URL:news:8kb5lo$m14$1@panix3.panix.com>:
// 
// Whenever I transfer my perl scripts to a new system, I have to go
// through this stupid ritual of changing the hash-bang first-lines to
// the correct perl location for that site.  This is a pain, even when
// it's done with the aid of a script (which itself must be done "by
// hand").
// 
// The obvious solution would be to define an environment variable PERL
// containing Perl's location (something in the spirit of setenv PERL
// `which perl`), so that all scripts can start with #!$PERL [flags...].
// The only problem with this is that it doesn't work.
// 
// Is there a way?


The manual covers even this specific question. Within the first 100
lines of 'man perlrun', you find *several* solutions to your problem.



Abigail
-- 
perl -wlne '}for($.){print' file  # Count the number of lines.


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

Date: Tue, 11 Jul 2000 00:18:33 GMT
From: sept00@my-deja.com
Subject: Faster way to do it...
Message-Id: <8kdp4a$hfn$1@nnrp1.deja.com>

When trying to replace strings in a text file for later output, I need
to read in a file, transfer it into a string and let the regular
expressions run over it, right? But now I'm stumped: Because of Perl's
miraculous TMTOWTDI-approach, I don't know which of the following
method is faster:

	foreach (<$fh>) {
		s/BLAH1/$sub_text1/eg;
		s/BLAH2/$sub_text2/eg;
		s/BLAH3/$sub_text3/eg;
		s/BLAH4/$sub_text4/eg;
		s/BLAH5/$sub_text5/eg;
		print;
	}

OR this

	@text_list = <$fh>;
	$text_scalar = "@text_list";
	$text_scalar =~ s/BLAH1/$sub_text1/eg;
	$text_scalar =~ s/BLAH2/$sub_text2/eg;
	$text_scalar =~ s/BLAH3/$sub_text3/eg;
	$text_scalar =~ s/BLAH4/$sub_text4/eg;
	$text_scalar =~ s/BLAH5/$sub_text5/eg;
	print $text_scalar;

I'd appreciate all the info I could get on this, so thanks in advance!!

Tom


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 11 Jul 2000 01:02:45 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Form Processing in NT
Message-Id: <slrn8mksh5.lk.efflandt@efflandt.xnet.com>

On Mon, 10 Jul 2000, i-p-hosting.com @Admin <carl.heaton@i-p-hosting.com>
wrote:
>Can anyone help me with form processing in windows NT? all the scripts I try
>dont work... Anyone got any links to NT Form mail scripts?
>Thanx
>Carl

The problem in the past was that NT was not necessarily standardized as
far as an smtp server because one was not included with NT.  There is an
option included in Option Pack 4 called CDO that I have used to e-mail
data from ASP.  The first thing you need to do is find out what mail
service is available and whether your web host has a FAQ explaining how to
use it.

But I only have ftp and FrontPage access to the only NT site I maintain,
which was donated space on a company server, so I am clueless about NT and
don't even know how to check if the system has Perl or how to use it in
NT.  All my other sites are Unix where I have used the sendmail program. I
have used Perl Mail::Sendmail module on a system that had sendmail and
smtp disabled, but only to myself, since you need to know the mail server
of the destination if you don't have one locally.

-- 
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: Tue, 11 Jul 2000 01:04:20 +0200
From: TM <thierry.metoudi@netcourrier.com>
Subject: Re: Getting a unique machine ID on win32?
Message-Id: <396A5674.3C69FFC0@netcourrier.com>

Seriously now


Drew Simonis a écrit :

> TM wrote:
> >
> > Hello,
> >
> > I'm looking for a way of getting a machine's unique ID  (e.g. hard drive
> > number or a microprocessor ID).
> >
>
> An earlier thread discussed this same exact topic.  I recall the
> decided solution was to use a screwdriver.



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

Date: Tue, 11 Jul 2000 00:10:43 +0200
From: "nicolas" <webmaster@archiTacTic.com>
Subject: Re: Hash vs. Array memory usage
Message-Id: <3Tra5.15672$DL.66198@nnrp1.none.net>


Michael Carman <mjcarman@home.com> a écrit dans le message :
396A1828.D5CE08CA@home.com...
> when
> processing a file it is much more memory-friendly to parse it line by
> line instead of slurping the whole thing into memory first.
>
That's what I started doing, but I have to compare an Array to another
Array. In other words, I have an Array which I want to compare to a data
file to see if elements are already there. The only thing I found was to
"slurp" the whole database into a variable (the @MyBigVar array) and then
comparing my other array to it to eliminate doubles.
So if you tell me that an array is better for memory, I'll keep that.

Thanks for the info,
Nick




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

Date: Mon, 10 Jul 2000 17:07:35 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Hash vs. Array memory usage
Message-Id: <MPG.13d4051e67f9c08898abb2@nntp.hpl.hp.com>

[Removed alt.perl.]

In article <3Tra5.15672$DL.66198@nnrp1.none.net> on Tue, 11 Jul 2000 
00:10:43 +0200, nicolas <webmaster@archiTacTic.com> says...
> 
> Michael Carman <mjcarman@home.com> a écrit dans le message :
> 396A1828.D5CE08CA@home.com...
> > when
> > processing a file it is much more memory-friendly to parse it line by
> > line instead of slurping the whole thing into memory first.
> >
> That's what I started doing, but I have to compare an Array to another
> Array. In other words, I have an Array which I want to compare to a data
> file to see if elements are already there. The only thing I found was to
> "slurp" the whole database into a variable (the @MyBigVar array) and then
> comparing my other array to it to eliminate doubles.
> So if you tell me that an array is better for memory, I'll keep that.

Memory isn't the issue here.  Performance is the issue.

To see what to do, read perlfaq4: "How do I compute the difference of 
two arrays? How do I compute the intersection of two arrays?" and 
several nearby FAQs.  You will want to use a hash, because using an 
array leads to quadratic performance (i.e., very slow for large arrays).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 10 Jul 2000 20:54:07 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Hash vs. Array memory usage
Message-Id: <slrn8mkt2u.7v7.abigail@alexandra.delanet.com>

nicolas (webmaster@archiTacTic.com) wrote on MMDV September MCMXCIII in
<URL:news:0Zna5.15609$DL.65529@nnrp1.none.net>:
'' Is there a way to know the memory usage of a variable?

Not really. Studying the source of perl might give you an estimate, though.

'' I have some very large variables (flat lists) that can be put in an array
'' (@MyBigVar), or in a Hash (%MyBigVar) and would like to know the memory size
'' of each to decide which is better.

That is the strangest approach I've seen to solve a problem. Arrays and
hashes are two different datastructures. It's mainly your problem that will
decide which is better to use, an array or a hash. If the memory is too
big, you can always tie it and save it to file.



Abigail
-- 
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");


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

Date: 10 Jul 2000 20:59:28 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Hash vs. Array memory usage
Message-Id: <slrn8mktcv.7v7.abigail@alexandra.delanet.com>

nicolas (webmaster@archiTacTic.com) wrote on MMDV September MCMXCIII in
<URL:news:3Tra5.15672$DL.66198@nnrp1.none.net>:
() 
() Michael Carman <mjcarman@home.com> a écrit dans le message :
() 396A1828.D5CE08CA@home.com...
() > when
() > processing a file it is much more memory-friendly to parse it line by
() > line instead of slurping the whole thing into memory first.
() >
() That's what I started doing, but I have to compare an Array to another
() Array. In other words, I have an Array which I want to compare to a data
() file to see if elements are already there. The only thing I found was to
() "slurp" the whole database into a variable (the @MyBigVar array) and then
() comparing my other array to it to eliminate doubles.
() So if you tell me that an array is better for memory, I'll keep that.


NO, NO, NO!

Please read the FAQ and use the solutions presented there. Both your
array and your hash will use linear storage. When using arrays, your
algorithm will be quadratic. When using hashes, your algorithm will be
nearly linear.

Even if you have to use a roll of toiletpaper and a crayon as swap device,
for large enough lists, the linear solution will beat the quadratic one
by a few millenia.


As I said in my previous post, the nature of the problem at hand is far,
far, far, far, far, far, far more important to decide whether an array
or a hash is appropriate then the memory usuage. 


Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Mon, 10 Jul 2000 17:15:04 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: Help with converting part of a page to CGI
Message-Id: <396A4AE8.8A881698@rac.ray.com>

Ted wrote:
> 
> Makarand Kulkarni wrote:
> > I suggest you look at HTML::Mason
> 
> Thanks, but what exactly *is* HTML::Mason, anyway? 

It's like a 0th degree Mason. You get to pay dues, but they don't
teach you the handshake.
-- 
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747

Quae narravi, nullo modo negabo. - Catullus


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

Date: Mon, 10 Jul 2000 18:16:39 -0400
From: Ryin <Ryin@mailmenot.com>
Subject: How to display the correct time from a time server on a page?
Message-Id: <idikmsk36lfiip654a796atsb0sr2rgqco@4ax.com>

Have seen many javascript clocks get the time from users'
systems.  Is it possible to display a correct time from a
time server when a page is viewed?

Any input is welcome.  Live example is better.


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

Date: Mon, 10 Jul 2000 19:30:49 -0500
From: greg@apple2.com.invalid
Subject: Re: How to display the correct time from a time server on a page?
Message-Id: <greg-257E78.19304910072000@news.binary.net>

In article <idikmsk36lfiip654a796atsb0sr2rgqco@4ax.com>,
Ryin <Ryin@mailmenot.com> wrote:

> Have seen many javascript clocks get the time from users' 
> systems.  Is it possible to display a correct time from a 
> time server when a page is viewed?

Not using Javascript alone.  It will need to communicate with a web 
server which contacts the time server and returns the result to the 
script.  There will be additional delays due to the complexity of time 
retrieval.

And correct for whom?  The user?  The server?  Greenwich?

-- 
__  _____________  __
\ \_\ \__   __/ /_/ /        <http://www.war-of-the-worlds.org/>
 .\  __ \ | | / __  /----------------------------------------------------
^ \_\ \_\|_|/_/ /_/             Don't mail me, I'll mail you.


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

Date: Mon, 10 Jul 2000 15:39:22 -0700
From: bv <bvoh@sdynamix.com>
Subject: Language Challenge -- Results
Message-Id: <396A509A.361F72B5@sdynamix.com>


Language Challenge 2000 -- Results

Contest entries have been tabulated and you're invited to find out how
different languages fared. View the effortless solution of this
technical problem embodying a central theme of modern engineering and
scientific practice -- computer aided optimal design. 

We'd like to particularly encourage a visit by the younger generation
which probably never even saw a code without trailing semicolons, and to
those who are curious how to "roll your own" before purchasing expensive
optimization toolboxes.

To view the contest summary please click on the "Language Challenge
2000" on http://sdynamix.com



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

Date: 10 Jul 2000 15:46:28 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: need post/lwp example
Message-Id: <396a5244@news.victoria.tc.ca>

Bill Webster (billw@dal.asp.ti.com) wrote:
: Hello folks,

:    My goal is to fill out a form for a given URL which uses the POST
: method,
: without the use of a browser.  I understand using LWP is a good way to
: go.
: Looking through LWPCOOK, I found:

:         #!/usr/bin/perl
:          use LWP::UserAgent;
:          $ua = LWP::UserAgent->new;

:          my $req = HTTP::Request->new(POST =>
: 'http://www.perl.com/cgi-bin/BugGlimpse');
:          $req->content_type('application/x-www-form-urlencoded');
:          $req->content('match=www&errors=0');

:          my $res = $ua->request($req);
:          print $res->as_string;

:   ...well http://www.perl.com/cgi-bin/BugGlimpse no longer exists, so
: its hard for me to
: play with this example.  I would like an example program that will work,

: so I can make
: sure I'm starting at the right point to debug my program ( which I think

: my problems my name/value pairs...).

:   Can someone send me an example similar to the one above that will
: work?


I really think you should install your own web server to receive the POST
data for this sort of testing.  It's not very polite to be sending bogus
requests to someone elses server when you're developing routines.

You would have the added benefit of being able to check both ends of the
connection to see what's really happening.

Your URL would be something like
'http://localhost/cgi-bin/my_test_cgi.pl'

and my_test_cgi.pl could be as simple as (untested)

	#!/usr/bin/sh
	echo 'new request received' >> /tmp/my_test_cgi.log
	date >> /tmp/my_test_cgi.log
	cat  >> /tmp/my_test_cgi.log

This just dumps the incoming POST data into a log file (make sure its
writable by the cgi script running account) so you can examine it.  You
might also want to dump the environment variables.  I forget how, but
'printenv', or 'set' probably work.

Windows would be a bit different, but the idea is the same.  Find a
utility that copies its standard input into a file and run that as the cgi
script.  Perhaps its as easy as 'TYPE CON >> file 'in a batch file.



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

Date: 10 Jul 2000 15:52:24 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: need post/lwp example
Message-Id: <396a53a8@news.victoria.tc.ca>

Malcolm Dew-Jones (yf110@vtn1.victoria.tc.ca) wrote:
: Bill Webster (billw@dal.asp.ti.com) wrote:
: : Hello folks,

: Your URL would be something like
: 'http://localhost/cgi-bin/my_test_cgi.pl'

 my example turned out to be a shell script, so don't be confused by the
 .pl file type, which turned out to be misleading.



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

Date: Tue, 11 Jul 2000 00:15:14 GMT
From: "Ecco" <ecco64@chello.nl>
Subject: Newbie in need of 2 scripts...
Message-Id: <mGta5.336147$k22.1498857@flipper>

I'm looking for two perl-scripts:
1. A script to enable multiple files to download at the same time.
2. A script that pop-ups a new browser-windows.

If anyone has any ideas... The second one shouldn't be that much of a
problem, but I doubt the first one is even possible...




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

Date: Mon, 10 Jul 2000 22:42:23 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: OLE and excel
Message-Id: <396A51B4.D3F1DFF5@rochester.rr.com>

Jon Marshall wrote:
> 
> Having a slight problem with perl and OLE.  After creating a spreadsheet
> with columns and saving it, if you then re-open it how can you re-read a
> columns worth of data without knowing how many cells you have filled in
> that column ie.  i have populated a column with 20 items - how can i
> retrieve these items without knowing the range.
> ( i could keep a record in the top cell of each column with how many
> items the column has in it but this seems very kludgy ).
 ...
> Jon Marshall

Check out Excel's CurrentRegion property.  And next time, ask Excel
questions in an Excel newsgroup.
-- 
Bob Walton


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

Date: Mon, 10 Jul 2000 15:57:51 -0700
From: Matthew Stoker <matt.stoker@motorola.com>
Subject: Re: OLE and excel
Message-Id: <396A54EF.B1751123@motorola.com>

Jon Marshall wrote:
> 
> Having a slight problem with perl and OLE.  After creating a spreadsheet
> with columns and saving it, if you then re-open it how can you re-read a
> columns worth of data without knowing how many cells you have filled in
> that column ie.  i have populated a column with 20 items - how can i
> retrieve these items without knowing the range.
> ( i could keep a record in the top cell of each column with how many
> items the column has in it but this seems very kludgy ).
> 
> I've figured out how to do most of the things i want from using the
> Visual basic editor in excel but no matter what i try for this i can't
> seem to work it out.
> 
> Any help would be much appreciated
> 
> Jon Marshall

I'm not sure if this will help and it's probably quite kludgy as well,
but in VBA you can use:

row_num = Range("C1").End(xlDown).Row

To get the number of the last row in a series of cells in a column.
Beware, however, that if your data contains blank cells in the column,
the above statement will return the last cell in the first continuous
set of data.  For example if column c contains:

25 <- row 1
36 <- row 2
48 <- row 3
   <-blank row
18 <- row 5
19 <- row 6
45 <- row 7

Then row_num = 3, since row 3 contains the last non-blank cell in the
series.  Perhaps a safer way to find the last occupied cell in a column
is with:

row_num = Range("C65536").End(xlUp).Row

This will return the row number of the last non-blank cell in the
column, unless row 65536 contains data, in which case it will give the
wrong answer, but you can test for that.

I'm just learning the win32::OLE interface, so I'm not sure of the perl
syntax. It should be something like:

$row_num = Range("C65536)->End(xlUp)->Row

I hope this helps!




-- 
/------------------------------------------------------------------\
| Matt Stoker                |     email: matt.stoker@motorola.com |
| Unit Process Modeling      | Mail Drop: M360                     |
| DigitalDNA(TM) Laboratories|     Phone: (480)655-3301            |
| Motorola, SPS              |       Fax: (480)655-5013            |
| 2200 W Broadway Road       |     Pager: (888)699-8803            |
| Mesa, AZ 85202             |                                     |
\------------------------------------------------------------------/


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

Date: Mon, 10 Jul 2000 22:01:18 GMT
From: rsivak@my-deja.com
Subject: Perl piping on NT
Message-Id: <8kdh3f$adb$1@nnrp2.deja.com>

Hi everyone,

I'm trying to pipe on nt to a file such as

program.pl >text.txt

this doesn't work.  However doing

perl program.pl > text.txt

does work.  However, I need to execute a perl
script from another program (Allaire ColdFusion),
which has problems doing the latter.

I have even tried pl2exe to convert it the script
to an exe file, which still didn't help(it still
doesn't pipe).  Is there a way to get it to
work?

Russ


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 10 Jul 2000 15:54:21 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Perl piping on NT
Message-Id: <396a541d@news.victoria.tc.ca>

rsivak@my-deja.com wrote:
: Hi everyone,

: I'm trying to pipe on nt to a file such as

: program.pl >text.txt

: this doesn't work.  However doing

Trying embedding the perl script in a batch file, and running the batch
file instead of the perl script.  NT allows batch files to pipe correctly
(as opposed to regular DOS).



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

Date: Mon, 10 Jul 2000 22:34:31 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: print command not found
Message-Id: <396A4FDD.59AFB8CF@rochester.rr.com>

Cheeby wrote:
 ...
> #!/usr/bin/perl
> 
> print "What is your name?";
> $name = <STDIN>;
> chomp ($name);
> print "Well, hello, $name!\n";
> 
> I've saved it as sample.pl, made it executable with chmod +x and when I run
> it I get
> 
> ./sample.pl: print: command not found
> ./sample.pl: line 6: syntax error near unexpected token ';'
> ./sample.pl: line 6: '$name = <STDIN>;'
> 
> I've got Perl 5, and it does reside in /usr/bin/perl
> 
> Any advice?  Thanks,
> 
> Cheeby

It looks to me like Linux is attempting to execute your program as a
shell script.  Check to make sure that the very first two characters of
your Perl program file are:

#!

That has to go on the very first line, and there can't be any spaces,
tabs, etc in front of it.
-- 
Bob Walton


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

Date: Mon, 10 Jul 2000 17:49:52 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: print command not found
Message-Id: <slrn8mkh80.1qr.tadmc@magna.metronet.com>

On Mon, 10 Jul 2000 16:56:03 -0500, Cheeby <sfox@earthlighttechnologies.com> wrote:

>I'm running through the O'Reilly book, Learning Perl and am stuck on the
>Hello, World example...


>./sample.pl: print: command not found
>./sample.pl: line 6: syntax error near unexpected token ';'
>./sample.pl: line 6: '$name = <STDIN>;'

>Any advice?  Thanks,


Yes. Look up the message and see what it says.


All of the messages that perl might issue (and even some issued
by other programs, which is what you're getting above, I think)
are documented in the perldiag.pod standard doc.

   perldoc perldiag

----------------------------
=item %s: Command not found

(A) You've accidentally run your script through B<csh> instead
of Perl.  Check the #! line, or manually feed your script into
Perl yourself.
----------------------------

If it works when invoked this way:

   /usr/bin/perl myprog

then you have some problem with your shebang line.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 10 Jul 2000 15:48:19 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: print command not found
Message-Id: <396a52b3@news.victoria.tc.ca>

Cheeby (sfox@earthlighttechnologies.com) wrote:
: I'm running through the O'Reilly book, Learning Perl and am stuck on the
: Hello, World example...

: (on SuSE 6.4)

: #!/usr/bin/perl

: print "What is your name?";
: $name = <STDIN>;
: chomp ($name);
: print "Well, hello, $name!\n";

: I've saved it as sample.pl, made it executable with chmod +x and when I run
: it I get

: ./sample.pl: print: command not found
: ./sample.pl: line 6: syntax error near unexpected token ';'
: ./sample.pl: line 6: '$name = <STDIN>;'

: I've got Perl 5, and it does reside in /usr/bin/perl

: Any advice?  Thanks,

Does it work if you type

	/usr/bin/perl  your-file.pl

on the command line?



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

Date: Mon, 10 Jul 2000 22:47:27 GMT
From: Tom Gederberg <tgederbe@ems.jsc.nasa.gov>
Subject: Re: print command not found
Message-Id: <8kdjpq$dhb$1@nnrp1.deja.com>


>I've saved it as sample.pl, made it executable with chmod +x and when
I run

Try typing:
perl sample.pl
and see if it works.

What version of UNIX are you using?  Some old UNIX systems do not
support the #! (shebang) notation.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 10 Jul 2000 23:29:09 GMT
From: martinru@my-deja.com
Subject: Re: Redirect messages to a file
Message-Id: <8kdm7i$fai$1@nnrp1.deja.com>

In article
<AD4BACD1ADB58864.D967D8768BC94A17.0E3891AFA8CD2F51@lp.airnews.net>,
  nnickee@nnickee.com wrote:
> On Mon, 10 Jul 2000 10:53:44 GMT, someone claiming to be
> martinru@my-deja.com said:
>
> >I tried redirecting to a file as you've illustrated above, but the
> >messages still scroll up the screen, and the file that is created
> >is empty. Any more ideas? -Thanks
>
> #!perl -s -w
>
> my $output = 'error.log';
>
> if ($ARGV[1]) {
> 	$output = $ARGV[1];
> }
>
> if (!$ARGV[0]) {
> 	print <<"EndOfThisBlock";
>
> Usage:
>
> perl err.pl file.pl output.file
>
> Where file.pl is the perl script you wish to test for errors, and
> output.txt is where the errors will be sent to.
>
> If no output file is given, error.log will be used.
> EndOfThisBlock
> 	exit;
> }
>
> open STDERR, ">$output" or die "Redirect didn't work! $!";
>
> $script = $ARGV[0];
> chomp($script);
>
> $torun = "perl -c " . $script;
> system ($torun);
>
> open(TEST, $output) or die "Can't open error file $!";
> $status = <TEST>;
> close(TEST);
>
> if ($status =~ m/syntax OK/) {
> 	print "No apparent problems with the script.\n";
> }
> else {
> 	print "He's dead, Jim....\n";
> }
>
>

Thank you all for the replies. I saved the above perl code as err.pl and
then used it just as it says... and it works GREAT!  Now I can see
easily see all my error messages in a file instead of watching them
scroll off the screen.  Thank you VERY much!



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 10 Jul 2000 19:31:38 -0500
From: Nnickee <nnickee@nnickee.com>
Subject: Re: Redirect messages to a file
Message-Id: <CFA15468B24F1538.98E93F5BAE51CEF1.DD054D8EEECBAE3A@lp.airnews.net>

On Mon, 10 Jul 2000 23:29:09 GMT, someone claiming to be
martinru@my-deja.com said:

<snipped my err.pl>

>Thank you all for the replies. I saved the above perl code as err.pl and
>then used it just as it says... and it works GREAT!  Now I can see
>easily see all my error messages in a file instead of watching them
>scroll off the screen.  Thank you VERY much!

You are VERY welcome :)
I'm glad that it's helpful to you.

Nnickee



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

Date: Mon, 10 Jul 2000 22:08:27 GMT
From: kmhanser@my-deja.com
Subject: Re: running system command as root from perl
Message-Id: <8kdhge$bpp$1@nnrp1.deja.com>

Yeah, I had thought of having a cron running and checking for a file...
you mention that restarting the server is different than reloading the
conf file... I haven't been able to find in apache's dox/man pages how
to make this happen w/out stopping and restarting the server.  How can
I get it to reload the conf w/out a restart?

Also, I'd be interested to hear your security concerns.  I'm always
interested in what sort of holes I'm opening up :)

As for the cron, that may be what I end up doing, I just thought there
was a way I could su and restart the server/reload the config with the
press of a button on a web form.  Would be a neat trick.  Regardless of
if I use it for this or not, it still would be handy to know how to run
a command as root...

Thanx

In article <brian-ya02408000R1007001548130001@news.panix.com>,
  brian@smithrenaud.com (brian d foy) wrote:
> In article <8kd6l8$3ad$1@nnrp1.deja.com>, kmhanser@my-deja.com posted:
>
> > I'd like to put a button on the page that
> > restarts the server when pressed, so the changes can be activated
from
> > the page as well.
> > What's the best way to do this?
>
> the best way?  don't use the web.
>
> however...
>
> i'd be tempted to have the CGI script create a file that signals
> another process (cron job? daemon?) that the server needs to reload
> the conf file (which is different than restarting the server)
>
> > Like I said, this is from a web page that is only accessible from
our
> > internal network, so it's not quite as big of a security risk as it
> > might seem...
>
> it's worse, actually.
>
> --
> brian d foy
> CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
> Perl Mongers <URL:http://www.perl.org/>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 10 Jul 2000 22:39:07 GMT
From: "Marcus Ouimet" <mouimet@direct.ca>
Subject: Shuffling an array
Message-Id: <fgsa5.102456$Do1.1116067@news1.rdc1.bc.home.com>

I have been trying to shuffle an array for a while, I have read all the
faq's etc. And this is where I am. I want to shuffle my array and display
multiple items at a time not just one. ie if someone searchs for a city it
brings up all the members in a random order. If someone could take a look at
what I am doing, and give me some directions or help it would be most
appreciated, thanks - here is is:

} elsif($in{cmd} eq "search") {
 $in{title} = "Search results";
 $in{body} = "<FONT SIZE='+2'>Search results</FONT><br>\n\n<UL>\n";
 open(SERVICELIST, "ls $servicesfolder |");
 @servicelist = <SERVICELIST>;
 @servicelist = sort(@servicelist);
 $y = 0;
 foreach $service (@servicelist) {
  chomp($service);
  if( ($in{service} eq "NS")||($in{service} eq "")||($in{service} eq
$service) ) {
   $servicechunk = "";
   $servicename = $service;
   $servicename =~ s/_/ /g;
   $servicechunk .= "<LI><FONT SIZE='+1'>$servicename</FONT>\n<UL>\n";
   open(USERLIST, "ls $servicesfolder/$service |");

    srand(time ^ $$);
   @userlist = <USERLIST>;
   $userlist = rand(@userlist);

   $x = 0;
   foreach $user (@userlist) {
    chomp($user);
    $infofilestring =
FileToString("$servicesfolder/$service/$user/$infofilename");
    $infofilestring =~ s/\n|\s+|\t/ /g;
    $name = Extract('name',$infofilestring);
    #$company = Extract('company',$infofilestring);
    $city = Extract('city',$infofilestring);
    $state = Extract('state',$infofilestring);
    $country = Extract('country',$infofilestring);
    $statename = $statestring{$state};
    if( (($in{city} eq "") || ($city =~ /$in{city}/i)) &&
     (($in{country} eq "NS") || ($country =~ /$in{country}/i)) &&
     (($in{state} eq "") || ($in{state} eq "NS") || ($in{state} eq
$state)) ) {
     $x++;
print "Content-type: text/html\n\n";
print $userlist[$userlist];
     $servicechunk .= "$name";
    }
   }
   $servicechunk .= "</UL>\n<BR>\n";
   if($x != 0) {
    $y++;
    $in{body} .= $servicechunk;
   }
  }
 }
 if($y == 0) {
  $in{body} .= "<LI>We are currently expanding the service in this city. To
contact an expert in this area <a href='listings.cgi?cmd=nouser'>click
here</a> and somebody will reply promptly.\n";
 }
 $in{body} .= "</UL>\n";




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

Date: Mon, 10 Jul 2000 18:01:59 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: Simple Question - Hash and foo..
Message-Id: <396A55E7.CF1F3758@rac.ray.com>

B Kemp wrote:
> 

> >( foobar is a "programming" thing, not a "Perl programming" thing )
> 
> I don't know when I first saw it but it came back to haunt me on AIX help
> and a C book.

It dates at least to World War II, where it was FUBAR, or Screwed Up
Beyond All Recognition.

-- 
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747

Quae narravi, nullo modo negabo. - Catullus


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

Date: 10 Jul 2000 20:04:30 -0400
From: kj0 <kj0@mailcity.com>
Subject: Re: split NONSENSE
Message-Id: <8kdoae$hsr$1@panix3.panix.com>

In <m1vgydzrga.fsf@halfdome.holdit.com> merlyn@stonehenge.com (Randal L. Schwartz) writes:

>>>>>> "kj0" == kj0  <kj0@mailcity.com> writes:

>kj0> How can I get the right behavior, i.e.

>By reading the manual. :)

DOH!

I hate it when that happens...

Thanks,

<TINY>kj</TINY>,


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

Date: 10 Jul 2000 20:29:49 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: split NONSENSE
Message-Id: <slrn8mkrld.7v7.abigail@alexandra.delanet.com>

kj0 (kj0@mailcity.com) wrote on MMDV September MCMXCIII in
<URL:news:8kd9oh$9ct$1@panix3.panix.com>:
$$ 
$$ 
$$ 
$$ 
$$ Consider the following Absurd Perl Behavior:
$$ 
$$     main::(-e:1):   1
$$       DB<1> x (split /:/, ":a")
$$     0  ''
$$     1  'a'
$$ (ok)
$$ 
$$       DB<2> x (split /:/, "a:")
$$     0  'a'
$$ (huh?)
$$ 
$$       DB<3> x (split /:/, ":")
$$       empty array
$$ (WHAT?!?)

You haven't bothered reading the man page, have you?

$$ How can I get the right behavior, i.e.
$$ 
$$       DB<?> x (split /:/, ":")
$$     0  ''
$$     1  ''

qed.


Abigail
-- 
sub A::TIESCALAR{bless\my$x=>A};package B;@q[0..3]=qw/Hacker Perl
Another Just/;use overload'""'=>sub{pop @q};sub A::FETCH{bless\my
$y=>B}; tie my $shoe => qq 'A';print "$shoe $shoe $shoe $shoe\n";


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

Date: 10 Jul 2000 19:33:39 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: String length?
Message-Id: <slrn8mkoc1.7v7.abigail@alexandra.delanet.com>

Merijn Broeren (merijnb@iloquent.nl) wrote on MMDV September MCMXCIII in
<URL:news:8kc9me$1q1$1@brugman.iloquent.nl>:
:) 
:) sub this_takes_the_cake {
:) 	my $str = shift;
:) 	my $length_not_found = 1;
:) 	my $try;
:) 	while ($length_not_found) {
:) 		# Shirley defined somewhere:)
:) 		$try = rand($perls_biggest_integer);
:) 		my $try_str = $str;
:) 		for ($i = 1; $i <= $try; $i++) {
:) 			chop $try_str;
:) 			next if $try_str;
:) 			$length_not_found = 0 if $i == $try;
:) 			last;
:) 		}
:) 	}
:) 	$try;
:) }
:) 
:) Nicely non-deterministic. 


    sub optimized_for_long_unicode_strings {
        local $_ = shift;
        my $l    = 0x7FFFFFFFFFFFFFFF;   # Assume 64 bit integers.
      TADA:
        my $s    = ("(" . join ("|" => map {quotemeta chr} 0 .. 0xFFFF) .
                    ")") x $l;
        return $#+ if /^$s\z/;
        $l --;
        goto TADA
    }


Abigail
-- 
               split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_)  {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};


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

Date: 10 Jul 2000 23:50:55 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: String length?
Message-Id: <8kdngv$9fo$1@news.NERO.NET>

In article <396a2ddb@news.victoria.tc.ca>,
Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote:
>: # get the length of a string, assuming its less than 70 characters long
>: # and has no line feeds, CRs, etc, in it

$string = 'a test string';
$me=$ENV{'USER'};

$now = `mail | head -1`;
$now = $1 if /: (\d+) message/;

@arry = split( //, $string );
foreach $i (@arry) {
	`echo $i | mail $me`;
} 

$then = `mail | head -1`;
$then = $1 if /: (\d+) message/;

print "length = ", $then-$now, "\n";




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

Date: Mon, 10 Jul 2000 18:40:43 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: String length?
Message-Id: <396A5EFB.3A3B2FF2@rac.ray.com>

Malcolm Dew-Jones wrote:
> 
> # get the length of a string, assuming its less than 70 characters long
> # and has no line feeds, CRs, etc, in it
> 
> sub get_length
> {  my $str = shift;
>    print '
> 123456789 123456789 123456789 123456789 123456789 123456789 123456789
> ';
>    print "$str\n";
>    print "Please enter the length of the string: ";
> 
>    $length = <STDIN>;
>    return $length;
> }

I know this one works, I actually tested it.

#!/opt/perl5/bin/perl -w
use strict;
use IO::File;
use POSIX qw(tmpnam);

my $len = strlen("1234567890");
print "Length is $len\n";
exit(0);

sub strlen
{
  my $str = shift;
  my ($fh,$fname);
  do { $fname = tmpnam() }
        until $fh = IO::File->new($fname, O_WRONLY|O_CREAT|O_EXCL);
  print $fh $str;
  $fh->close;
  my $len = (stat($fname))[7];
  unlink $fh; 
  return $len;
}
  


-- 
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747

Quae narravi, nullo modo negabo. - Catullus


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

Date: Tue, 11 Jul 2000 01:24:06 +0200
From: "Day" <reui@fdd.ff>
Subject: this newsgroup
Message-Id: <8kdm15$iho$9@sunce.iskon.hr>

Hi

What for exactly is this news group?





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

Date: Mon, 10 Jul 2000 19:20:30 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: this newsgroup
Message-Id: <slrn8mkmhu.20f.tadmc@magna.metronet.com>

On Tue, 11 Jul 2000 01:24:06 +0200, Day <reui@fdd.ff> wrote:

>
>What for exactly is this news group?


comp

   this is a forum about computers

comp.lang

   this is a forum about computer languages

comp.lang.perl

   this is a forum about the Perl computer language

comp.lang.perl.misc

   this is a forum for things relating to the Perl computer 
   language that do not fit into any of the other comp.lang.perl.*
   groups.


If you have a question that fits with that, and you have spent
at least 5 minutes searching the standard docs that came with
your perl but still cannot find the answer, then post your
Perl question here.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 10 Jul 2000 17:12:54 -0700
From: Marc Holder <marc@netcontinuum.com>
Subject: warning?? 
Message-Id: <396A6686.743B2702@netcontinuum.com>

Does anybody know what the warning:

print (...) interpreted as function at xasm.pl line 157.

Is refering to when I run a perl script with the -w argument?

for the line
exists ($opcode{$op})            or  print ("WRN<MAIN-parse1.$ln> opcode

\`$op\' undefined => statement ignored\n"), next;






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

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


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