[26896] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8886 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 26 03:05:45 2006

Date: Thu, 26 Jan 2006 00:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 26 Jan 2006     Volume: 10 Number: 8886

Today's topics:
    Re: array question <tadmc@augustmail.com>
    Re: concatenate variables during looping question <tadmc@augustmail.com>
        How can I get the full path for the running script (lik <imfeaw5672@pacbell.net>
        How do I set timeout in Net::HTTP? <speediercoREMOVE_THIS@yahoo.com>
        How do I set timeout in Net::HTTP? <speediercoREMOVE_THIS@yahoo.com>
        How do I set timeout in Net::HTTP? <speediercoREMOVE_THIS@yahoo.com>
        How do I set timeout in Net::HTTP? <speediercoREMOVE_THIS@yahoo.com>
    Re: How do I set timeout in Net::HTTP? <speediercoREMOVE_THIS@yahoo.com>
    Re: How do I set timeout in Net::HTTP? <jgibson@mail.arc.nasa.gov>
    Re: Ordering string of commands in a file (Raghuramaiah Gompa)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 25 Jan 2006 17:59:14 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: array question
Message-Id: <slrndtg46i.blh.tadmc@magna.augustmail.com>

a <a@mail.com> wrote:

> syntax error at filename line 20, near "]~"


line _20_ huh?


> "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net> ¼¶¼g©ó¶l¥ó·s»D
>:Xns975672314DF1Felhber1lidotechnet@10.232.40.227...
>>
>> [don't top-post]
    ^^^^^^^^^^^^^^
    ^^^^^^^^^^^^^^
    ^^^^^^^^^^^^^^

Did you see that?

If you don't understand what it means, then ask what it means.

If you do understand what it means, then stop doing it!


>> "a" <a@mail.com> wrote:
>>
>> > "Jürgen Exner" <jurgenex@hotmail.com> ¼¶¼g©ó¶l¥ó·s»D
>> >:K%HBf.1621$iD.886@trnddc08...
>> >> a wrote:

>> >> > Can I do the following?
>> >> > my @ary;
>> >> > $ary[0]="a";
>> >> > $ary[1]="b";
>> >>
>> >> Have you tried it? What happened?
>> >
>> >
>> > Hi,
>> > Syntax error complains but not specific
>>
>>
>> They are always specific. What was the error message you got?


We have seen only a 3-line program.

There *is no* line 20, so you are on your own...


Have you seen the Posting Guidelines that are posted here frequently?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 25 Jan 2006 22:50:51 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: concatenate variables during looping question
Message-Id: <slrndtgl9b.dqa.tadmc@magna.augustmail.com>

lance-news <lance-news@augustmail.com> wrote:

> Trying to create a loop and need some help
> in concatenation


What you really need is a better choice of data structure.



> My current syntax:
> 
> $Sheet->Cells(16,2)->{Value} = $Ja13_1;
> $Sheet->Cells(16,3)->{Value} = $Ja13_2;
> $Sheet->Cells(16,4)->{Value} = $Ja13_3;
> $Sheet->Cells(16,5)->{Value} = $Ja13_4;
> $Sheet->Cells(16,6)->{Value} = $Ja13_5;
> $Sheet->Cells(16,7)->{Value} = $Ja13_6;


Sequentially-named variables are a red flag that an array would 
be a better data structure than a slew of individual scalars.


> What I am trying to do:
> 
> for (my $i=2; $i=7; $i++){


   foreach my $i ( 2 .. 7 ) {  # easier to read and understand


> $Sheet->Cells(16,$i)->{Value} = "$Ja13_"."$i-1";


What you are attempting to do is use something called a "symbolic reference".

They are bad. 

They can lead to hard-to-troubleshoot bugs, and can nearly always
be refactored using a hash and/or a real reference.


>                           }
> 
> but doesn't work.


Have you seen the Posting Guidelines that are posted here frequently?


> Also, how could I incorporate an array so I could create 2 loops such 
> that all the lines above compress to one line?


If you had @Ja13, then:

   $Sheet->Cells(16, $_)->{Value} = $Ja13[$_ - 1] for 2 .. 7;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 26 Jan 2006 01:18:13 GMT
From: "sm" <imfeaw5672@pacbell.net>
Subject: How can I get the full path for the running script (like $0)
Message-Id: <prVBf.14310$_S7.20@newssvr14.news.prodigy.com>

Hi Folks,
I need to know the full path to the running script ( $0 provides the name of 
the file)
is there a way to get the full path.
for example:
I run the script  "/root/eng/perlscripts/xyz.pl"
$0 = xyz.pl
I need a way to know "/root/eng/perlscripts/xyz.pl"

Thanks
-sm




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

Date: Wed, 25 Jan 2006 19:43:55 -0500
From: "OttawaTrade" <speediercoREMOVE_THIS@yahoo.com>
Subject: How do I set timeout in Net::HTTP?
Message-Id: <shVBf.71$Mw4.44@fe13.lga>

 use Net::HTTP;
 my $s = Net::HTTP->new(Host => "myserver.com") || die $@;
 $s->write_request(HEAD => "/", );

I am trying to monitor the myserver.com, however, the script just hangs
there forever, like 5 miutes so, then give me "Net::HTTP: Timeout at
check_server_up.pl line 4.". I hope to set it at 15seconds at max, but maybe
try after 15 seconds then die; or move on to email me...





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

Date: Wed, 25 Jan 2006 19:43:55 -0500
From: "OttawaTrade" <speediercoREMOVE_THIS@yahoo.com>
Subject: How do I set timeout in Net::HTTP?
Message-Id: <AXUBf.9937$WC4.6558@fe17.lga>

 use Net::HTTP;
 my $s = Net::HTTP->new(Host => "myserver.com") || die $@;
 $s->write_request(HEAD => "/", );

I am trying to monitor the myserver.com, however, the script just hangs
there forever, like 5 miutes so, then give me "Net::HTTP: Timeout at
check_server_up.pl line 4.". I hope to set it at 15seconds at max, but maybe
try after 15 seconds then die; or move on to email me...





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

Date: Wed, 25 Jan 2006 19:43:55 -0500
From: "OttawaTrade" <speediercoREMOVE_THIS@yahoo.com>
Subject: How do I set timeout in Net::HTTP?
Message-Id: <K%UBf.9938$WC4.7007@fe17.lga>

 use Net::HTTP;
 my $s = Net::HTTP->new(Host => "myserver.com") || die $@;
 $s->write_request(HEAD => "/", );

I am trying to monitor the myserver.com, however, the script just hangs
there forever, like 5 miutes so, then give me "Net::HTTP: Timeout at
check_server_up.pl line 4.". I hope to set it at 15seconds at max, but maybe
try after 15 seconds then die; or move on to email me...





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

Date: Wed, 25 Jan 2006 19:43:55 -0500
From: "OttawaTrade" <speediercoREMOVE_THIS@yahoo.com>
Subject: How do I set timeout in Net::HTTP?
Message-Id: <63VBf.9939$WC4.2387@fe17.lga>

 use Net::HTTP;
 my $s = Net::HTTP->new(Host => "myserver.com") || die $@;
 $s->write_request(HEAD => "/", );

I am trying to monitor the myserver.com, however, the script just hangs
there forever, like 5 miutes so, then give me "Net::HTTP: Timeout at
check_server_up.pl line 4.". I hope to set it at 15seconds at max, but maybe
try after 15 seconds then die; or move on to email me...





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

Date: Wed, 25 Jan 2006 20:09:46 -0500
From: "OttawaTrade" <speediercoREMOVE_THIS@yahoo.com>
Subject: Re: How do I set timeout in Net::HTTP?
Message-Id: <zjVBf.83$Mw4.7@fe13.lga>

> use Net::HTTP;
>  my $s = Net::HTTP->new(Host => "myserver.com") || die $@;
>  $s->write_request(HEAD => "/", );
>
> I am trying to monitor the myserver.com, however, the script just hangs
> there forever, like 5 miutes so, then give me "Net::HTTP: Timeout at
> check_server_up.pl line 4.". I hope to set it at 15seconds at max, but
maybe
> try after 15 seconds then die; or move on to email me...
>

Apparently, I can use (host=>,timeout=>10); timeout is not published in
net::http. possible got this from http's parent.

another problem i have is that

my $s = Net::HTTP->new(Host => "myserver.com") || die &sub1;

it always output something to stdout; how do I keep die quiet?




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

Date: Wed, 25 Jan 2006 17:44:51 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: How do I set timeout in Net::HTTP?
Message-Id: <250120061744518605%jgibson@mail.arc.nasa.gov>

In article <zjVBf.83$Mw4.7@fe13.lga>, OttawaTrade
<speediercoREMOVE_THIS@yahoo.com> wrote:

> > use Net::HTTP;

[timeout problem snipped]

> another problem i have is that
> 
> my $s = Net::HTTP->new(Host => "myserver.com") || die &sub1;
> 
> it always output something to stdout; how do I keep die quiet?

Use exit?

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Thu, 26 Jan 2006 03:39:56 +0000 (UTC)
From: rgompa@steel.ucs.indiana.edu (Raghuramaiah Gompa)
Subject: Re: Ordering string of commands in a file
Message-Id: <dr9gac$djh$1@rainier.uits.indiana.edu>

>Is that what you mean?
>
>The code below *might* do something like you want, but
>since your
>specification is lacking, the results may be too.
>
>Interesting (to me) sidenote: I noticed that when I
>added the lc()
>calls to the sort, the warnings about use of undefined
>variables
>(because Title isn't defined for some elements) went
>away. Shouldn't
>lc() warn if it's passed undef?
>
>
>#!/usr/bin/perl
>use warnings;
>use strict;
>
>my %items;
>while(<DATA>) {
>    $items{$2}{$1} = $3 if /^(\w+?)(\d+)=(.+)/;
>}
>
>my $n = 1;
>for my $idx (
>     sort {
>	    lc $items{$a}{Title} cmp lc $items{$b}{Title}
>	} keys %items)
>{
>    print map {
>		"$_$n=$items{$idx}{$_}\n";
>	    } keys %{$items{$idx}};
>    print "----\n";
>    ++$n;
>}

Now I am trying to modify the above code to print the 
hash without the sort command.  Could some one help me 
with this?  Thanks. .. Raghu



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8886
***************************************


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