[21978] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4200 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 30 21:05:45 2002

Date: Sat, 30 Nov 2002 18:05:06 -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           Sat, 30 Nov 2002     Volume: 10 Number: 4200

Today's topics:
        anyone compile perl on linux? heitkamp@ameritech.net
    Re: anyone compile perl on linux? <goldbb2@earthlink.net>
    Re: Automatic input response in perl script (Maurice Fox)
    Re: Automatic input response in perl script <terachichi@yahoo.com>
    Re: Automatic input response in perl script (Tad McClellan)
        checking for dead links, LWP::Simple (Jason Quek)
    Re: checking for dead links, LWP::Simple <comdog@panix.com>
    Re: checking for dead links, LWP::Simple (Jay Tilton)
    Re: Need Help with OLE ! <Mark@ecc-limited.com>
    Re: Need Help with OLE ! (Jay Tilton)
        string processing in Perl (David Tian)
    Re: string processing in Perl (Jay Tilton)
    Re: win32 <aka@mvps.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 30 Nov 2002 21:01:23 GMT
From: heitkamp@ameritech.net
Subject: anyone compile perl on linux?
Message-Id: <DG9G9.4229$4j5.2308800@newssvr28.news.prodigy.com>
Keywords: glibc-2.3.1, gcc-3.2.1, perl, linux

I have Linux kernel 2.4.20-rc1, glibc-2.3.1 and gcc-3.2.1.
I can get perl 5.6.1 and 5.8.1 to compile but the Configure
does not find these functions which are on my system.

gethostbyaddr() NOT found.
 
gethostbyname() NOT found.
 
gethostent() NOT found.

getprotobyname() NOT found.
 
getprotobynumber() NOT found.
 
getprotoent() NOT found.

Have you had this problem?

-- 

Fred

Error Loading Explorer.exe
You must reinstall Windows.


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

Date: Sat, 30 Nov 2002 18:52:38 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: anyone compile perl on linux?
Message-Id: <3DE94F46.6C652571@earthlink.net>

heitkamp@ameritech.net wrote:
> 
> I have Linux kernel 2.4.20-rc1, glibc-2.3.1 and gcc-3.2.1.
> I can get perl 5.6.1 and 5.8.1 to compile but the Configure
> does not find these functions which are on my system.
[snip]

This isn't really the best place to post this kind of problem -- send it
to the perl5porters mailing list using the 'perlbug' program which comes
with perl, or mail directly to perl5-porters@perl.org.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: 30 Nov 2002 14:52:21 GMT
From: mauricef@ix.netcom.com (Maurice Fox)
Subject: Re: Automatic input response in perl script
Message-Id: <asajb5$37s$2@slb3.atl.mindspring.net>

In article <3DE85E03.3D88F3C4@yahoo.com>, PL wrote:
> Hi,
> 
> I have a perl script calling another program which will
> in turn ask me a series of yes/no questions, and I already know
> the responses to this series of questions beforehand. How can I redirect
> a yes/no
> response to this program in my perl script in the automatic mode
> without having the script stopped and asked me for inputs?
> 
> thanks
> 

You could use Expect, I expect, but I found this to be simple and practical:

my @res = `myprog <<END_OF_STUFF
Y
1
Beethoven
n
END_OF_STUFF
`;

I'm remembembering this from work, so the right backtick might out of place.
Anyway, that's the idea.

HTH - Maurice


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

Date: Sat, 30 Nov 2002 13:46:48 -0800
From: PL <terachichi@yahoo.com>
Subject: Re: Automatic input response in perl script
Message-Id: <3DE931C8.71A804A8@yahoo.com>

Could you please point me to some on-line documentation/books
on Expect module from CPAN?

thanks in advance

Ben Morrow wrote:

> PL <terachichi@yahoo.com> wrote:
> >I have a perl script calling another program which will
> >in turn ask me a series of yes/no questions, and I already know
> >the responses to this series of questions beforehand. How can I redirect
> >a yes/no
> >response to this program in my perl script in the automatic mode
> >without having the script stopped and asked me for inputs?
>
> You want the Expect module from CPAN.
>
> Ben



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

Date: Sat, 30 Nov 2002 17:23:19 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Automatic input response in perl script
Message-Id: <slrnauii37.2oe.tadmc@magna.augustmail.com>

PL <terachichi@yahoo.com> wrote:
> Could you please point me to some on-line documentation/books
> on Expect module from CPAN?


   http://search.cpan.org/author/RGIERSIG/Expect-1.15/Expect.pod


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


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

Date: Sat, 30 Nov 2002 18:50:57 GMT
From: jason@generationterrorists.com (Jason Quek)
Subject: checking for dead links, LWP::Simple
Message-Id: <3de9072a.9615286@news.starhub.net.sg>

Hi,

I am using the following code to check an array of URLs for deadlinks.

#--------------------------------------------------------------------------------------------
@urls = ('http://www.cnn.com', 'http://www.cnnnnnnn.com');

use LWP::Simple;

foreach (@urls)
	{
	if (head($_))
		{
		print "OK: $_\n";
		}
	else
		{
		print "NOTOK: $_\n";
		}
	}
#--------------------------------------------------------------------------------------------

Even though 'http://www.cnnnnnnn.com' doesn't exist, the script still
returns it as 'OK'.

What am I doing wrong? Any help would be appreciated.




Jason Q.


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

Date: Sat, 30 Nov 2002 17:48:45 -0600
From: brian d foy <comdog@panix.com>
Subject: Re: checking for dead links, LWP::Simple
Message-Id: <301120021748451317%comdog@panix.com>

In article <3de9072a.9615286@news.starhub.net.sg>, Jason Quek
<jason@generationterrorists.com> wrote:

> foreach (@urls)
>  {
>  if (head($_))
>     {
>     print "OK: $_\n";
>     }
>  else
>     {
>     print "NOTOK: $_\n";
>     }
>  }

> Even though 'http://www.cnnnnnnn.com' doesn't exist, the script still
> returns it as 'OK'.

it returns NOTOK for me.

also, you cannot always trust HEAD.  some major servers do not 
implement it correctly, so you should check a HEAD failure with 
a GET.

-- 
brian d foy, comdog@panix.com


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

Date: Sat, 30 Nov 2002 23:49:30 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: checking for dead links, LWP::Simple
Message-Id: <3de94cb3.171499997@news.erols.com>

jason@generationterrorists.com (Jason Quek) wrote:

: I am using the following code to check an array of URLs for deadlinks.
: 
: #--------------------------------------------------------------------------------------------
: @urls = ('http://www.cnn.com', 'http://www.cnnnnnnn.com');
: use LWP::Simple;
: foreach (@urls)
: 	{
: 	if (head($_))
: 		{
: 		print "OK: $_\n";
: 		}
: 	else
: 		{
: 		print "NOTOK: $_\n";
: 		}
: 	}
: #--------------------------------------------------------------------------------------------
: 
: Even though 'http://www.cnnnnnnn.com' doesn't exist, the script still
: returns it as 'OK'.
: 
: What am I doing wrong?

Nothing obvious.

: Any help would be appreciated.

Looking at the returned headers or at the return from get() might give
some clues on why your system is finding a phantom document.



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

Date: Sat, 30 Nov 2002 12:14:46 -0000
From: "mark wildey" <Mark@ecc-limited.com>
Subject: Re: Need Help with OLE !
Message-Id: <uuhanlqcir907f@corp.supernews.com>

Jay

Thanks for the reply. I'm rather new at Perl and OLE so please excuse my
simplistic approach to what I'm trying to achieve

#
#     Tailor the graph to remove the "Code" column from the graph
#

                  $Sheet->Chart("Chart 22")->Activate ;
                  $Chart->PlotArea->Select ;
                  $Chart->SeriesCollection(1)->Delete ;


The $Chart has been defined before for use in generating and formating the
Excel charts. There is only one chart on each worksheet.

Thanks again

Mark




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

Date: Sat, 30 Nov 2002 16:30:25 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Need Help with OLE !
Message-Id: <3de8c2fd.136241037@news.erols.com>

"mark wildey" <Mark@ecc-limited.com> wrote:

: Thanks for the reply. I'm rather new at Perl and OLE so please excuse my
: simplistic approach to what I'm trying to achieve

Nothing to excuse.  Simple is good.

In future, please quote enough material from the article to supply context
to your reply.[1]  

For reference, here's the original VBA macro.

    ActiveSheet.ChartObjects("Chart 22").Activate
    ActiveChart.PlotArea.Select
    ActiveChart.SeriesCollection(1).Delete
    
: #     Tailor the graph to remove the "Code" column from the graph
: 
:                   $Sheet->Chart("Chart 22")->Activate ;
:                   $Chart->PlotArea->Select ;
:                   $Chart->SeriesCollection(1)->Delete ;
: 
: The $Chart has been defined before for use in generating and formating the
: Excel charts. There is only one chart on each worksheet.

Since the methods invoked for $Chart are failing, its value must be stale.
It may be a Chart object, but it's not necessarily the same one
represented by ActiveChart.  Same for $Sheet.

If you want a specific chart from a specific sheet in a specific workbook,
the code should get hold of those objects...umm...specifically.

    my $app = Win32::OLE->new('Excel.Application', 'Quit');
    my $workbook = $app->Workbooks->Open('c:\temp\test.xls');
    my $sheet = $workbook->ActiveSheet;
    my $chart = $sheet->ChartObjects(1)->Chart; # Only one chart there
    $chart->PlotArea->Select;
    $chart->SeriesCollection(1)->Delete;

Or knock it all out in one swoop.


$workbook->ActiveSheet->ChartObjects(1)->Chart->SeriesCollection(1)->Delete;
    
(It should get along fine without the "PlotArea->Select" part.  Excel was
just dutifully recording everything you did.)
    
FWIW, most recorded macros can be converted instantly by exploiting the
fact that ActiveSheet and ActiveChart (and others) are methods of the
Application object.

    $app->ActiveSheet->ChartObjects(1)->Activate;
    $app->ActiveChart->PlotArea->Select; # necessary step?
    $app->ActiveChart->SeriesCollection(1)->Delete;

*snap*

[1]Lots more good advice on participating in c.l.p.m. can be found in the
Posting Guidelines, which can be found at
http://mail.augustmail.com/~tadmc/clpmisc.shtml



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

Date: 30 Nov 2002 16:09:25 -0800
From: yuanxi80@hotmail.com (David Tian)
Subject: string processing in Perl
Message-Id: <da930649.0211301609.465743d2@posting.google.com>

hi,

How would I do the following in Perl:

Given some lines of texts, terminating with the standard Unix
"end-of-file",
1)I would like to remove any leading spaces and/or punctuations before
the first input word. So eg. '    ,.I am male.' becomes 'I am male.'
 
The regular expression (re) '/^\s*.\w+$/' would match the leading
punctuations and/or spaces. What would be the new re it is substituted
with? Something like '/^\w+$'? (but it isn't working,'w+' gets
substituted).

2)Remove any space(s) between a word and a punctuation. e.g. 'word  
,' becomes
 'word,'. 

I think the re '/\w*\s+\[\.\,]/ would match the pattern. What would be
the new re it is substituted with?

3)Wherever a pattern a punctuation with a word (e.g.',word' where
'word' is any sequcence of letters) exists, add a space immediately
after the punctuation, so
',word' becomes ', word'. 

I think the re '/.\[\,\.]\w*$/' matches this kind of pattern. What
would be the new re it is substituted with?

4)
Print lines of the texts of at most 70 characters to the standard
output, so that no word is split in the middle at the 70th place on
each line.
And also each line starts with a whole word (no punctuation, spaces).

I guessed an array would be useful. Put the strings of texts into an
array, then do the following:

 loop: get the next 70th char from the lines of texts, 
       
       do some pattern matching and insert an newline char at an
approperiate
       place (before or at the 70th char).
       align this line of text to the left.
       add this line of text to the end of previous line of text (this
is a
       string)
 stop when EOF reached.

 Print the string of lines of text on standard output.

How would do these in Perl?

Cheers,

David


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

Date: Sun, 01 Dec 2002 01:16:29 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: string processing in Perl
Message-Id: <3de955c8.173825867@news.erols.com>

yuanxi80@hotmail.com (David Tian) wrote:

: 1)I would like to remove any leading spaces and/or punctuations before
: the first input word. So eg. '    ,.I am male.' becomes 'I am male.'
:  
: The regular expression (re) '/^\s*.\w+$/' would match the leading
: punctuations and/or spaces. 

Disassemble it and see what the pieces would match.  The /x modifier lets
you add comments to make the meaning of each piece more transparent.

    m/
        ^   # anchored at beginning of string
        \s* # zero or more whitespace chars
        .   # followed by any char except \n
        \w+ # followed by one or more word chars
        $   # to the end of the string
    /x;

That's not what you want.  Try this.

    s/
        ^       # Anchored at beginning of the string
        [\s.,]+ # one or more whitespace, '.' or ',' chars
    //x;	# replace with nothing

: What would be the new re it is substituted with?
: Something like '/^\w+$'? (but it isn't working,'w+' gets
: substituted).

The second half of the s/// operator is a string, not a regular
expression.  You will suffer greatly until you absorb this. :)

: 2)Remove any space(s) between a word and a punctuation. e.g. 'word  
: ,' becomes
:  'word,'. 
: 
: I think the re '/\w*\s+\[\.\,]/ would match the pattern.

Nope.

    m/
        \w* # zero or more word chars
        \s+ # followed by one or more whitespace chars
        \[  # followed by a '['
        \.  # followed by a '.'
        \,  # followed by a ','
        ]   # followed by a ']'
     /x;

This is more what you what.

    s/
        (\w)    # word character
        \s+     # followed by one or more whitespace chars
        ([.,])  # followed by a '.' or a ','
    /$1$2/gx;   # leave out the whitespace

: 3)Wherever a pattern a punctuation with a word (e.g.',word' where
: 'word' is any sequcence of letters) exists, add a space immediately
: after the punctuation, so
: ',word' becomes ', word'. 
: 
: I think the re '/.\[\,\.]\w*$/' matches this kind of pattern.

Missed again.

    m/
        .   # any char except \n
        \[  # followed by a '['
        \,  # followed by a ','
        \.  # followed by a '.'
        ]   # followed by a ']'
        \w* # followed by zero or more word chars
        $   # to the end of the string
    /x;

Try this instead.

    s/
        ([.,])  # a '.' or ','
        (\w)    # followed by a word char
    /$1 $2/gx;  # put a space between them

: 4)
: Print lines of the texts of at most 70 characters to the standard
: output, so that no word is split in the middle at the 70th place on
: each line.

See if the Text::Wrap module can get you there before trying to roll your
own code.



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

Date: Sat, 30 Nov 2002 17:55:36 -0500
From: "Alex K. Angelopoulos" <aka@mvps.org>
Subject: Re: win32
Message-Id: <asbfla$pqr15$1@ID-136433.news.dfncis.de>

"Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in message
news:as7sit$7lt$1@korweta.task.gda.pl...
> In article <AwKF9.762$361.442@nwrddc04.gnilink.net>, Kris Carlson
> wrote:
> > Hi,
> >
> > Are there shortcomings to learning perl on win32 systems (my system at
> > home)?

> Yes - you have to use Windows.

ROFLMAO!!!

Ok, but at least perl is a "transferable" skill...<g>




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

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.  

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


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