[13805] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1215 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 29 00:11:16 1999

Date: Thu, 28 Oct 1999 21:11:00 -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: <941170260-v9-i1215@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 28 Oct 1999     Volume: 9 Number: 1215

Today's topics:
    Re: Forcing a submit <cassell@mail.cor.epa.gov>
    Re: How di I join a string together? (Tad McClellan)
    Re: How di I join a string together? <gellyfish@gellyfish.com>
    Re: How di I join a string together? <uri@sysarch.com>
    Re: How di I join a string together? <jon@midnightbeach.com>
    Re: How parse a,b,"x,y",c (Tad McClellan)
    Re: How to compare files in different directories ? <cassell@mail.cor.epa.gov>
    Re: How to convert a a single char (from a string) to a <partha@urbana.css.mot.com>
    Re: How to convert a a single char (from a string) to a <sariq@texas.net>
    Re: How to convert a a single char (from a string) to a <gellyfish@gellyfish.com>
    Re: How to pick a random item from an array? (Thomas Wasell)
    Re: How to read from Game Port in Win32 dawgeatdawg@my-deja.com
    Re: how to reformat a multiline string <lr@hpl.hp.com>
    Re: How to round a number? <skilchen@swissonline.ch>
    Re: How to Trap DBI Errors (Jeff Givens)
        How to use Perlscript from Visual Basic for Application <ter@my-deja.com>
    Re: HTML Table to Array? <gellyfish@gellyfish.com>
    Re: HTML Table to Array? <cassell@mail.cor.epa.gov>
        I'm a bit lost with this LWP problem (Bill Moseley)
    Re: Installing perl for apache on winnt !! <sjohns17@uic.edu>
    Re: Installing perl for apache on winnt !! <gellyfish@gellyfish.com>
        ioctl() on /dev/tty <mbacchi@together.net>
    Re: ioctl() on /dev/tty (Sam Holden)
    Re: Is this a bug? <blakem@world.std.com>
    Re: Just to get rid of dos prompt window. <cassell@mail.cor.epa.gov>
    Re: length (number of items) of an array <emschwar@rmi.net>
    Re: length (number of items) of an array (Philip 'Yes, that's my address' Newton)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 28 Oct 1999 16:25:46 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Forcing a submit
Message-Id: <3818DB7A.5B7F873F@mail.cor.epa.gov>

brsuresh@my-deja.com wrote:
> 
> I need to get a webpage form, change the ACTION attribute of the FORM
> tag to my webserver and force a SUBMIT ACTION. Can some one tell me how
> to force the SUBMIT ?

I don't know if you'll get a helpful response here.  But, even
if your program is written in Perl, this is really a CGI problem
instead of a Perl problem.  Trust me.  Why would I lie to you?
So you'll get a better answer if you post this question in
comp.infosystems.www.authoring.cgi instead.  And that way, if
you get an answer you'll know from the thread in that newsgroup
whether it is a *correct* answer as well.

Good luck,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 28 Oct 1999 10:16:03 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How di I join a string together?
Message-Id: <3rl9v7.evg.ln@magna.metronet.com>

Steven Filipowicz (steven@*REMOVE*filipowicz.com) wrote:

: Subject: How di I join a string together?
                    ^^^^

   Uhh,...


      perldoc -f join


: Any help would be welcome.
: Thanks!


   Uh huh.


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


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

Date: 28 Oct 1999 20:57:22 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How di I join a string together?
Message-Id: <7vadbi$10u$1@gellyfish.btinternet.com>

On Thu, 28 Oct 1999 14:25:02 GMT Clinton Pierce wrote:
> 
> On Thu, 28 Oct 1999 15:52:24 +0200, Steven Filipowicz
> <steven@*REMOVE*filipowicz.com> wrote:
>>$FORM{'domain1'} = hello
>>$FORM{'domain2'} = bye
>>
>>Now I want to join 'hello' and 'bye' together and put them in $hostname.
>>Like hostname = 'hello' + 'bye'
> 
> ETOOMUCHJAVASCRIPT
> 
> The concatenation operator in Perl is ".", not "+".  
> 
> $hostname=$FORM{domain1} . $FORM{domain2};
> 
> or, simply use them together in a double-quoted string:
> 
> $hostname="$FORM{domain1}$FORM{domain2}";
> 

Purleeze Clint - thats just sooo lame :

#!/usr/bin/perl -w

use strict;

my $var1 = "eelackaneekee";
my $var2 = "vastandbulbous";

my $string = jjoin(' ',$var1,$var2);

print $string,"\n";

sub jjoin
{

  my ($join_string,@strings) = @_;

  my @out;

  foreach (@strings)
   {
     my $index;
     for $index ( 0 .. length ($_) - 1)
       {
         push @out,substr $_,$index,1;
       }
     push @out,$join_string;
   }
  
  my $out_string = '';

  my $index = 0;

  foreach (@out)
    {
      substr($out_string,$index++,1) = $_;
    }

  $out_string =~ s/\Q$join_string\E$//;

  return $out_string;
}

;-}

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: 28 Oct 1999 20:15:56 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How di I join a string together?
Message-Id: <x71zafdnsz.fsf@home.sysarch.com>

>>>>> "JS" == Jonathan Stowe <gellyfish@gellyfish.com> writes:

  JS> On Thu, 28 Oct 1999 14:25:02 GMT Clinton Pierce wrote:

  >>> Now I want to join 'hello' and 'bye' together and put them in $hostname.
  >>> Like hostname = 'hello' + 'bye'
  >> 
  >> $hostname="$FORM{domain1}$FORM{domain2}";

  JS> Purleeze Clint - thats just sooo lame :

didn't i start a thread a few weeks back on the worst ways to join
strings? i am too lazy this moment to check deja.

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, 28 Oct 1999 17:46:48 -0700
From: Jon Shemitz <jon@midnightbeach.com>
Subject: Re: How di I join a string together?
Message-Id: <3818EE78.75A4AE30@midnightbeach.com>

Steven Filipowicz wrote:

> I'm a webpage I have a form with 2 text fields. 

Wow, that's some hairy AI, that lets a webpage ask questions in
something so close to standard written English. Is the AI script Open
Source?

-- 

http://www.midnightbeach.com    - Me, my work, my writing, and
http://www.midnightbeach.com/hs - my homeschool resource pages


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

Date: Thu, 28 Oct 1999 11:48:26 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How parse a,b,"x,y",c
Message-Id: <a8r9v7.q2h.ln@magna.metronet.com>

Holger Marzen (hm@sik-gmbh.de) wrote:

: How can I split a line into words. The word separator is ,
: However it can be part of words if they are surrounded with "

: Any ideas?


   One idea would be to check the Perl FAQ *before* posting
   to the Perl newsgroup like someone with _good_ manners
   would have done.


   Perl FAQ, part 4:

      "How can I split a [character] delimited string except when inside
       [character]? (Comma-separated files)"


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


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

Date: Thu, 28 Oct 1999 16:36:16 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to compare files in different directories ?
Message-Id: <3818DDF0.B11AEA9C@mail.cor.epa.gov>

Adrian Chin wrote:
> 
> Hi
> 
> I need to compare  files attributes and existence in two diffrerent
> directory ?

There are plenty of DOS and Windows programs which will do this
stuff for you.  PCMagNet used to have a slew of them.  You can
even do it via Explorer if you want.

But for a Perl solution, look up opendir(), readdir(), and
closedir() to learn how to open a directory and read it in.

perldoc -f opendir
perldoc -f readdir
perldoc -f closedir

Then learn how to look at the existence and attributes of
files, using what are called the -X operators:

perldoc -f -X

If you need to recurse into subdirectories too, you'll
want to learn about the File::Find module.

perldoc File::Find

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 28 Oct 1999 14:38:32 -0500
From: Parthasarathi Ramanujam <partha@urbana.css.mot.com>
Subject: Re: How to convert a a single char (from a string) to a int (decimal)???
Message-Id: <3818A638.8572DCC0@urbana.css.mot.com>

See
perldoc -f ord
perldoc -f chr

HTH
Partha

jan smit wrote:

> id like to know how to convert a char to a decimal value ..
> if id have a stringe like so : "hallo" ..
> and id were to use regular expression to get the chat h .. then how could i
> get its decimal value?? .. like @ = 64 if i remember correctly ..



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

Date: Thu, 28 Oct 1999 15:01:36 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: How to convert a a single char (from a string) to a int (decimal)???
Message-Id: <3818ABA0.E2329CA4@texas.net>

jan smit wrote:
> 
> id like to know how to convert a char to a decimal value ..
> if id have a stringe like so : "hallo" ..
> and id were to use regular expression to get the chat h .. then how could i
> get its decimal value?? .. like @ = 64 if i remember correctly ..

perldoc -f ord

- Tom


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

Date: 28 Oct 1999 21:01:01 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to convert a a single char (from a string) to a int (decimal)???
Message-Id: <7vadid$116$1@gellyfish.btinternet.com>

On Thu, 28 Oct 1999 20:20:27 +0200 jan smit wrote:
> id like to know how to convert a char to a decimal value ..
> if id have a stringe like so : "hallo" ..
> and id were to use regular expression to get the chat h .. then how could i
> get its decimal value?? .. like @ = 64 if i remember correctly ..
> 

 look up the function ord() in the fantastic manual ...

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Fri, 29 Oct 1999 02:25:26 GMT
From: wasell@bahnhof.se (Thomas Wasell)
Subject: Re: How to pick a random item from an array?
Message-Id: <MPG.128322c445cc192b989697@news.bahnhof.se>

In article <7uvu7e$gjv$1@gellyfish.btinternet.com>, Jonathan Stowe 
<gellyfish@gellyfish.com> wrote:
>On Sun, 24 Oct 1999 13:24:44 GMT AcCeSsDeNiEd wrote:
>> 
>>       a code                                                 
>>
>
>What does this mean ? This reeks of script kiddie of k3wl t0k of all
>those things that make *this programmer* want to go out an start tending
>sheep ...
>
>You have *some code* or you have *a program* - *a code* will generally have
>nothing to do with computer programming in any particular sense.

True enough, but maybe you should consider cutting him some slack. He 
posts from Singapore, so chances are that English isn't native language. 
(Nor is it mine, BTW.)

-- 
Thomas Wasell -- wasell@bahnhof.se


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

Date: Fri, 29 Oct 1999 03:32:59 GMT
From: dawgeatdawg@my-deja.com
Subject: Re: How to read from Game Port in Win32
Message-Id: <7vb4hb$v36$1@nnrp1.deja.com>

Yeah, I didn't see anything in the SerialPort
module either. Maybe it's in the CommPort module.

I've seen references elsewhere to
using a C or C++ function called inportb to read
from i/o port 201(hex i suppose). I've also read
in newsgroups that there doesn't seem to be a perl
module that implements the inportb function, unless
you can do this with CommPort or SerialPort.

In article <381522A4.8787CB6D@home.com>,
  Kenneth Bandes <kbandes@home.com> wrote:
> "Harlan Carvey, CISSP" wrote:
> > You want the Win32::SerialPort module
> > dawgeatdawg@my-deja.com wrote:
> > > Hope this is the right place for a rookie question: Can someone
show me
> > > code that reads from the game port or joystick with Activeperl?
>
> Offhand, I don't know the answer, but this isn't it - the game port is
> not a serial port and Win32::SerialPort does not mention game port
> support in its documentation.
>
> Ken Bandes
>


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


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

Date: Thu, 28 Oct 1999 12:22:21 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: how to reformat a multiline string
Message-Id: <MPG.1282424cb3915fe98a152@nntp.hpl.hp.com>

In article <38186297.A52C541F@law.georgetown.edu> on Thu, 28 Oct 1999 
14:55:10 GMT, Yuan Yao <yaoy@law.georgetown.edu> says...

 ...

> SUBJECT = Administrative law -- Germany -- Rheinland--Palatinate --
> History.
> TITLE = 50 Jahre Verfassungs- und Verwaltungsgerichtsbarkeit in
> Rheinland -
> Pfalz : eine Chronik / herausgegeben von Karl-Friedrich Meyer ;
> Redaktion:
> Joachim Hennig.
> IMPRINT = Frankfurt : Lang, 1997.
> CALL # = KKC271 .F54 1997.
> OCLC # = 40303464.

 ...

> I tried some scripts in perl faq (extracting a range of lines, matching
> more than one line, etc.) but none seems to work the way I desire.
> 
> Any suggestions?

As you recognize, the basic problem is that dealing with one line at a 
time doesn't match the logical structure of your data file, which is 
defined by certain headers.  It seems to be a sequence of records, each 
of which is started by a line that contains "SUBJECT = ".  So I would 
set that to be the input record separator $/, read one record at a time, 
and parse it.

{ local $/ = "SUBJECT = ";
  while (<DATA>) {
      chomp;
      if (s/(.+?)(?=\n[A-Z]+ =)//s) {
          (my $x = $1) =~ tr/\na-z/ A-Z/;
          print OUT "<b>$x</b>\n";
      }
      if (s/.*?TITLE = (.+?)\n(?=[A-Z]+ =)//s) {
          (my $x = $1) =~ tr/\n/ /;
          print OUT "<br>$x\n";
      }
      print OUT; # Whetever is left in the record?
  }
}

Adapt and adjust to fit!

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


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

Date: Fri, 29 Oct 1999 02:48:13 GMT
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: How to round a number?
Message-Id: <NV7S3.27342$m4.98528579@news.magma.ca>

Russ Allbery <rra@stanford.edu> wrote in message
news:ylaep4rqs1.fsf@windlord.stanford.edu...
> Samuel Kilchenmann <skilchen@swissonline.ch> writes:
>
> > Its in the FFAQ where you find the answer that Perl has no round
> > function and that you could use (s)printf instead.
>
> That is a rounding function.

Then most of Perl's arithmetic operators must be "rounding functions"
too, because they involve some kind of rounding when applied to
floating point values. "Fixing the precision to x decimal digits
(where some rounding is involved)" and "rounding" is not the same. And
the conversion of a double to a decimal string needs a huge amount of
work in addition to the rounding itself (take a look at the
implementation of e.g. dtoa). Don't tell me that stringification is
needed to round a number to its nearest integer (according to some
more or less strange definition of "nearest").

>
>> Usually, though, we can just use sprintf. The f format lets you
>> specify a particular number of decimal places to round its argument
>> to. Perl looks at the following digit, rounds up if it is 5 or
>> greater, and rounds down otherwise.
>
>> This last sentence is simply wrong.
>
> Correct.  It depends on the host rounding mode.
>
Thats exactly why Perl should have a rounding function which doesn't
depend on the host rounding mode. (You probably mean the C-Compilers
rounding mode.)

>
>> To ask the question once more: why is there no round function in
>> Perl with the same behavior on all platforms?
>
> Because floating point arithmetic doesn't work the same on all
> platforms, I'd imagine.
>
Not really: Un*x and Win32 on Intel Boxes use exactly the same
floating point arithmetic, but nonetheless sprintf behaves
differently. A round function could (should) abstract away the
specifics of the underlying floating point arithmetic (and the
specifics of the compiler) to get the same behavior on all supported
platforms. If papers like the "Revised(5) report on the Algorithmic
Language Scheme" do define a specific rounding behavior, that does not
mean that it is impossible to port Scheme to platforms where the
C-Compiler's default rounding mode is not "round to even".

But anyway: some people will tell me again that i should write my own
round() function. No problem, but what i was looking for a long time
ago, was something that may be called an "idiomatic implementation" of
a round function in Perl. Something that nonexperts like me could use
instead of the probably less than optimal (and probably even
incorrect) functions that average Perl programmers like me will write.
(For an example see one of my first posts in this thread.) Such an
"idiomatic round function" implemented in Perl would be a nice and
useful addition to perlfaq4.








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

Date: Fri, 29 Oct 1999 03:47:10 GMT
From: jgivensXX@adelphiaXX.netXX (Jeff Givens)
Subject: Re: How to Trap DBI Errors
Message-Id: <381a1866.3367654@nntp>

On 27 Oct 1999 16:44:13 GMT Erik van Roode <newsposter@cthulhu.demon.nl>
wrote:

>> How about setting raiseerror to zero, can I then make an error call
>> after every dbi function, something like:
>
>  Yes, you can set RaiseError to 0:
>
>    my $dbh = DBI->connect($db, $db_user, $db_passwd, {
>        RaiseError => 0,
>        AutoCommit => 0,
>        PrintError => 0,
>    });

That's the route I took Erik. A simple check of the error string generates
the error html code.

Haven't the time at the moment for finesse and proper coding - ugly is as
ugly does.

Thanks for the info Erik.
_________________________________________________________________
JG...                                                 Jeff Givens
         mailto:jgivensXX@adelphiaXX.netXX

"My hovercraft is full of eels."


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

Date: Fri, 29 Oct 1999 02:30:21 GMT
From: Tim Richardson <ter@my-deja.com>
Subject: How to use Perlscript from Visual Basic for Applications with Script Control
Message-Id: <7vb0ru$smd$1@nnrp1.deja.com>

 Here is an example of using Perl in Visual Basic for Applications.

You need to get the Microsoft Script Control (free) from
http://msdn.microsoft.com/scripting
and of course the ActiveState Win32 Perl distribution, and don't change
the default installation of PerlScript.

I'm putting this here because I couldn't find any examples of this
useful technique anywhere. This example works in Access.

I'm not much of Visual Basic programmer, and it is an awful and foul
visitation upon us, but at least now I can use regular expressions at
will. I'm a lot more cheerful.

Public Function applyRegExp(ByVal inputStr As String, ByVal FromExp As
String, ByVal ToExp As String)
    Dim sc As ScriptControl
    Set sc = CreateObject("ScriptControl")
    Dim strCode As String

    strCode = "sub findReplace(){($in,$find,$replace) = @_;" _
    & "$in =~ s/$find/$replace/g;return $in}"

    sc.Language = "PerlScript"
    sc.AddCode strCode

    applyRegExp = (sc.Run("findReplace", inputStr, FromExp, ToExp))
End Function




Rem Have fun.


--
Tim Richardson
(search string: qweeblebeast)


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


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

Date: 28 Oct 1999 20:42:15 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: HTML Table to Array?
Message-Id: <7vacf7$10i$1@gellyfish.btinternet.com>

On Thu, 28 Oct 1999 10:30:26 -0500 Hank Marquardt wrote:
> Tom Phoenix <rootbeer@redcat.com> wrote in message
> news:Pine.GSO.4.10.9910271946140.29843-100000@user2.teleport.com...
>> On Wed, 27 Oct 1999, Hank Marquardt wrote:
>>
>> > Is there a function/module that takes a html file, looks for tables
>> > and then will return an array of values based on individual rows/cell
>> > contents?
>>
>> Sure there is. But maybe no one has written it yet. :-)
>>
>> But start with HTML::Parser from CPAN. Good luck!
>>
> I found that already .... I was being lazy <- a programmer is supposed to do
> that, right?;)
> 
> Guess I'll have to write the code anyway.
> 

OK,OK.  I did offer to do the HTML::Parser examples this week ;-}

Here is a module sub-classed from HTML::Parser that will take some HTML
with a table in it and create a list of lists contain the table - it will
only get the last table in a document and Lord knows what it will do if
you have tables within tables - but hey I just got home from work :


package TableThing;

use strict;

use vars qw(@ISA $infield $inrecord $intable);

@ISA = qw(HTML::Parser);

require HTML::Parser;

sub start()
{
   my($self,$tag,$attr,$attrseq,$orig) = @_;
   if ($tag eq 'table')
     {
      $self->{Table} = ();
      $intable++;
     }
   if ( $tag eq 'tr' )
     {
       $self->{Row} = ();
       $inrecord++ ;
     }
   if ( $tag eq 'td' )
     {
       $self->{Field} = '';
       $infield++;
     }
}



sub text()
{
   my ($self,$text) = @_;
   if ($intable && $inrecord && $infield )
     {
       $self->{Field} .= $text;
     }
}

sub end()
{
   my ($self,$tag) = @_;
   $intable-- if($tag eq 'table');
   if($tag eq 'td')
    {
     $infield--;
     push @{$self->{Row}},$self->{Field};
    }
   if($tag eq 'tr')
    {
     $infield--;
     push @{$self->{Table}},\@{$self->{Row}};
    }
}

1;

Of course this is not a 'proper' module 'cause it has no POD and wants
an access method to get at the 'Table' structure ...

And here is some code that uses it to output a comma separated file from
a table :


#!/usr/bin/perl -w

use strict;

use TableThing;

my $table = new TableThing;

$table->parse_file('table.html');

foreach ( @{$table->{Table}} )
{
  print join(',',@{$_}),"\n";
}


This assumes that the module is saved in a file 'TableThing.pm' in the
current directory or somewhere in @INC;

HTH

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Thu, 28 Oct 1999 17:22:17 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: HTML Table to Array?
Message-Id: <3818E8B9.C124C962@mail.cor.epa.gov>

Hank Marquardt wrote:
> 
> Thanks Tom,
> 
> I found that already .... I was being lazy <- a programmer is supposed to do
> that, right?;)
> 
> Guess I'll have to write the code anyway.
> 
> This is probably heresy in this group given the number of *NIX folks around,
> but I solved the immediate need by opening the html file in MS Excel 2000
> and Excel did all the work for me.   Still I'll need to do this again in an
> automated fashion so I'm not out of the coding woods.

Well, there are multi-platform and non-unix people around here.

But if Excel handled everything for you, you could consider
automating this using Win32::OLE and automatically using
Excel as your.. umm.. filter.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 28 Oct 1999 16:45:17 -0700
From: moseley@best.com (Bill Moseley)
Subject: I'm a bit lost with this LWP problem
Message-Id: <MPG.12827fec9b04fbf989823@nntp1.ba.best.com>

Ok, I've got a routine (below) that uses LWP to validate a URL.


I'm passing it www.test.com:44991/test and I get the error:
Can't locate URI/www_Otest_Ocom.pm in @INC (@INC contains: /home/....) 
at (eval 21) line 3.

What are those "_0" doing there?

If I add http:// to the URL it works fine.  If I remove the port number 
then it gives me the "400 URL must be absolute" error.

But the real ugly thing is I place just the subroutine in a new program 
for testing and the error doesn't happen.  (Of course, it's a CGI script 
processing a large form.)  

Tips on debugging this?

Happens on Solaris and ActiveState.
21) ~ %perl -MURI -e 'print $URI::VERSION . "\n"'
1.04
22) ~ %perl -MLWP -e 'print $LWP::VERSION . "\n"'
5.44
23) ~ %perl -MLWP::UserAgent -e 'print $LWP::UserAgent::VERSION . "\n"'
1.67

Output:
url = www.test.com:44991/test
about to create request object
Can't locate URI/www_Otest_Ocom.pm in @INC (@INC contains: /home...


sub validate_link {
    my %headers;

    my $url = shift;

    use LWP::UserAgent;

    my $start_time = time();

    my ( $ua, $req, $res );

warn "url = $url\n";

    # Create the UserAgent object and set some parameters
    $ua = LWP::UserAgent->new(); 
    $ua->agent('Mozilla/4.08 [en] (Win98; U ;Nav)');
warn "about to create request object\n";
    $req = HTTP::Request->new(GET => $url );
    $ua->timeout( $LWP_GET_WAIT || 30 );
warn "about to request\n";
    $res = $ua->simple_request($req, sub { die }, 100 );
warn "done with reqest\n";

    $headers{TIME}      = time() - $start_time;
    $headers{STATUS}    = $res->status_line;
    $headers{SUCCESS}   = $res->is_success();

    $res->scan( sub { 
        my ($key, $value) = @_;
        $headers{lc($key)
     } .=  $value } );

    return \%headers;

}
-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Thu, 28 Oct 1999 14:17:45 -0500
From: Seth David Johnson <sjohns17@uic.edu>
Subject: Re: Installing perl for apache on winnt !!
Message-Id: <Pine.A41.4.10.9910281416090.116522-100000@tigger.cc.uic.edu>

On Thu, 28 Oct 1999, anis benhamida wrote:

> Hi all !!
> Could somebody help me for installing perl modules under Apache for Winnt4
> !!
> thanx !!

Yes, read up on PPM:

http://www.activestate.com/PPM/

!! reading the docs is useful !!

-Seth
 www.pdamusic.com



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

Date: 28 Oct 1999 21:18:49 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Installing perl for apache on winnt !!
Message-Id: <7vaejp$135$1@gellyfish.btinternet.com>

On Thu, 28 Oct 1999 18:54:17 +0200 anis benhamida wrote:
> Hi all !!
> Could somebody help me for installing perl modules under Apache for Winnt4
> 

Nothing to do with Apache whatsoever - read about PPM in the activestate
documentation.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Thu, 28 Oct 1999 20:46:36 -0400
From: root <mbacchi@together.net>
Subject: ioctl() on /dev/tty
Message-Id: <3818EE6C.B0B6D0ED@together.net>

I'm attempting to run a daemon process(pppd) from a perl script which
itself will be run from cron.  I seem to have a problem because it runs
fine if I start it from the command line, but it dies if run from cron.
 The Perl docs say that this about daemon processes:

<QUOTE>
How do I fork a daemon process?

If by daemon process you mean one that's detached (disassociated from
its tty), then the following process is reported to work on
most Unixish systems. Non-Unix users should check their Your_OS::Process
module for other solutions.

       Open /dev/tty and use the the TIOCNOTTY ioctl on it. See tty(4)
for details. Or better yet, you can just use the POSIX::setsid()
       function, so you don't have to worry about process groups.

       Change directory to /

       Reopen STDIN, STDOUT, and STDERR so they're not connected to the
old tty.

       Background yourself like this:

             fork && exit;
<\QUOTE>

Yet I can't seem to get this to work.  Here's some of my code:

require 'ioctl.ph';
`/usr/sbin/pppd`;
open (TTY,'/dev/tty');
ioctl(TTY,TIOCNOTTY,0)
   || die "Can't ioctl: $!";

open STDIN, ">&STDIN";
open STDOUT, ">&STDOUT";
open STDERR, ">&STDERR";

I'm getting an error when the ioctl() command fails.  Anyone have any
ideas?

-Matt



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

Date: 29 Oct 1999 03:34:13 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: ioctl() on /dev/tty
Message-Id: <slrn81i5dl.hj0.sholden@pgrad.cs.usyd.edu.au>

On Thu, 28 Oct 1999 20:46:36 -0400, mbacchi@together.net wrote:
>I'm attempting to run a daemon process(pppd) from a perl script which
>itself will be run from cron.  I seem to have a problem because it runs
>fine if I start it from the command line, but it dies if run from cron.
> The Perl docs say that this about daemon processes:
>
>open (TTY,'/dev/tty');
>ioctl(TTY,TIOCNOTTY,0)
>   || die "Can't ioctl: $!";

>I'm getting an error when the ioctl() command fails.  Anyone have any
>ideas?

Probably something to do with the fact that a program executed by cron
isn't connected to a TTY in the first place.

You should check the return value of open too.


-- 
Sam

Simple rule: include files should never include include files.
	--Rob Pike


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

Date: Thu, 28 Oct 1999 22:07:11 -0400
From: Blake Meike <blakem@world.std.com>
Subject: Re: Is this a bug?
Message-Id: <3818FE6B.405297AD@world.std.com>

It appears that this is a real, serious bug, but that it is not in perl.
 I haven't yet pinned it down, but it appears to be a problem with older
versions of the GNU libc library.  A verbatim copy of an installation of
perl 5.00503 from a RedHat 5.2 system to a RedHat 6.1 system, made the
bug disappear.

  -blake



The following program doesn't behave in at all the way I would expect.
Is this a bug, or have I overlooked something.

Blake Meike
Adero Inc.

#!/usr/bin/perl -w
use strict;

my $MAX_THREADS = 2;
my $threads = 0;

while (<DATA>) {
    print STDERR "$.: $_";

    while ($threads >= $MAX_THREADS) {
        wait();
        $threads--;
    }
        
    unless (fork()) { sleep 2; exit; }

    $threads++;
}

__END__
1
2
3
4


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

Date: Thu, 28 Oct 1999 16:31:14 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Just to get rid of dos prompt window.
Message-Id: <3818DCC2.197B0D33@mail.cor.epa.gov>

Matthew David Zimmerman wrote:
> 
> In article <380640CC.FB326CA6@sympatico.ca>,
> Guo Quin  <cau.quach@sympatico.ca> wrote:
> >Hello. Please answer one of following questions.
> >
> >1/How can I add --more-- to "perldoc -f xxxx and/or perdoc -q xxxx"
> >(MSWindows) ?
> 
> perldoc -f xxxx | more
> perldoc -q xxxx | more

I'm sorry, but you really should have tried these in
win95/98 before posting.  They don't work.  Pipes _et_al._
are too broken.  The best solution is the one I posted
yesterday - a better perldoc, from ActiveState.

> >2/How can I "perldoc (as above) > text_file" (MSwindows) ?
> 
> perldoc -f xxxx > textfile
> 
> should work under MS-DOS 6.22.

Nope, this doesn't work either [win95/98].  The 'best'
you can hope for here is a scrolling mess on your screen 
and a 0-length file names 'textfile' in your current
directory.  Hardly optimal.

> >3/How to put "perldoc (as above)" in a perl script to print output in
> >www
> >browser ?
> 
> http://www.perl.com/pub/v/documentation    :)
> 
> Not to mention that you should have www versions of the docs if you have
> Activestate. Look around somewhere (dir called 'html', maybe? )

You *should* have this as a line in your Start Menu, thanks
to the install process.  So this searching shouldn't be
needed.  But you're right about the location.  The files are
in the html directory under the place you installed Perl,
as well as the subdirs of the html directory.

Thanks for trying, Matt.  But, as I learned the hard way,
it always pays off to test even the obvious bits before posting.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 28 Oct 1999 16:33:36 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: length (number of items) of an array
Message-Id: <xkfr9iff73z.fsf@valdemar.col.hp.com>

cberry@cinenet.net (Craig Berry) writes:
> Abigail (abigail@delanet.com) wrote:
> : Daniel Krajzewicz (krajzewicz@inx.de) wrote on MMCCXLVIII September
> : MCMXCIII in <URL:news:3816E60E.1EAD5366@inx.de>:
> : $$ How do I get the number of items (the length of) an array ?
> : 
> : while (@array) {$count ++; shift}
> 
> But after that infinite loop completes, as the last protons are decaying,
> how do we finally get the length of @array?  Or is this optimized to
> measure the length of empty arrays?

See that's what's called "inadequately specifying the problem",
a.k.a. "Leaving room for answers that have side effects you didn't say
you didn't want", a.k.a. "What you get if you don't read the
documentation, which clearly and unambiguously tells how to do this."

-=Eric
-- 
"Cutting the space budget really restores my faith in humanity.  It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation."
                -- Johnny Hart


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

Date: Fri, 29 Oct 1999 04:05:54 GMT
From: nospam.newton@gmx.li (Philip 'Yes, that's my address' Newton)
Subject: Re: length (number of items) of an array
Message-Id: <381919d0.424586352@news.nikoma.de>

On 28 Oct 1999 14:40:09 GMT, gbacon@ruby.itsc.uah.edu (Greg Bacon)
wrote:

>        return 0 if $#_ == -1;

What if someone outside of your subroutine fiddles with $[ ?

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>


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

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


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