[24900] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7150 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 17 03:06:45 2004

Date: Fri, 17 Sep 2004 00:05:15 -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           Fri, 17 Sep 2004     Volume: 10 Number: 7150

Today's topics:
    Re: $| (undocumented) magic? (krakle)
    Re: Can you break Google's secret? <tassilo.von.parseval@rwth-aachen.de>
    Re: CGI.pm textfield problem drove me crazy (wana)
    Re: Extracting bitmap from Excel using Win32::OLE <brian_helterline@hp.com>
        How can I measure web hits from my web browser/end user (Chris Nelson)
    Re: How can I measure web hits from my web browser/end  (Malcolm Dew-Jones)
    Re: hv_iterinit has side effects - who cares about PL t (Ozgun Erdogan)
    Re: hv_iterinit has side effects - who cares about PL t <tassilo.von.parseval@rwth-aachen.de>
    Re: hv_iterinit has side effects - who cares about PL t <joe+usenet@sunstarsys.com>
    Re: Is my algorithm wrong? <dwall@fastmail.fm>
    Re: killing a "nobody's" process and its group <1usa@llenroc.ude.invalid>
    Re: Locate last populated row/column in Excel with Win3 <brian_helterline@hp.com>
        multiple assignments with a HoHoA <matrix_calling@yahoo.dot.com>
    Re: multiple assignments with a HoHoA <noreply@gunnar.cc>
    Re: multiple assignments with a HoHoA <mark.clements@kcl.ac.uk>
    Re: newbie question (krakle)
        perl in crontab <sonet.all@msa.hinet.net>
    Re: perl in crontab <sholden@flexal.cs.usyd.edu.au>
    Re: script portability problem <ceo@nospam.on.net>
    Re: script portability problem (Andres Monroy-Hernandez)
    Re: Why this Regex not working? <someone@example.com>
    Re: Why this Regex not working? <pinyaj@rpi.edu>
    Re: Why this Regex not working? <someone@example.com>
    Re: Xah Lee's Unixism <proto@panix.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 16 Sep 2004 21:48:53 -0700
From: krakle@visto.com (krakle)
Subject: Re: $| (undocumented) magic?
Message-Id: <237aaff8.0409162048.612d57b1@posting.google.com>

Michele Dondi <bik.mido@tiscalinet.it> wrote in message news:<ecvjk09um3jll6gi82pmnug1qegeuo2q23@4ax.com>...
> On 16 Sep 2004 09:16:49 -0700, krakle@visto.com (krakle) wrote:
> 
> >> > They're just jealous because they can't write any valid Python program 
>                                                              ^^^^^^
>                                                              ^^^^^^
> 
> >> > in just four lines (/me ducks and runs for cover).
> >> Well we can't write _any_ valid program in four lines
> >
> >#!/usr/bin/perl -w
> >print "What's your name?";
> >my $name = <STDIN>;
> >print "Hi $name I just wanted to show you a valid Perl program in 4
> >lines. Isnt this valid?\n";
> 
> It seems you don't waste your time with JAPHs, because you only spend
> your efforts in "productive code"

My point: Programs can be written in 4 lines of code. The rest of your
post was ignored.


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

Date: Fri, 17 Sep 2004 06:51:29 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: Can you break Google's secret?
Message-Id: <2qv8qkF142jlvU1@uni-berlin.de>

Also sprach Looking:

> The most successful search engine's secret algorithm can be calculated from
> a sandbox/blackbox detection. Assuming we already know the secret, can you
> write the code with it?
> 
> Case 1, especially for news.google.com, Google compares two documents in
> stripped text format, and see how much of them in common. If they share 90%
> similar things, then they are talking about the same thing.
> here is the algorithm A, break down each document into key phrases and
> keywords, ignore the most common ones, then compare the array of keywords
> from both documents.
> algorithm B is simpler, compare two documents as whole. Currently I am
> trying to study how to complete the algorithm and codes for B.

Easy:

    print "Similar" if $text1 eq $text2;

Is that what you meant with 'compare two documents as whole'?

> For B, here is a test case, can you write a perl code for that? Just
> comparing two strings, rather than long documents. Sudocodes are welcomed
                                                     ^^^^^^^^^
What's that? Code for the superuser?

> too. Here is the sample input string.

[...]

This group isn't meant as a place to discharge your quizzes of the week.
Have you tried anything so far yourself?

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 16 Sep 2004 18:26:09 -0700
From: ioneabu@yahoo.com (wana)
Subject: Re: CGI.pm textfield problem drove me crazy
Message-Id: <bf0b47ca.0409161726.5a3c6a9e@posting.google.com>

ctcgag@hotmail.com wrote in message news:<20040916133501.923$yq@newsreader.com>...
> 
> > I had to put in -force=>1 for it to work.  Is
> > that normal?
> 
> Yes.  Without 'force' or some equivalent, when CGI regenerates the same
> form that was just submitted, it uses the values that that parameter
> currently has (i.e. It only uses your default value if there is no already
> existing value in that parameter).
> 
> As an alternative to using force, you could just set the parameter to what
> you want to be sometime before you print the form element:
> 
> param('chicken',$a);
> 
> Xho

Thanks!  I like your way better than mine.  Sorry about the oversized
example.  I trimmed it:

#!/usr/bin/perl 
use CGI ':standard';
$a = "";
if (param)
{
        $a = param('cow');
}
print header;
print start_html, start_form,
textfield({-name=>'cow'}),
textfield({-name=>'chicken',-value=>$a,-force=>1}),
,submit({-name=>'enter'}), end_form,end_html;


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

Date: Thu, 16 Sep 2004 15:55:50 -0700
From: "Brian Helterline" <brian_helterline@hp.com>
Subject: Re: Extracting bitmap from Excel using Win32::OLE
Message-Id: <414a1a87@usenet01.boi.hp.com>


"aminnis" <alanminnis@yahoo.com> wrote in message
news:eaef7f31.0409151440.7bcfa5e@posting.google.com...
> Hello all,
>
> Does anyone know how to extract a bitmap from a cell using win32::OLE
> and save it to a file?  Any help is appreciated.
>
> Alan

Bitmaps are not in cells, they are on the "Shapes" layer within Excel.
my $bitmap = $excel->ActiveSheet->Shapes(1);
or if you want to limit the search to the selection,
my $bitmap = $excel->ActiveSheet->Selection->Shapes(1);

Then you have to
$bitmap->Copy;

to place it on the clipboard, and

use Win32::Clipboard

to retrieve it and write it to file (using binmode)

--
-brian




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

Date: 16 Sep 2004 19:36:02 -0700
From: fimafeng@yahoo.com (Chris Nelson)
Subject: How can I measure web hits from my web browser/end user perspective....?
Message-Id: <919f1ca2.0409161836.3502177f@posting.google.com>

Hello:
I know that for a web server..... there are many ways to measure the
"hits", when accessing a web page. However, what I need to be able to
do... is determine that when downloading a web page.... how many
"hits" comprise that web page.(From an end user perspective)

Am I correct in that an accurate # of hits representing a web page
could be determined by viewing the source of a web page and adding up
the files that are listed in that code? Is there a piece of
code/software that does this?

Basically, 
I have a situation where I need to demonstrate to semi-technical
people that a single web page can be comprised of many hits. (And in
my case more importantly..... hits do not in any way directly
correlate to time spent an individual web page and or site.

Any help would be greatly appreciated.


Chris


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

Date: 16 Sep 2004 21:30:36 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: How can I measure web hits from my web browser/end user perspective....?
Message-Id: <414a686c@news.victoria.tc.ca>

Chris Nelson (fimafeng@yahoo.com) wrote:
: Hello:
: I know that for a web server..... there are many ways to measure the
: "hits", when accessing a web page. However, what I need to be able to
: do... is determine that when downloading a web page.... how many
: "hits" comprise that web page.(From an end user perspective)

: Am I correct in that an accurate # of hits representing a web page
: could be determined by viewing the source of a web page and adding up
: the files that are listed in that code? Is there a piece of
: code/software that does this?

: Basically, 
: I have a situation where I need to demonstrate to semi-technical
: people that a single web page can be comprised of many hits. (And in
: my case more importantly..... hits do not in any way directly
: correlate to time spent an individual web page and or site.

: Any help would be greatly appreciated.


The above shows a great deal of confusion in your mind about web pages.  
By "semi-technical people" perhaps you mean yourself.

That would explain why you posted this question in a perl group, instead 
of in some group dedicated to web page issues.

However, with that excuse in mind, and guessing somewhat about what you
really mean, perhaps you mean that you think that the contents displayed
in the window of a web browser might sometimes require more than one file
to be downloaded from the web.  That is true.

To display what looks like a single "web page" will commonly require
downloading multiple files.  Perhaps the most notable situation is that
each picture in a web page requires its own file, so if a web page shows
two pictures then there are at least three downloads - the html file, plus
two picture files.

As for "time spent", and again I am guessing what it is you are really
trying to ask, no, the time spent looking at a web page has nothing to do
with any of the above.


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

Date: 16 Sep 2004 21:29:34 -0700
From: ozgune@gmail.com (Ozgun Erdogan)
Subject: Re: hv_iterinit has side effects - who cares about PL theory
Message-Id: <48b43181.0409162029.1a39bcbf@posting.google.com>

> perl isn't threaded, so the relevance of T1/T2 escapes me.
> Have you considered rewriting whatever it is you're doing 
> around a breadth-first search instead of a depth-first one?

That may fix it too. I re-implemented hv_iterinit/hv_iternext, and
that seemed to solve the problem for me.

I brought up the T1/T2 point just to make the distinction between
reads/writes clearer. I can see that the iterator is within the hash
structure to make lazy deletion possible. I can also see that somebody
made the decision based on that.

However, this decision poses some strong limitations on concurrent
programming in Perl, and makes primitive data types in Perl "very out
of the ordinary" - from a PL design perspective (yup, I'm repeating
myself).

As for Xho's post, I've never said "everybody should want this", there
is a fine line between C/Java and Perl, and this is one of those
features that draws the line.


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

Date: Fri, 17 Sep 2004 06:44:24 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: hv_iterinit has side effects - who cares about PL theory
Message-Id: <2qv8daF14b43vU1@uni-berlin.de>

Also sprach ctcgag@hotmail.com:

> ozgune@gmail.com (Ozgun Erdogan) wrote:

>> Thanks for backing me up Xho. That's what I was trying to say the
>> whole thread. If I want to do a hash read from the beginning, why
>> would I need to call init (change) the hash structure, right? Take
>> init out of the picture in T1/T2, and you'd get completely
>> non-deterministic behavior.
> 
> I didn't know I was backing you up!  It doesn't sound like you want to do
> a simple hash read, it sounds like you want to do a hash iteration, which
> is different.  It seems to me that you are insisting a hash iteration is
> (or should be) a simple read, but obviously it is no such thing.  (As
> evidenced by the fact that you need to call init in your pseudocode).
> 
> If you say "I want an iterator separate from the hash itself", well, I
> can't disagree with that.  You want what you want.  Maybe you want to use
> some other language.  That's also fine.  But you seem to be saying
> "Everyone else should want that too."  Well, we don't.

Also, there is keys() which is a simple way to iterate over a hash
without requiring any state.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 17 Sep 2004 01:17:05 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: hv_iterinit has side effects - who cares about PL theory
Message-Id: <87wtytiiem.fsf@gemini.sunstarsys.com>

ozgune@gmail.com (Ozgun Erdogan) writes:

> > perl isn't threaded, so the relevance of T1/T2 escapes me.
> > Have you considered rewriting whatever it is you're doing 
> > around a breadth-first search instead of a depth-first one?
> 
> That may fix it too. I re-implemented hv_iterinit/hv_iternext, and
> that seemed to solve the problem for me.

Hmm, I'm wondering whether there's a simpler way...
Looking at a 5.8.x implementation of hv_iterinit:

==================================================
I32
Perl_hv_iterinit(pTHX_ HV *hv)
{
    register XPVHV* xhv;
    HE *entry;

    if (!hv)
	Perl_croak(aTHX_ "Bad hash");
    xhv = (XPVHV*)SvANY(hv);
    entry = xhv->xhv_eiter; /* HvEITER(hv) */
    if (entry && HvLAZYDEL(hv)) {	/* was deleted earlier? */
	HvLAZYDEL_off(hv);
	hv_free_ent(hv, entry);
    }
    xhv->xhv_riter = -1; 	/* HvRITER(hv) = -1 */
    xhv->xhv_eiter = Null(HE*); /* HvEITER(hv) = Null(HE*) */
    /* used to be xhv->xhv_fill before 5.004_65 */
    return XHvTOTALKEYS(xhv);
}
==================================================

I'm pretty sure that the iterator's entire state is managed by
xhv_riter and xhv_eiter.  By copying those to automatic C variables 
before doing any recursive calls, and then restoring those values 
when control is returned, you should be able to patch
Data::Structure::Util to get it working.  You may need to muck 
with HvLAZYDEL before restoring, but that seems relatively 
staightforward.

I suspect you tried this already, so I'm wondering what
sort of problems you encountered.


> I brought up the T1/T2 point just to make the distinction between
> reads/writes clearer. I can see that the iterator is within the hash
> structure to make lazy deletion possible.

Personally I don't think lazy deletion is much of a big deal.
IMO the iterator belongs in the hash because you can't
implement Perl's C<each %foo> without associating an iterator
to the hash itself.  If you don't think it belongs in the
struct, where else would you put it?

-- 
Joe Schaefer


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

Date: Thu, 16 Sep 2004 22:20:49 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: Is my algorithm wrong?
Message-Id: <Xns9566BAA262B36dkwwashere@216.168.3.30>

Looking <adsense@whitehouse.com> wrote:

>> Quick and dirty:
>>
>>     my $string = 'something at least twenty-five characters
>>     long'; my ($part1, $part2) = $string =~
>>     /^(.{1,23}\S)\s(.*)/s; 
>>
>> Ideally you should check to see if the match succeeded.
>>
>> I do hope this isn't homework.
>>
> 
> it is not a homework. it is a feature i am adding to a site.

OK. No offense meant.

> your works except in the case that there is no space in the first
> 25. my codes have problems too.

I didn't think of that. (Obviously.)
 
> thundergnat's solution works perfect. 

Yeah, I like it. Looks a bit like the code in Text::Wrap, but I'd 
guess he/she came up with it independently.

Just to redeem myself a little, here's a slightly altered version of 
the single regex solution. (Although I suspect there's a more 
succinct way to express it.)


my $string = 'thisistheoriginalstringblahblahblah';

my ($part1, $part2) = grep defined, 
    $string =~ /^
                (?:  (.{1,24}\S) \s  (.*)  )
                |
                (?:  (.{1,24}\S) \s? (.*)  )
               /sx;


Oh, and I changed it to grab at most 25 characters, not 24; at first 
I just saw the text that said "less than 25 characters", that is, 
< 25, not <= 25.  <shrug>



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

Date: 16 Sep 2004 23:38:57 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: killing a "nobody's" process and its group
Message-Id: <Xns9566C7E38F1ACasu1cornelledu@132.236.56.8>

Henry Law <lawshouse.public@btconnect.com> wrote in
news:vrsjk0tf8oeg9gq545seg7n8ibk4qrk740@4ax.com: 

> On 16 Sep 2004 13:01:13 GMT, "A. Sinan Unur"
> <1usa@llenroc.ude.invalid> wrote:
> 
>>Henry Law <lawshouse.public@btconnect.com> wrote in
>>news:k19dk0tuu9a5mr2m6qv13tedmidarbpotg@4ax.com: 
>>
> 
>>You misquoted. The OP's original sentence was:
> 
> Copied directly from your post.  Our respective newsreaders have
> folded the lines in different places.

Now you are lying. My original post contained full quote of what I was
referring to as 'gibberish'. I would like to know if that passage does
not match the following definition: 

Webster's Revised Unabridged Dictionary
Gibberish n. [From {Gibber}, v. i.] Rapid and inarticulate talk;
unintelligible language; 

> What if the text that the chap wrote *is* the best he's capable of?
> How about if he taught himself English from reading, cigarette
> packets, say? Could be a pretty impressive achievement and worthy of
> our respect. We just don't know.

Ah, the soft-bigotry of lowered expactations ... In any case, you must
have very, very interesting cigarette packets in England for you to have
been able to imagine such a thing possible. OTOH, if performing such a
feat does not accomplish the underlying purpose of using language, i.e.
getting others to understand you, it is pretty useless no matter how
impressive. 

> Perhaps because of your own achievement you have less patience with 
> others who haven't reached the same standard?

Whatever my achievement might be, it did not happen overnight. It also
could not have happened if no one ever pointed out my errors.
Elsethread, in response to Sherm, I had already said: 

<blockquote>
It would have been (better) if I had mentioned that I was not sure if I
understood the question, and given an answer with that disclaimer
attached rather than just calling it gibberish. Apologies to the OP.
</blockquote>

almost a day before you called me "unkind". Now, I know news propagation 
takes but had you really not seen that before attacking me?

>>On the other hand, I do not remember the OP mentioning anything about 
>>Apache.
> 
> Copied from the original post:
>>thanks!
>>Federico
>>(I'm using Mac OsX with apache2 server)

I just did not notice that probably because it was under the his name. 
Sorry.

I thought I had laid my part in this thread to rest and will do for real 
this time. 

-- 
A. Sinan Unur
1usa@llenroc.ude.invalid 
(remove '.invalid' and reverse each component for email address)



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

Date: Thu, 16 Sep 2004 15:12:28 -0700
From: "Brian Helterline" <brian_helterline@hp.com>
Subject: Re: Locate last populated row/column in Excel with Win32::OLE
Message-Id: <414a105c$1@usenet01.boi.hp.com>

"mrichardson" <mrichardson@transim.com> wrote in message
news: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};

It seems to work for me.

Other Ideas:

If you know that your UsedRange is completely populated, then you can
count the number of rows and columns to figure out the last cell.

# untested
my $used = $TransCharWS->UsedRange;
my $rows = $used->Rows->Count;
my $cols = $used->Columns->Count;
my $last = $used->Cells( $rows, $cols );

If this isn't a safe assumption (I would guess it is not), but you know
all the data is continuous, then you can select the beginning of the
UsedRange and scroll down and over to the last populated cell (like hitting
END+DOWN-ARROW, etc.

#again, untested
my $used = $TransCharWS->UsedRange->Cells( 1, 1 ); # first cell is active
$used = $used->End(xlDown);    # last row
$used = $used->End(xlToRight);    # last column of last row

>
> However, both lines return "902" which doesn't seem especially useful.

Can't reproduce this

> I'd be willing to wade through some documentation if anyone can point
> me in the right direction.
>
> Thanks,
> Matt
>





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

Date: Fri, 17 Sep 2004 11:49:59 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: multiple assignments with a HoHoA
Message-Id: <htv2d.227$Sp5.35@news.oracle.com>

Hi,

I have a hash variable, %table, which I populate as

my %table;
$table{'A'}{'B'}=['C','D','E'];

I now do

my $val1;
my $val2;
my $val2;

This :

($val1, $val2, $val3) = $table{'A'}{'B'}; #causes $val1, $val2 to
be undef, 					  #$val3 = ARRAYREF

However, this :

$val1 =  $table{'A'}{'B'}[0];
$val2 =  $table{'A'}{'B'}[1];
$val3 =  $table{'A'}{'B'}[2];   # Does the Right Thing.

Could someone point out what silly mistake I am committing in the 1st case, 
and how to rectify it ?


Thanks

Abhinav


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

Date: Fri, 17 Sep 2004 08:50:02 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: multiple assignments with a HoHoA
Message-Id: <2qvfqiF143p7iU1@uni-berlin.de>

Abhinav wrote:
> I have a hash variable, %table, which I populate as
> 
> my %table;
> $table{'A'}{'B'}=['C','D','E'];
> 
> I now do
> 
> my $val1;
> my $val2;
> my $val2;
> 
> This :
> 
> ($val1, $val2, $val3) = $table{'A'}{'B'}; #causes $val1, $val2 to
> be undef,                       #$val3 = ARRAYREF

Suppose you mean that $val1 is assigned the array reference, not $val3.

<snip>

> Could someone point out what silly mistake I am committing in the 1st 
> case,

You don't dereference your array reference.

> and how to rectify it ?

Dereference your array reference.

     perldoc perlreftut

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Fri, 17 Sep 2004 08:51:19 +0200
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: multiple assignments with a HoHoA
Message-Id: <414a8968$1@news.kcl.ac.uk>

Abhinav wrote:

> I have a hash variable, %table, which I populate as
> 
> my %table;
> $table{'A'}{'B'}=['C','D','E'];

OK: this is actually syntactic sugar for

$table{A}->{B} = [ 'C', 'D', 'E'];
# note you'd probably use qw here instead ie [qw( C D E )]

this sets $table{A}->{B} to be an arrayref

Perl allows you to specify multiple dereferences without the ->, 
supposedly to make it easier to read

ie

$table{A}{B}{C} is the same as $table{A}->{B}->{C} but not the same as 
$table->{A}->{B}->{C}.

> ($val1, $val2, $val3) = $table{'A'}{'B'}; #causes $val1, $val2 to
> be undef,                       #$val3 = ARRAYREF
it should set $val1 *not* $val3: $table{A}->{B} is a scalar value ie an 
arrayref, so the right-hand side only returns one value, which is 
assigned to the first item in the list on the lhs.

> 
> However, this :
> 
> $val1 =  $table{'A'}{'B'}[0];
> $val2 =  $table{'A'}{'B'}[1];
> $val3 =  $table{'A'}{'B'}[2];   # Does the Right Thing.
syntactic sugar is coming into play again.

$val1 = $table->{A}->{B}->[0];

and so on.


> Could someone point out what silly mistake I am committing in the 1st 
> case, and how to rectify it ?
Not silly so much as missing some of the subtleties of perl data 
structures - you need to check out

man perldsc

Mark


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

Date: 16 Sep 2004 21:52:38 -0700
From: krakle@visto.com (krakle)
Subject: Re: newbie question
Message-Id: <237aaff8.0409162052.3542bfa8@posting.google.com>

Sherm Pendley <spamtrap@dot-app.org> wrote in message news:<cYGdnbPtpc8GUdTcRVn-gg@adelphia.com>...
> krakle wrote:
> 
> >>>#!/usr/bin/perl -w
> >>>print "Content-type: text/html\n\n";
> >>>print "Perl works\n";
> > 
> > No.. I meant just as I said text/html... Because don't you want the
> > browser to parse and read HTML to form a web page?
> 
> Parse and read *what* HTML? Your output here is a single line of plain 
> text, and the correct MIME type for that is text/plain.

I disagree. I believe the original poster wanted to form a web page
with HTML output and only used a non-html output as a test. Just
because my output didn't consist of Html tags doesn't mean the content
should be text/plain unless I wanted it to view as a plantext file in
the browser. In this case, I wanted it to view as text/html but didn't
bother typing out any html tags for example since it would be
irrelevant (Perl group remember...)...


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

Date: Fri, 17 Sep 2004 10:28:42 +0800
From: "news.hinet.net" <sonet.all@msa.hinet.net>
Subject: perl in crontab
Message-Id: <cidi5b$acf$1@netnews.hinet.net>

This test can work when i run it anywhere.
But the chdir seem does not work when i set it in crontab??
==============================================
#!/usr/bin/perl

chdir("/usr/local/admin/dir");
system("tar zcvf test.tgz *");




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

Date: 17 Sep 2004 02:58:34 GMT
From: Sam Holden <sholden@flexal.cs.usyd.edu.au>
Subject: Re: perl in crontab
Message-Id: <slrnckkkmq.akh.sholden@flexal.cs.usyd.edu.au>

On Fri, 17 Sep 2004 10:28:42 +0800,
	news.hinet.net <sonet.all@msa.hinet.net> wrote:
> This test can work when i run it anywhere.
> But the chdir seem does not work when i set it in crontab??
>==============================================
> #!/usr/bin/perl
>
> chdir("/usr/local/admin/dir");
> system("tar zcvf test.tgz *");

So test the return value and report the failure including the
error message:

chdir("/usr/local/admin/dir") or die "chdir failed: $!";
system("tar zcvf test.tgz *")==0 or die "system failed: $!";


-- 
Sam Holden


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

Date: Thu, 16 Sep 2004 23:50:28 GMT
From: ChrisO <ceo@nospam.on.net>
Subject: Re: script portability problem
Message-Id: <8Fp2d.3148$Qv5.1402@newssvr33.news.prodigy.com>

Chris Mattern wrote:
> 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).
> 

I prefer, "Negative, Space Ranger..." :-)  Thanks for the correction.

-ceo


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

Date: 16 Sep 2004 17:13:01 -0700
From: andres@monroy.com (Andres Monroy-Hernandez)
Subject: Re: script portability problem
Message-Id: <3591b31a.0409161613.1b78d087@posting.google.com>

What about creating a script that changes the shebang line? You would
run this script once you move the scripts to the customer's server.
I've had experienced the same issue and that's what I did.

The script could be something like this:

------ shebang.pl--------------
use File::Find;
my ($dir) = @ARGV;
print "Replacing for files under '$dir'.\n";
find(\&callback, $dir);
exit;

sub callback {
    my $namepath = $File::Find::name;
    my $name = $_;

    # replace shebang only in .pl files
    return unless ($name =~ /\.pl$/); {
    print "Couldn't open '$name' for reading purposes\n" unless (-w
$name);
    replace($name);
}

sub replace{
    my ($fn) = @_;
    open(F, "+< $fn")       or die "can't read $fn: $!";
    my $out = '';
    $out .= "#!/customer/she/bang/perl\n";
    while (<F>) {
        next if /^\s*#\/yourshebang$/; 
        $out .= $_;
    }
    seek(F, 0, 0)               or die "can't seek to start of $fn:
$!";
    print F $out                or die "can't print to $fn: $!";
    truncate(F, tell(F))        or die "can't truncate $fn: $!";
    close(F)                    or die "can't close $fn: $!";
}
-----------------------------------------

Then you will run it like this:
perl shebang.pl /the/dir/where/scripts/are/


Regards,
---
-Andrés Monroy-Hernández


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

Date: Fri, 17 Sep 2004 01:00:09 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Why this Regex not working?
Message-Id: <tGq2d.37164$KU5.35406@edtnps89>

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.

Oops, don't you hate it when that happens.  ;-)
So how come you can put a variable in a character class and have it work at 
run-time?


John
-- 
use Perl;
program
fulfillment


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

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

On Fri, 17 Sep 2004, John W. Krahn wrote:

>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.
>
>Oops, don't you hate it when that happens.  ;-)
>So how come you can put a variable in a character class and have it work at 
>run-time?

Because when a variable is in a regex, the regex can't be compiled until
run-time[1].  That "law" just doesn't hold for backreferences.

[1] thus the existence of the /o switch which quells more than one
compilation of a regex with variables in it

--
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: Fri, 17 Sep 2004 01:20:43 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Why this Regex not working?
Message-Id: <LZq2d.37178$KU5.12532@edtnps89>

Looking wrote:
>>>$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?
>>
>>That is because *, + and ? are greedy and will match as many characters as
>>possible so (.*) will match everything to the end until the last ", | or '
>>character.  (Why are you trying to match the | character?)  You probably
>>want something like:
>>
>>$s =~ s/.*content=.*?(["'])([^\1]*)[\1].*/$2/si;
> 
> By the way, I assume \1 is same as $1 but on the left side. Your code is not
> working. It does not match anything. Although, I think your idea is right
> 
> $s=qq( "sadf content= "this is what i' want " asd " sdf " adfa  " sdf' );
> #$s =~ s/.*content=.*?["'](.*?)["'].*/$1/si;
> $s =~ s/.*content=.*?(["'])([^\1]*)[\1].*/$2/si;
> print "$s\n";
> 
> I hope it can return
> this is what i' want
> but yours return
> "sadf content= "this is what i' want " asd " sdf " adfa  " sdf'
> so, no match.

Yes, as "Japhy" has pointed out, \1 won't work inside of a character class. 
This should work a lot better.  :-)

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



John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 17 Sep 2004 00:19:24 -0400
From: Walter Bushell <proto@panix.com>
Subject: Re: Xah Lee's Unixism
Message-Id: <proto-49B8AF.00192417092004@reader1.panix.com>

In article <tqmisaoiuc6.fsf@drizzle.com>,
 Patrick Scheible <kkt@drizzle.com> wrote:

> jmfbahciv@aol.com writes:
> 
> > It's apparently having the desired effect.  The subject of
> > the radio talk show last night was about the results of a poll
> > where 41% of the people asked (New York state residents) believed 
> > that Bush and Co. knew that the WTC was going to be attacked and 
> > did nothing to prevent it.
> 
> They can have a nice chat with the 40-some-odd percent of the people
> who think Saddam was working with al-Qaida...
> 
> -- Patrick

Does this come before or after the debate between the born again 
evangelicals and the Hari Krisnas?

-- 
Guns don't kill people; automobiles kill people.


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

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


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