[24897] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7149 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 16 18:11:47 2004

Date: Thu, 16 Sep 2004 15:10:14 -0700 (PDT)
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, 16 Sep 2004     Volume: 10 Number: 7149

Today's topics:
        Locate last populated row/column in Excel with Win32::O <mrichardson@transim.com>
    Re: Replacing Ampertsand in cgi url <Joe.Smith@inwap.com>
    Re: script portability problem <nospamplease@cinci-solutions.com>
    Re: script portability problem <ceo@nospan.on.net>
    Re: script portability problem <matternc@comcast.net>
    Re: Why this Regex not working? <jgibson@mail.arc.nasa.gov>
    Re: Why this Regex not working? <daveandniki@ntlworld.com>
    Re: Why this Regex not working? <pinyaj@rpi.edu>
    Re: Why this Regex not working? <mark.clements@kcl.ac.uk>
    Re: Xah Lee's Unixism <firstname@lastname.pr1v.n0>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 16 Sep 2004 11:34:57 -0700
From: "mrichardson" <mrichardson@transim.com>
Subject: Locate last populated row/column in Excel with Win32::OLE
Message-Id: <cicmch$29a@odak26.prod.google.com>

Hello,

I'm working on a Perl script that needs to locate the last populated
row/column in an Excel sheet. I have tried the following:

my $TransCharWSLastRow = $TransCharWS->UsedRange->Find({What=>"*",
SearchDirection=>xlPrevious, SearchOrder=>xlByRows})->{Row};
my $TransCharWSLastCol = $TransCharWS->UsedRange->Find({What=>"*",
SearchDirection=>xlPrevious, SearchOrder=>xlByColumns})->{Column};

However, both lines return "902" which doesn't seem especially useful.
I'd be willing to wade through some documentation if anyone can point
me in the right direction.

Thanks,
Matt



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

Date: Thu, 16 Sep 2004 20:05:31 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Replacing Ampertsand in cgi url
Message-Id: <fmm2d.101360$3l3.47384@attbi_s03>

Alan J. Flavell wrote:

> On Wed, 8 Sep 2004, Joe Smith wrote:
>
>>"cgi-bin/test.cgi?var1=1&var=2" should remain as is,
> 
> No! - making the obvious assumptions about context, if this variant is 
> used then the query string in the "URI attribute value" should read 
> var1=1&amp;var=2 , or its equivalent (&#38;).  See:
> 
>  http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.2

Good reference.  Thanks.
	-Joe



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

Date: Thu, 16 Sep 2004 14:39:59 -0400
From: John Davison <nospamplease@cinci-solutions.com>
Subject: Re: script portability problem
Message-Id: <10kjng0pc7oc731@corp.supernews.com>

develop@gistenson.com wrote:
> Hi,
> 
> At the beginning of each perl c         giscriptisthe#!line.I'massumingthat
> this is an http directive that executes perl and indicates thedirectory in 
> which perl is found.
> 
> I'm developing scripts for a client. The problem is that he is using a 
> different web host than I am, and perl is found in different directories, 
> so I need to use different #! directives at the beginning of the scripts.
> 
> I don't want to have to change the scripts when I move them from my host 
> to the client's host. Is there a '#if' '#else' type of directive pair, and 
> if there is, what is the syntax and what test could I use to have the 
> script know whether it's running on my host or the client's host? 
> (Possibly the environment, $ENV{'???'}.)
> 
> Is there another way to accomplish this?
> 
> Thanks,
> Dan
> 

If your script is called foo.pl, then instead of running
 ./foo.pl
or
foo.pl

run this instead
perl foo.pl

Works as long as perl is in the $PATH.

-john


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

Date: Thu, 16 Sep 2004 18:43:40 GMT
From: Chris <ceo@nospan.on.net>
Subject: Re: script portability problem
Message-Id: <w9l2d.3046$Qv5.2420@newssvr33.news.prodigy.com>

develop@gistenson.com wrote:
> Hi,
> 
> At the beginning of each perl cgi script is the #! line. I'm assuming that 
> this is an http directive that executes perl and indicates thedirectory in 
> which perl is found.

Negative, Space Ranger...  It's called a she-bang path for Unix scripts. 
  It tells the command shell what executable to use to execute the 
script.  Has nothing to do with HTTP.

> I'm developing scripts for a client. The problem is that he is using a 
> different web host than I am, and perl is found in different directories, 
> so I need to use different #! directives at the beginning of the scripts.
> 
> I don't want to have to change the scripts when I move them from my host 
> to the client's host. Is there a '#if' '#else' type of directive pair, and 
> if there is, what is the syntax and what test could I use to have the 
> script know whether it's running on my host or the client's host? 
> (Possibly the environment, $ENV{'???'}.)
> 
> Is there another way to accomplish this?

Create a soft link on your development machine that matches the she-bang 
  you will use on your target machine.  For example, if Perl is found in 
/usr/local/bin on the target machine but in /usr/bin on your development 
machine, place a softlink on your development machine to match it.  Then 
use that she-bang line in your scripts:

$ ln -sn /usr/bin/perl /usr/local/bin/perl

In file:

#!/usr/local/bin/perl
$|++;

use strict;
use warnings qw( all );
#...etc...

__END__

-ceo


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

Date: Thu, 16 Sep 2004 16:51:14 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: script portability problem
Message-Id: <C46dnaIyAO5ZYdTcRVn-ow@comcast.com>

Chris wrote:

> develop@gistenson.com wrote:
>> Hi,
>> 
>> At the beginning of each perl cgi script is the #! line. I'm assuming
>> that this is an http directive that executes perl and indicates
>> thedirectory in which perl is found.
> 
> Negative, Space Ranger...  It's called a she-bang path for Unix scripts.
>   It tells the command shell what executable to use to execute the
> script.  Has nothing to do with HTTP.
> 
Incorrect, my prince.  She-bang talks direct to the kernel when the kernel
attempts to load the file for execution.  This means, for example, that
she-bang scripts work right when you exec() them, which doesn't involve
the shell at all (as the exec(3) man page explains, as a matter of fact).

-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: Thu, 16 Sep 2004 11:10:22 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Why this Regex not working?
Message-Id: <160920041110224981%jgibson@mail.arc.nasa.gov>

In article
<rni2d.18368$Q7D.5528@twister01.bloor.is.net.cable.rogers.com>, Looking
<adsense@whitehouse.com> wrote:

> > Looking wrote:

[attempt at using regexs snipped]

> > Mark Clements wrote:
> > You may want to check out HTTP::Headers rather than doing this yourself.
> >
> 
> If you mean HTML::HeadParser
> I tried it and it is not working!.
> 
> That is the sample it gave:
>  $h = HTTP::Headers->new;
>  $p = HTML::HeadParser->new($h);
>  $p->parse(<<EOT);
>  <title>Stupid example</title>
>  <base href="http://www.linpro.no/lwp/";>
>  Normal text starts here.
>  EOT
>  undef $p;
>  print $h->title;   # should print "Stupid example"
> 
> I tried to use $h->description, it does not return anything. I am trying to
> get keywords, description etc, but got nothing.
> If you know where the bugs are, let me know.

Try this, which uses HTML::Headparser:

#!/usr/local/bin/perl

use strict;
require HTML::HeadParser;

my $header = <<EOT
<title>Stupid example</title>
<base href="http://www.linpro.no/lwp/";>
Normal text starts here.
EOT
;

my $p = HTML::HeadParser->new;
$p->parse($header);
print "Title: ", $p->header('Title'), "\n";


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

Date: Thu, 16 Sep 2004 18:10:50 GMT
From: "Dave" <daveandniki@ntlworld.com>
Subject: Re: Why this Regex not working?
Message-Id: <KGk2d.519$JJ1.116@newsfe6-gui.ntli.net>


"Looking" <adsense@whitehouse.com> wrote in message
news:Qxa2d.2507$RTE1.503@news01.bloor.is.net.cable.rogers.com...
> $s='sadf content= "this is what i want " asd " sdf " adfa  " sdf';
> $s =~ s/.*content=.*?["|'](.*)?["|'].*/$1/si;
> #$s =~ s/.*content=.*?["|']([^"|']*)["|'].*/$1/si;
> print "$s\n";
>
> The scond regex works. I wonder why the first regex not working?
> I am trying to get whatever is between the first pair of "" or '' after
> content=. It is parsing the header file of HTML pages.
>
> The first regex gave me this:
>  "this is what i want " asd " sdf " adfa
>
> But I need this:
> this is what i want
>
>

The other answers are better but the minimum change to your code that would
work is:

$s =~ s/.*content=.*?["|'](.*?)["|'].*/$1/si;

for the reasons explained by the others.




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

Date: Thu, 16 Sep 2004 14:26:27 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: Why this Regex not working?
Message-Id: <Pine.SGI.3.96.1040916142517.52118A-100000@vcmr-64.server.rpi.edu>

On Thu, 16 Sep 2004, Mark Clements wrote:

>For the record, \1 is a backreference ie it refers to a previously 
>matched and captured part of the regexp.
>
>so
>
>(["'])([^\1]*)[\1]
>
>matches " or ', followed by any character other than these zero or more 
>times, followed by whichever of " and ' was matched the first time.

No it doesn't.  Character classes are created when the regex is compiled,
but \1 is not known until the regex is EXECUTED.  Using \1 inside a
character class is that same as using \x01 or \001, it's the ASCII
character whose ordinal value is 1.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
  Senior Dean, Fall 2004    %  have long ago been overpaid?
RPI Corporation Secretary   %
http://japhy.perlmonk.org/  %    -- Meister Eckhart




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

Date: Thu, 16 Sep 2004 21:29:01 +0200
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: Why this Regex not working?
Message-Id: <4149e97d$1@news.kcl.ac.uk>

Jeff 'japhy' Pinyan wrote:
> On Thu, 16 Sep 2004, Mark Clements wrote:
>>For the record, \1 is a backreference ie it refers to a previously 
>>matched and captured part of the regexp.
>>
>>so
>>
>>(["'])([^\1]*)[\1]
>>
>>matches " or ', followed by any character other than these zero or more 
>>times, followed by whichever of " and ' was matched the first time.
> 
> 
> No it doesn't.  Character classes are created when the regex is compiled,
> but \1 is not known until the regex is EXECUTED.  Using \1 inside a
> character class is that same as using \x01 or \001, it's the ASCII
> character whose ordinal value is 1.
Thanks - serves me right for not having the good sense to run the code 
in order to check, and I didn't know that about character classes.

Mark


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

Date: Thu, 16 Sep 2004 20:30:18 GMT
From: Morten Reistad <firstname@lastname.pr1v.n0>
Subject: Re: Xah Lee's Unixism
Message-Id: <sircic.6932.ln@via.reistad.priv.no>

In article <4149B516.17F7F078@yahoo.com>,
CBFalconer  <cbfalconer@worldnet.att.net> wrote:
>Chuck Dillon wrote:
>> 
>... snip ...
>> 
>> Going into Iraq was IMHO justified without consideration of 9/11
>> or the war on terror.  Setting up a more democratic and educated
>> Afghanistan and Iraq blows a big whole in Islam's isolation
>> efforts and forces them to deal with the reality of the 21st
>> century.  The process will be bumpy but we can no longer be
>> patient when the mainstream of Islam allow violence on the scale
>> of 9/11 or beyond to occur.
>
>I disagree.  Afghanistan, yes.  Chasing Bin Laden, yes.  They were
>the direct cause of 9/11 (which was not a unique occurance, except
>in degree).  Iraq, no.  That was the descendent of "avenge
>disrespect to Daddy" syndrome, and has been shown to have no
>connection with either 9/11 nor with WMDs.  

The adversary is easy to describe, if not to find. He (and almost
certainly he is male) is strongly idelogical and religous; and
can be very patient. The ideology far transcends the national part.

This fits Afghanistan like a glove. It fits Sudan and the (now
expelled) Yemenis. It fits a lot of Pakistan; and almost all of Iran.

Saddam however was a "dictator classic". His system looked
more like a South American strongman like Stroessner than 
Al-Quada. So does the Assad family in Syria, and Ghadaffi's; and
Burma. Even North Korea may have slid into this camp.

Pakistan, Algeria and Lebanon have had lethal fights between the
"dictator classics" and the islamic revolutionaries. None look
very appealing; but at least the "dc" does not send bombs to
the west as long as we keep shipping the caviar. 

On another note we have three countries spiralling into
internal destruction so fast they may implode alltogether. They
are Sudan, North Korea and Turkmenistan. 

As the US Army seems to have enourmous problems in Iraq, rapidly
becoming another Vietnam in scale, up to ten other spots may
require a rapid reaction force. 

We europeans have better saddle up; the US is going to be so
bogged down they will be stuck.

>The whole business has effectively ended the punishment phase of
>9/11 and justified it in the minds of many Moslems.  For a short
>while there was an opportunity to do an exemplary job in
>Afghanistan and show the Islamic world the possibilities.  That
>has been thrown away by our Glorious Inept Leaders.

I don't lament that so much. It is impossible to satisfy people
that have decided otherwise, and Afghanistan was going to be a tough
one anyhow. 

But I am a lot more worried that the western alliance is unable to
project power even against a militarily beaten people like Iraq. 

-- mrr


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

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


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