[29061] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 305 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 5 09:10:17 2007

Date: Thu, 5 Apr 2007 06:09:08 -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, 5 Apr 2007     Volume: 11 Number: 305

Today's topics:
    Re: CGI "working" message/page ? <spamtrap@dot-app.org>
    Re: CGI "working" message/page ? <news@lawshouse.org>
    Re: Generating serial numbers <rvtol+news@isolution.nl>
    Re: Generating serial numbers <scobloke2@infotop.co.uk>
        How to Optimize the Pattern Matching search m.muthukareem@gmail.com
    Re: How to resolve funky sync issues with fork here. <hjp-usenet2@hjp.at>
    Re: How to run Perl script as GUI Windows program? Like carl.hafner@gmail.com
    Re: Looking for a Perl or (similar) type of script to p <scobloke2@infotop.co.uk>
        mod_perl 2.0 book <bol@adv.magwien.gv.at>
        perl hash - creation by side effect? <bugbear@trim_papermule.co.uk_trim>
    Re: perl hash - creation by side effect? <bugbear@trim_papermule.co.uk_trim>
    Re: perl hash - creation by side effect? <bugbear@trim_papermule.co.uk_trim>
    Re: perl hash - creation by side effect? <wahab-mail@gmx.de>
    Re: perl hash - creation by side effect? <spamtrap@dot-app.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 05 Apr 2007 06:22:39 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: CGI "working" message/page ?
Message-Id: <m21wiz3yts.fsf@local.wv-www.com>

- Bob - <uctraing@ultranet.com> writes:

> On 05 Apr 2007 00:56:21 GMT, xhoster@gmail.com wrote:
>
>>Myself, I just use the <meta http-equiv="refresh" ....> tag.  Sloppy though
>>some people may find it, it gets the job done.
>
> What does the refresh do?

The same thing it does if it's produced by Python, Ruby, or included in a
static .html file.

Remember what I said about Perl questions and non-Perl questions earlier?

> Keep polling a program / data area looking
> for some "program completed" data bit left by the process you are
> waiting to have completed?

That's the idea, yes. If you have a Perl question, for example if you're
having trouble implementing such a process, feel free to ask it.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Thu, 05 Apr 2007 13:34:09 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: CGI "working" message/page ?
Message-Id: <1175776417.51293.0@iris.uk.clara.net>

- Bob - wrote:

> What does the refresh do? 

A little advice.  You could have answered that question yourself, so 
asking it here looks like laziness.  The clever Perl people (i.e. not 
me) are really clever, but also really busy, and laziness isn't attractive.

And if you'd answered the question you'd also have found the other 
aspect, which is that "refresh" has nothing to do with Perl (and 
everything to do with HTML and how browsers handle it), so there'd be no 
point in posting it here anyway.

Read this; it will help: http://www.catb.org/~esr/faqs/smart-questions.html

-- 

Henry Law            Manchester, England


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

Date: Thu, 5 Apr 2007 10:36:39 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Generating serial numbers
Message-Id: <ev2jo5.1a4.1@news.isolution.nl>

xhoster@gmail.com schreef:

> If I want some kind of timestamp built into the file name, then I use
> the above (down to the second) and append the pid to it.  I rather
> doubt your system pid will wrap around within one second.

pids aren't handed out sequentially anymore on securer systems. 

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: Thu, 05 Apr 2007 11:20:25 +0100
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Generating serial numbers
Message-Id: <4614cd6f$0$21834$db0fefd9@news.zen.co.uk>

Ian Wilson wrote:
> I have a Perl CGI application that handles transactions, writing data to 
> a temporary file. I need to keep the data files for a few weeks and so 
> need to allocate unique names to them.

<snip>

Many thanks to Jürgen, David, Brian, Ted, Randal, krakle, Xho, Dr.Ruud 
and anyone else whose message I haven't yet seen.

A very useful set of responses!


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

Date: 5 Apr 2007 04:58:16 -0700
From: m.muthukareem@gmail.com
Subject: How to Optimize the Pattern Matching search
Message-Id: <1175774296.950570.102810@o5g2000hsb.googlegroups.com>

Hi

 Sub: I need an idea about, To optimize the search of function
declaration present in two different source.


 I have collected the function declarations from c program headers on
two different operating system. Now, i have to    look for absence of
all functions declaration in any given application w.r.t. other
operating system. The major issue is  once an function declaration is
fetched from application, we need to search in entire input file for
the absence of similar function. The process repeats for other
functions declaration recursively by reading the same input file from
top to bottom. So Could any of you give proper suggestion on how to
optimize the search.



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

Date: Thu, 5 Apr 2007 15:05:03 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: How to resolve funky sync issues with fork here.
Message-Id: <slrnf19svv.cdt.hjp-usenet2@yoyo.hjp.at>

["Followup-To:" header set to comp.lang.perl.misc.]
On 2007-04-04 12:22, Lew Pitcher <lpitcher@sympatico.ca> wrote:
> On Apr 3, 9:27 pm, "grocery_stocker" <cdal...@gmail.com> wrote:
>> Here is a copy a persons code I saw on a blog. The only difference
>> here is that I enable warnings use my().
>>
>> #!/usr/bin/perl -w
>>
>> my @array = qw(ugh geeze blah test smith bob homes point);
>>
>> my $num = "10";
>>
>> for(1..$num) {
>>     my $pid = fork();
>>     if ($pid) {
>>     # parent
>>         push(@childs, $pid);
>>     } elsif ($pid == 0) {
>>     # child
>>         print "@array\n\n";
>>         sleep 5;
>>         exit(0);
>>     } else {
>>         die "couldn't fork: $!\n";
>>     }
>>     print "BEFORE FOR BRACKET\n";
>>
>> }
>>
>> print "AFTER FOR BRACKET\n";
>>
>> foreach (@childs) {
>>     waitpid($_, 0);
>>
>> }
>>
>> And here is what I get when I run it a few times...
> [snip]
>> [cdalten@localhost perl]$ ./par.pl
[...]
>> BEFORE FOR BRACKET
>> BEFORE FOR BRACKET
>> ugh geeze blah test smith bob homes point
>>
>> ugh geeze blah test smith bob homes point
>
> I presume that the above apparent out-of-order results is what you are
> concerned about?
[...]
>> How would I get them in sync?
>> Would I have to insert another wait() into the child? Just need some ideas
>> here.
>
> Move your waitpid() call so that it executes immediately prior to
> your
>  print "BEFORE FOR BRACKET\n";
> statement. This way, the parent will wait for the child to complete
> (and thus write the array) before it proceeds to generate the BEFORE
> FOR BRACKET line.

If you do that, what's the point of forking in the first place?

	hp


-- 
   _  | Peter J. Holzer    | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR       | to write clearly is like blaming English for
| |   | hjp@hjp.at         | the circumlocutions of bureaucrats.
__/   | http://www.hjp.at/ |	-- Charlton Wilbur in clpm


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

Date: 5 Apr 2007 05:25:42 -0700
From: carl.hafner@gmail.com
Subject: Re: How to run Perl script as GUI Windows program? Like Word, Notepad, Calculator etc.
Message-Id: <1175775942.350894.247490@p77g2000hsh.googlegroups.com>

If you're looking for a simple start:


$picture_count = 0;
opendir(PICDIR,'C:\XX\My Pictures');

while(readdir(PICDIR))
   { $picture_count++; }

closedir(PICDIR);
$picture_count = $picture_count - 3;

use Tk;
$main = MainWindow->new();
$main->Label(-text => $picture_count)->pack;
MainLoop;




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

Date: Thu, 05 Apr 2007 11:50:14 +0100
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Looking for a Perl or (similar) type of script to parse XML files for errors
Message-Id: <4614d46d$0$6943$fa0fcedb@news.zen.co.uk>

Will wrote:
> On Apr 4, 5:43 pm, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> 
>> On 4 Apr 2007 13:27:38 -0700, WBi...@gmail.com wrote:
>> 
>>> I'm looking for a Perl script ( or assistance on how to write
>>> one) 

It is my experience that, in this newsgroup, you are far more likely to 
receive the latter than the former. The more effort you make in writing 
some Perl, the more help you will get. Have a go.

>> 
>> http://groups.google.com/group/comp.lang.perl.misc/search?q=parse+xml...
>> 

Here Michele is pointing out that you can use Google to search for prior
discussion of this subject. Many people tire of repeating the same 
advice over and over and over again.

The general answer to "how do I parse XML" is "Use a Perl module
designed for that purpose". You can find them in CPAN.

>> 
>>> Does anyone have something similar that I could use as a base? I 
>>> realize that grep will do some of this but it's a little more 
>>> difficult to parse given the length of the java error messages.
>> 
>> java?!?
>> 
>> Michele -- {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map
>> substr (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB=' 
>> .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_, 
>> 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Newsgroup tradition is to omit sigs from the text you are quoting.


> 
> The app. was written in Java and produces an error file/log w/ the 
> error messages and the XML data section applied to it.

Care to post a small sample?


> I'm not a java guy but are you asking if java is the way to go here?
> Thanks
> 

My interpretation is that Michele was puzzled by your mention of Java.
It is likely that the programming language (used to create the program
that wrote the log) is irrelevant to your problem.

You probably could use Java to do what you want but if you're interested
in so doing you should take the question to a Java newsgroup.


Summary:
Use Google groups to search for prior discussion.
Look in CPAN for a module to parse XML.
Post a small sample of what you want to parse.


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

Date: Thu, 5 Apr 2007 09:47:46 +0200
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: mod_perl 2.0 book
Message-Id: <1175759266.893261@proxy.dienste.wien.at>

Hi @ all,

Can someone point me to a good book about mod_perl 2.0?

I think of somewhat like the "Eagle Book", but unfortunately,
this is very old (1999) and covers Apache 1.3 & mod_perl 1.0
only.

MTIA and kind greetings from Vienna,

Ferry

-- 
Ing Ferry Bolhar
Magistrat der Stadt Wien - MA 14
A-1010 Wien
E-Mail: bol@adv.magwien.gv.at




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

Date: Thu, 05 Apr 2007 11:30:06 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: perl hash - creation by side effect?
Message-Id: <4614cfaf$0$8755$ed2619ec@ptn-nntp-reader02.plus.net>

I'm sure I've seen a reference to this, but I couldn't
find it in the manuals or on line

#!/usr/bin/perl

use strict;
use Data::Dumper;

my $s = {};
my $i = $s->{f};
print Dumper($s->{f});
my $j = $s->{f}->{i};
print Dumper($s->{f});

The output is:
$VAR1 = undef;
$VAR1 = {};

It appears that the assignment to $j has a side
effect of creating a 'f' member of $s; this f has
a value of reference to an empty hash.

Advice, references etc welcome as usual.

(I originally fell across this in a module/object
project - accessing a field-of-a-field caused
the "field" to exist as an empty hash, causing
trouble a little later)

   BugBear


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

Date: Thu, 05 Apr 2007 11:37:00 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: perl hash - creation by side effect?
Message-Id: <4614d14c$0$8755$ed2619ec@ptn-nntp-reader02.plus.net>

bugbear wrote:
> I'm sure I've seen a reference to this, but I couldn't
> find it in the manuals or on line
> 
> #!/usr/bin/perl
> 
> use strict;
> use Data::Dumper;
> 
> my $s = {};
> my $i = $s->{f};
> print Dumper($s->{f});
> my $j = $s->{f}->{i};
> print Dumper($s->{f});
> 
> The output is:
> $VAR1 = undef;
> $VAR1 = {};
> 
> It appears that the assignment to $j has a side
> effect of creating a 'f' member of $s; this f has
> a value of reference to an empty hash.

Finally found it;

Programming Perl, 3rd edition, 8.2.6
8.2.6. Implicit Creation of References

A final method for creating references is not really a method
at all. References of an appropriate type simply spring into
existence if you dereference them in an lvalue context that
assumes they exist. This is extremely useful, and is also
What You Expect. This topic is covered later in this chapter,
where we'll discuss how to dereference all of the references
we've created so far.


   BugBear


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

Date: Thu, 05 Apr 2007 11:49:27 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: perl hash - creation by side effect?
Message-Id: <4614d437$0$8725$ed2619ec@ptn-nntp-reader02.plus.net>

Sigh - knowing the answer makes finding the answer easy:

If only I'd searched for "autovivification"
I'd have known what was happenening :-)

http://sysarch.com/Perl/autoviv.txt

   BugBear


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

Date: Thu, 05 Apr 2007 13:22:18 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: perl hash - creation by side effect?
Message-Id: <ev2mfs$if7$1@mlucom4.urz.uni-halle.de>

bugbear wrote:
> Sigh - knowing the answer makes finding the answer easy:
> 
> If only I'd searched for "autovivification"
> I'd have known what was happenening :-)
> 
> http://sysarch.com/Perl/autoviv.txt

Good, you found that!

I'd like to make one short remark. You
used Data::Dumper, which is o.k. Another
'Dumper', which I prefer for things like
this, is the 'Dumpvalue', e.g.:

   ...
   use Dumpvalue;
   sub DUMP { print Dumpvalue->new()->dumpValue($_[0]) }

   my $s = {};           DUMP $s;
   my $i = $s->{f};      DUMP $i;
                         DUMP $s;
   my $j = $s->{f}->{i}; DUMP $j;
                         DUMP $s;
   $s->{f}->{i} = 3;     DUMP $s->{f}->{i};
                         DUMP $s;
   ...

Regards
M.


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

Date: Thu, 05 Apr 2007 08:02:53 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: perl hash - creation by side effect?
Message-Id: <m2bqi32fma.fsf@local.wv-www.com>

bugbear <bugbear@trim_papermule.co.uk_trim> writes:

> I'm sure I've seen a reference to this, but I couldn't
> find it in the manuals or on line
>
> #!/usr/bin/perl
>
> use strict;
> use Data::Dumper;
>
> my $s = {};
> my $i = $s->{f};
> print Dumper($s->{f});
> my $j = $s->{f}->{i};
> print Dumper($s->{f});
>
> The output is:
> $VAR1 = undef;
> $VAR1 = {};
>
> It appears that the assignment to $j has a side
> effect of creating a 'f' member of $s;

That's not a side effect of the assignment, it's a side effect of accessing
a member of the 'f' hashref. References on the left of a -> are automatically
defined, to allow the lookup on the right to be performed.

In this case, an anonymous hash is created and a reference to it stored
in $s->{f}, so that the key {i} can be searched for.

> Advice, references etc welcome as usual.

This process is called "autovivification". It's discussed in:

    perldoc perlreftut
    perldoc perlref

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

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 V11 Issue 305
**************************************


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