[23946] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6147 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 17 14:05:56 2004

Date: Tue, 17 Feb 2004 11:05:08 -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           Tue, 17 Feb 2004     Volume: 10 Number: 6147

Today's topics:
        CGi parameters lost <damu@wharton.upenn.edu>
    Re: do not reload  <glex_nospam@qwest.invalid>
    Re: do not reload  (Malcolm Dew-Jones)
    Re: do not reload <jwillmore@remove.adelphia.net>
    Re: do not reload <trammell+usenet@hypersloth.invalid>
    Re: do not reload (Malcolm Dew-Jones)
    Re: do not reload <flavell@ph.gla.ac.uk>
    Re: Example of web application done right? thumb_42@yahoo.com
    Re: generate a list of file extensions? <me@privacy.net>
    Re: hidden perl <peter@nospam.calweb.com>
    Re: how to start thread in thread <pawo2000@wp.pl>
    Re: how to start thread in thread <usenet@morrow.me.uk>
    Re: how to start thread in thread <pawo2000@wp.pl>
    Re: if for... <nobull@mail.com>
    Re: open pipe vs signals causing problems ? <nobull@mail.com>
    Re: Perl memory allocation ctcgag@hotmail.com
        Prob Perl/Tk <orion93@club-internet.fr>
    Re: Problem with Perl/Tk <orion93@club-internet.fr>
    Re: RDBMS to hold Perl objects? thumb_42@yahoo.com
        Reading & Posting Usenet News Messages <ignoromnibus@cochon.fr>
    Re: Reading & Posting Usenet News Messages <ittyspam@yahoo.com>
    Re: Threadsafe writing to files <ThomasKratz@REMOVEwebCAPS.de>
    Re: When i try to implement a server program giving UDP <dont@spam.please>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 17 Feb 2004 12:39:49 -0500
From: "Damu Zhang" <damu@wharton.upenn.edu>
Subject: CGi parameters lost
Message-Id: <c0tjl7$6u1m$1@netnews.upenn.edu>

We are having a CGI issue, our clients send parameters via form POST, but
sporadically the values turn be to empty, and it happened all of sunden
since early last week. Anyone has the same issue?





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

Date: Tue, 17 Feb 2004 10:06:50 -0600
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: do not reload 
Message-Id: <v_qYb.344$f55.28465@news.uswest.net>

anonymous@coolgroups.com wrote:
> Ok, maybe I wasn't clear about the issue since nobody 
> answered the question.  Basically, I want the browser to 
> use a CACHED copy of a page if the person goes back to it.  
> Specifically, if you go to http://www.coolgroups.com, view 
> a message, and then click BACK, I don't want it to reload 
> the message listing from the server. 

What does this have to do with perl???.. Try one of the CGI/HTTP newsgroups.


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

Date: 17 Feb 2004 09:04:07 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: do not reload 
Message-Id: <40324987@news.victoria.tc.ca>

J. Gleixner (glex_nospam@qwest.invalid) wrote:
: anonymous@coolgroups.com wrote:
: > Ok, maybe I wasn't clear about the issue since nobody 
: > answered the question.  Basically, I want the browser to 
: > use a CACHED copy of a page if the person goes back to it.  
: > Specifically, if you go to http://www.coolgroups.com, view 

coolgroups - hardly a cool site - pop up haven, javascripted links, slow
response, browser death, i'm not sure you have to worry about people using
the BACK button at all.

If a page reloads it is probably due to javascripted links not being 
cached - $0.02.


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

Date: Tue, 17 Feb 2004 11:07:59 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: do not reload
Message-Id: <pan.2004.02.17.16.07.58.248275@remove.adelphia.net>

On Tue, 17 Feb 2004 16:04:27 +0000, anonymous wrote:

> Ok, maybe I wasn't clear about the issue since nobody 
> answered the question.  Basically, I want the browser to 
> use a CACHED copy of a page if the person goes back to it.  
> Specifically, if you go to http://www.coolgroups.com, view 
> a message, and then click BACK, I don't want it to reload 
> the message listing from the server.

No one answered your question because it's not specific to Perl :-)  It
has more to do with using HTTP headers and maybe JavaScript.

There are ways to approach this using Perl, but the question, IMHO, has a
lot more to do with understanding HTTP than it does with using Perl.

There *is* a CGI newsgroup that you could post this question to - and may
get more responses.

Try comp.infosystems.www.authoring.cgi as the newsgroup.

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Necessity is a mother. 




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

Date: Tue, 17 Feb 2004 16:15:38 +0000 (UTC)
From: "John J. Trammell" <trammell+usenet@hypersloth.invalid>
Subject: Re: do not reload
Message-Id: <slrnc34fha.8mj.trammell+usenet@hypersloth.el-swifto.com.invalid>

On Tue, 17 Feb 2004 16:04:27 GMT, anonymous@coolgroups.com
<anonymous@coolgroups.com> wrote:
> Ok, maybe I wasn't clear about the issue since nobody 
> answered the question.  Basically, I want the browser to 
> use a CACHED copy of a page if the person goes back to it.  
> Specifically, if you go to http://www.coolgroups.com, view 
> a message, and then click BACK, I don't want it to reload 
> the message listing from the server. 

Is the browser written in Perl?  Otherwise it's not a
Perl question.



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

Date: 17 Feb 2004 08:55:51 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: do not reload
Message-Id: <40324797@news.victoria.tc.ca>

anonymous@coolgroups.com wrote:
: How do I make sure that a perl CGI page doesn't get reloaded
: when the user hits the back button and goes to it?  I've
: tried outputting the "Expires" header, but that doesn't seem
: to do the trick.

Don't use POST.  Always use GET if possible.  The browser interactions are
more polite for the user, and the semantics of POST cannot be trusted to
work correctly when you need them anyway.



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

Date: Tue, 17 Feb 2004 18:14:43 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: do not reload
Message-Id: <Pine.LNX.4.53.0402171810570.28351@ppepc56.ph.gla.ac.uk>

On Tue, 17 Feb 2004, Malcolm Dew-Jones wrote:

> Don't use POST.  Always use GET if possible.

If this was a CGI group, I'd go into detail about why I thought that
was poor advice in the form in which it's offered.  There sure can be
situations where it's the right answer; but to offer it as a general
rule seems to provoke far more problems than it could possibly solve.

sorry.



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

Date: Tue, 17 Feb 2004 18:45:01 GMT
From: thumb_42@yahoo.com
Subject: Re: Example of web application done right?
Message-Id: <NitYb.207019$U%5.1139528@attbi_s03>

Simon McCaughey <simonmcc@nortelnetworks.com> wrote:
> 
> <thumb_42@yahoo.com> wrote in message
> news:iySXb.43206$_44.39503@attbi_s52...
> 
> <snip>
> 
>> As far as the web front.. I would really not recommend perl for this
> 
> What would you recommend? and what did you use?

We used perl, and regretted it for the web interface.

I might go with java servlets if I were to do it again, or try and find a
way to get PHP to do it. mod_perl wasn't very stable IMO.

> Did you manage without session data? or how did you handle this problem?

No.. the sessions were a constant struggle. Here is how it was supposed to 
work (as I recall):

Session ID was a string that contained info about which machine it was on.

If Session ID is from another machine, fetch session across network
and make it local, use new session ID. 

Our web server load balancing was done by DNS, and, thankfully most browsers
didn't rotate the IP, so we didn't have to copy the session across very often,
when we did, it usually worked but on occassion it dropped them on the
floor. :-(

I much perfer the way Apache + tomcat handle the problem, even if you use
perl to do the web interface, it's a technique that is worth looking at.

Basically the way they do it is the web server is like a proxy that forwards
the HTTP request to whoever is responsible for that that session ID. I
suppose we could have used this approach in our code as well but didn't
think of it then. :-)

It's kind of a matter of cost -vs- cost of failure type of problem. It's a
hassle, but not a complete outage because (ideally) the (current_users /
(number of servers - 1) ) are unaffected by it, and anyway, affected users
could restart their session. Considering most of your "heavy lifting" is
done on a backend server, taking a web server down is relatively rare anyway
so this isn't that huge of a concern. If you were a stock broker it might be
though. (in that case you should probably have dedicated servers that do
nothing but manage sessions)

The most important part of doing large-scale web applications (IMO) is
preparing for the maintenance issues, second is hardware failures. Ideally,
you can work it out so that any machine can be taken out with minimal
or no impact.

A big part of that was dynamic configuration, when you take a machine out or
add a new one in, all the other machines need to know about it. We "abused"
an LDAP server for this purpose. Using LDAP was overkill, but we could take
a backend out of the loop, wait for it to finish what it was doing then stop
it, perform an upgrade, start it, and tell the other machines about it
via LDAP. (repeat process foreach backend until everything is updated) This
was actually kind of cool because it meant we didn't have to login to each
machine to update it's config. :-)

By keeping as much logic as possible outside of the web space and on 
back-end(s), most maintenance was handled 100% transparently.

Jamie







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

Date: Tue, 17 Feb 2004 08:44:30 -0800
From: "davido@codethought.nospamforme.com" <me@privacy.net>
Subject: Re: generate a list of file extensions?
Message-Id: <57h430p5ntdv1t7imqb96180uhrm9hff3v@4ax.com>

On Tue, 17 Feb 2004 15:44:09 +0000, Paul Cooper
<paul.cooper@Nobasspam.ac.uk> wrote:

>Not so. The excellent Cygwin software provides most of the Unix
>utilities in a Win32 environment.

Cygwin is not an option.




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

Date: Tue, 17 Feb 2004 10:18:00 -0800
From: Penguinista <peter@nospam.calweb.com>
Subject: Re: hidden perl
Message-Id: <40325884$0$68961$d368eab@news.calweb.com>

daniel caplan wrote:
> sorry if this is in the wrong newsgroup.  am not a perl programmer, so am
> not sure under what heading to put this under.  simply put:
> 
> my company has a software (written in perl) that it runs on our internal
> servers (linux).  we would
> like to be able to have 3rd party companies run it, not off of our servers,
> but on their own internals network.  but obviously we don't want them to
> be able to see our source code.
> 
> can i ask what solutions there are?
> 
> are there compilers?  reliable ones?  am sure we are not the first to
> encounter this scenario, so am sure there is a solution.
> 
> many thanks ahead, as always.
> 
> sergio
> 
> 
> 
With the strandard perl hiding the source code just isn't a realistic 
option.

It would be possable to produce a custom processor that loaded and 
decrypted your program before passing it to an embeded perl.  Just keep 
in mind that the embeded perl would need to be statically linked or 
another route for getting at your 'valuable' source code exists.



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

Date: Tue, 17 Feb 2004 17:07:51 +0100
From: "pawo" <pawo2000@wp.pl>
Subject: Re: how to start thread in thread
Message-Id: <c0te9v$a4c$1@atlantis.news.tpi.pl>


>
> You do realise that OO and threads are not the same thing at all?
>
Yes, of course. I just planed to do some encapsulation of threads within
separate object.
A base class could have the following thread function:
sub _threadfunc {
  my $obj = shift;
  if(1 == ($obj->init_th())) {
    $obj->run_th();
    $obj->finish_th();
  }
  $obj->close_th();
}
and all the inheriting calsses would overwrite init_th, run_th, finish_th,
etc.... methods.
That's all.I'm not sure whether fork-based threads could be encapsuletaed
into separate object as well as the above example
:-) Until now i didn't think about that.

>
> FWIW, on my system (linux 2.4.20, glibc 2.3.2, perl 5.8.2) I get large
> numbers of both 1s and @s, until I press return when it prints
>
> FINISHED
> A thread exited while 3 threads were running, <> line 1.
>
> as expected. I suspect you have a synchronisation problem: likely, for
> some reason the first thread is sitting in the <> doing nowt: does Win32
> suffer from the 'one thread blocking blocks all threads' problem?
>
> Ben
>

That is what I wanted to know. As I suspected the perl threads under win32
are a bit unpredictable.
THX




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

Date: Tue, 17 Feb 2004 16:50:38 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: how to start thread in thread
Message-Id: <c0tgou$a76$1@wisteria.csv.warwick.ac.uk>


"pawo" <pawo2000@wp.pl> wrote:
> >
> > You do realise that OO and threads are not the same thing at all?
> >
> Yes, of course. I just planed to do some encapsulation of threads within
> separate object.
> A base class could have the following thread function:
> sub _threadfunc {
>   my $obj = shift;
>   if(1 == ($obj->init_th())) {
>     $obj->run_th();
>     $obj->finish_th();
>   }
>   $obj->close_th();
> }

Presumably you mean something more like:

sub new {
    my $class = shift;
    my $obj   = $class->init(@_);
    my $tid   = async { 
        $obj->set_tid(threads->self);
        my $rv = $obj->run;
        $obj->finish;
        return $rv;
    };
    $obj->set_tid($tid);
    return $obj;
}

sub join {
    my $obj = shift;
    my $tid = $obj->get_tid;
    $tid == threads->self and die "can't join myself!";
    my $rv = $tid->join;
    $obj->finish;
    return $rv;
}

, since you end up with two separate threads of control?

> and all the inheriting calsses would overwrite init_th, run_th, finish_th,
> etc.... methods.
> That's all.I'm not sure whether fork-based threads could be encapsuletaed
> into separate object as well as the above example

'fork-based threads' are more commonly known as 'processes' :). Yes, of
course you can:

sub new {
    my $class = shift;
    my $obj   = $class->init(@_);
    my $pid = fork;
    defined $pid or die "fork failed: $!";
    unless ($pid) {
        $obj->set_pid($$);
        my $rv = obj->run;
        $obj->finish;
        exit $rv;
    }
    $obj->set_pid($pid);
    return $obj;
}

sub wait {
    my $obj = shift;
    my $pid = $obj->get_pid;
    $pid == $$            and die "can't wait on myself!";
    -1 != waitpid $pid, 0 or  die "no such child: $pid";
    $obj->finish;
    return $? >> 8; # see the documentation for $?
}

You can only return an 8-bit integer, of course, which may be a
problem... if you need more, see forks.pm from CPAN, which provides the
threads api using fork and sockets.

> That is what I wanted to know. As I suspected the perl threads under win32
> are a bit unpredictable.

I suspect that you would have fewer problems with a less pathological
example (those while(1) loops are nasty...). You may find you have to
use non-blocking IO to get things to play nicely, which rather takes
away the point of threading...

I take it you know that fork is implemented with threads on Win32?

Ben

-- 
Musica Dei donum optimi, trahit homines, trahit deos.    |
Musica truces molit animos, tristesque mentes erigit.    |   ben@morrow.me.uk
Musica vel ipsas arbores et horridas movet feras.        |


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

Date: Tue, 17 Feb 2004 18:28:14 +0100
From: "pawo" <pawo2000@wp.pl>
Subject: Re: how to start thread in thread
Message-Id: <c0tj3r$1f9$1@nemesis.news.tpi.pl>


> Presumably you mean something more like:
>
> sub new {
>     my $class = shift;
>     my $obj   = $class->init(@_);
>     my $tid   = async {
>         $obj->set_tid(threads->self);
>         my $rv = $obj->run;
>         $obj->finish;
>         return $rv;
>     };
>     $obj->set_tid($tid);
>     return $obj;
> }
>
 ............
 ............
> You can only return an 8-bit integer, of course, which may be a
> problem... if you need more, see forks.pm from CPAN, which provides the
> threads api using fork and sockets.
>
> > That is what I wanted to know. As I suspected the perl threads under
win32
> > are a bit unpredictable.
>
> I suspect that you would have fewer problems with a less pathological
> example (those while(1) loops are nasty...). You may find you have to
> use non-blocking IO to get things to play nicely, which rather takes
> away the point of threading...

Yes, you right. As I said it was only for testing purposes, no joins, etc...

> I take it you know that fork is implemented with threads on Win32?
>
No, I didn't know that. And the threads on win32 are bugged, great.
I'll tryto run something similar to your examples.

Thank you for the introduction about perl threads. :-)

--
pawo
[spadam bo za duzo gadam]




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

Date: 17 Feb 2004 18:26:45 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: if for...
Message-Id: <u9ptcdh89m.fsf@wcl-l.bham.ac.uk>

ajs@ajs.com (Aaron Sherman) writes:

> Brian McCauley <nobull@mail.com> wrote
> 
> > > So, you have to restrict for to a single instance,
> > 
> > No you don't.
> > 
> > > and that seems non-intuitive to many users
> > 
> > So don't do it.
> 
> So, what this really comes down to is this: people have stated their
> reasons for disagreeing with this idea (as I have) and you disagree
> back. That's fine, but don't discount such disagreement.

I don't "discount disagreement".  I simply assert that you have drawn
an invalid logical inference in your statement "so, you have to...".
If your statement "so, you have to..." was not intended to imply that
you thought you were drawing a logical inference then I'm sorry.

> I don't think you've added anything new to the debate,

If you look back at this thread you'll find I did not attempt to add
anything new to the debate.  I attempted to summarise it for the OP.
You then tried to add something my summary.  I tried to explain how
you had not added anything.  You came back and said that _I_ hadn't
added anything.

> I think postfix loops were a mistake.

I have no problem with that view.  I do not discount it.  What I
object to stongly is people who assert that there's some hard factual
something wrong with _nested_ postfix loops as distinct from there
being something wrong with postfix loops per se.

> And for the record, the p6l discussion is wide open to the public in
> the archives. It raged on for a month or more, so I don't think you'll
> have any trouble finding it.

As I have stated I have found several instansiations. 

> I feel such footnotes to well archived
> information are better than re-posting several megabytes of heated
> conversation....

In general I agree completely.  But now we've got to state
where the vast majority of the discussion that can be found by doing a
search of the archives consists of people saying "don't discuss this
again, search the archives".

> You can find it by searching for "elsunless" ...
> postfix operations, continue blocks, scoping and switch-like uses of
> if/elsif/else were discussed ad nauseum.

I can find only one sizable thread in p6l containing the world
"elsunless" and that was:

http://groups.google.com/groups?threadm=20030120055123.7C89245D%40babylonia.flatirons.org

Can you confirm that that was the one?

I've only skimmed over it so far but I can't really see how it applies
to Perl5.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 17 Feb 2004 18:37:22 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: open pipe vs signals causing problems ?
Message-Id: <u9lln1h7rx.fsf@wcl-l.bham.ac.uk>

a_gilotra@yahoo.com (funtoosh) spits TOFU in my face:

[ TOFU is rude.  Please don't do it.  TOFU corrected ]

> Brian McCauley <nobull@mail.com> wrote in message news:<u9hdxukefn.fsf@wcl-l.bham.ac.uk>...
> > a_gilotra@yahoo.com (funtoosh) writes:
> > 
> > > I am using latest PERL provided with REDHAT 9.
> > 
> > At least show us the first line form "perl -v" and maybe even selected
> > highlights of "perl -V" if you suspect this could be platform-related
> > (and that wouldn't be a ureasonable supposition),
>
> I am using v5.6.1 of Perl on i386 linux. Kernel 2.4.20-20.9 from
> Redhat
> 
> libc-2.2.5.so is installed on my system.

> > > Now, when I send signal SIGTERM to the perl script, it DOES NOT call
> > > the installed handler
> > 
> > Your test script works OK for me on 5.6.1 and 5.8.0 on SuSE Linux
> > (albeit with an old glibc).
> 
> So, when u run this script, it catches the signal and also kills
> anotherProgram too ?

It catches the signal.  There's nothing in the test script to
explicitly kill the other program so I had no way of guessing this was
part of the desired behaviour.  

Did you perhaps mean to send the SIGTERM to a process group rather
than a single process?

Under normal circumstances a child started with a '-|' mode open()
will terminate on a SIGPIPE when the parent closes the FIFO.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 17 Feb 2004 17:05:32 GMT
From: ctcgag@hotmail.com
Subject: Re: Perl memory allocation
Message-Id: <20040217120532.056$vc@newsreader.com>

Ben Morrow <usenet@morrow.me.uk> wrote:
> Eric Bohlman <ebohlman@earthlink.net> wrote:
> > "Ian Cass" <ian.cass@mblox.com> wrote in
> > news:FE4Yb.164$_P.2707686@news-text.cableinet.net:
> > > Eric Bohlman wrote:
> > >>
> > >> perldoc -q free
> > >>
> > >> (the second entry displayed is the one you want)
> > >
> > > My Perl is compiled with the OS's malloc rather than Perls.
> >
> > How is that relevant?
>
> perlfaq3.pod:
> | Some operating systems [...] can reclaim memory that is no longer
> | used, but on such systems, perl must be configured and compiled to use
> | the OS's malloc, not perl's.
>
> was no doubt confusing the OP... the important part is 'Some OSen'.
> Clearly the OP's isn't one of them.
>
> (As an aside, would it be feasible to change perl's malloc to use mmap
> where possible, and release mem back to the OS? This seems to be quite
> often wanted...)

How would it ensure that the entire segment is simultaneously unused
in order to return the underlying memory?  Unless you have one mmap per
variable, it doesn't seem very easy.  I guess you could add syntax to give
hints:

my_big_assed $x = "The quick brown fox jumps over the lazy dog"x10_000;

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: 17 Feb 2004 18:21:11 GMT
From: Orion93 <orion93@club-internet.fr>
Subject: Prob Perl/Tk
Message-Id: <Xns9492C5C48966Aorion93clubinternetf@194.158.96.17>

From the script below I try to make an interface in Perl/Tk to be able to 
choose the repertory directly. The initial script count lines for all pl 
files in one directory.
 
Initial Script:
#!/usr/bin/perl
sub recupPages
{
my $nomFic = shift;
my $result = shift;

# Récupération des lignes du fichier
open(F,$nomFic);
open(SORTIE,">> $result");
$i = 0;
while(<F>)
{
$i ++;
}
print SORTIE " $nomFic $i\n";

close F;
close SORTIE;}

my $emplacement = "e:\\Dossier_travail\\stat\\";
my $ficResultat = "e:\\result.txt";
recupPages($_, $ficResultat) for glob 'e:\\Dossier_travail\\stat\\*.pl';

 
Current script:
 
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use diagnostics;

my $main = MainWindow -> new;
$main -> title("Test 1");
$main -> Label(-text=>"Chemin:")->pack();
$main -> Entry()->pack(-padx=>5);
$main->Button(-text=>'Ok',-command=>\my $recupPages)->pack(-side=>'left', 
expand=>1);
$main->Button(-text=>"Fermer",-command=>sub {exit;})->pack(-side=>'right', 
expand=>1);
MainLoop();

sub recupPages
{
# my $rep= my $resupPages->get();
my $result = shift;
# Récupération des lignes du fichier
open (F,"$recupPages");
open (SORTIE,">> my $result");
my $i = 0;
while(<F>)
{
$i ++;
}
print SORTIE " my $recupPages $i\n";
close F;
close SORTIE;
}
#my $emplacement = @rep;
my $ficResultat = "e:\\result.txt";
recupPages($_, $ficResultat) for glob '$nomFic\*.pl';

I don't understand where are my errors! Please Help me again!



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

Date: 17 Feb 2004 18:20:26 GMT
From: Orion93 <orion93@club-internet.fr>
Subject: Re: Problem with Perl/Tk
Message-Id: <Xns9492C5A438A4Dorion93clubinternetf@194.158.96.17>

Ben Morrow <usenet@morrow.me.uk> wrote in
news:c0r9gi$mqe$1@wisteria.csv.warwick.ac.uk: 

> 
> Orion93 <orion93@club-internet.fr> wrote:
> 
> use strict;
> use warnings;
> 
>> use Tk;
>> 
>> $main = MainWindow -> new;
> 
> my $main = ...;
> 
>> $main->title("Test 1");
>> $libelF=$main->Label(-text=>'Chemin:')->pack();
> 
> my $libelF = ...;
> 
> &c.
> 
>> $montantF->Entry(-textvariable=>\$nomFic)->pack(-padx=>5);
>> $valid=$main->Button(-text=>'Ok',-command=>\&recupPages)->pack(-
>> side=>'left', expand=>1);
> 
> It would be a lot easier to see what is going on if you put some
> whitespace in here; also, you never set $montantF:
> 
> my $nomFic;
> my $montantF = $main->Entry (-textvariable => \$nomFic)
>                     ->pack  (-padx => 5);
> my $valid    = $main->Button(-text => 'Ok', -command => \&recupPages)
>                     ->pack  (-side => 'left', -expand => 1);
> 
> As an aside, I *really* hate apps that call buttons 'Ok': not only is
> it inconsistent with every OS I've ever used, it's also Wrong. It's an
> abbreviation, so it's spelt 'OK'.
> 
>> $end=$main->Button(-text=>'Fermer',-command=>sub {exit})->pack(-
>> side=>'right', expand=>1);
>> MainLoop();
>> 
>> sub recupPages
>> {
>> my $rep= $montantF->get();
>> my $result = shift;
>> open(F,'$nomFic');
>> open(SORTIE,'$result');
> 
> Use lexical filehandles: they close automatically, which makes your
> life easier. Check the return value of open: yes, *every* time. Those
> single quotes won't interpolate, so you're trying to open a file
> called '$nomFic'. You don't need quotes at all.
> 
> open my $F,      $nomFic or die "can't open $nomFic: $!";
> open my $SORTIE, $result or die "can't open $result: $!";
> 
>> $i = 0;
>> while(<F>)
>> {
>> $i ++;
>> }
>> print SORTIE " $nomFic $i\n";
>> close F;
>> close SORTIE;
>> }
> 
> Sort out your indentation: it makes things much easier:
> 
> sub recupPages {
>     my $rep    = $montantF->get();
>     my $result = shift;
> 
> I'm not sure what you think this does, but I doubt it's what you mean.
> Do you not just mean
>     my $result = $montantF->get();
> ? Or, indeed, just use $nomFic, since you've set that up to contain
> the value of the entry box... no, hang on, $nomFic is the input file.
> Where do you want the name of the output file to come from?
> 
>     open my $F...
>     ...
>     while (<$F>) {
>         $i++;
>     }
> 
> Or, neater:
>     $i++ while <$F>;
> 
> Or use $. instead of $i:
>     1 while <$F>;
>     print $SORTIE " $nomFic $.\n";
> See perldoc perlvar.
>     
>     print $SORTIE " $nomFic $i\n";
>     # no need to close the FHs: they will close at the end of the
>     scope. 
> }
> 
>> my $emplacement = $nomFic;
>> my $ficResultat = "e:\\result.txt";
>> recupPages($_, $ficResultat) for glob '$nomFic';
> 
> I'm not sure when you want this to execute, but as things stand it
> won't, ever. MainLoop never returns, so Perl will never get here. If
> you want it to be executed when the OK button is pressed, it needs to
> go inside recupPages; if you want it to be executed at the end of the
> program (ie. when the Fermer button is pressed) it needs to go in an
> END block:
> 
> END {
>     my $emplacement = $nomFic;         # why? you never use this
>     variable. my $ficResultat = 'e:/result.txt'; # yes, use / even on
>     win32 
>     
>     recupPages($_, $ficResultat) for glob $nomFic;
>     # again, the '' quotes won't interpolate the variable.
> }
> 
> I get the feeling you're not entirely clear about what you want this
> program to do... or, at any rate, *I'm* not.
> 
> Ben
> 

From the script below I try to make an interface in Perl/Tk to be able to 
choose the repertory directly. The initial script count lines for all pl 
files in one directory.
 
Initial Script:
#!/usr/bin/perl
sub recupPages
{
my $nomFic = shift;
my $result = shift;

# Récupération des lignes du fichier
open(F,$nomFic);
open(SORTIE,">> $result");
$i = 0;
while(<F>)
{
$i ++;
}
print SORTIE " $nomFic $i\n";

close F;
close SORTIE;}

my $emplacement = "e:\\Dossier_travail\\stat\\";
my $ficResultat = "e:\\result.txt";
recupPages($_, $ficResultat) for glob 'e:\\Dossier_travail\\stat\\*.pl';

 
Current script:
 
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use diagnostics;

my $main = MainWindow -> new;
$main -> title("Test 1");
$main -> Label(-text=>"Chemin:")->pack();
$main -> Entry()->pack(-padx=>5);
$main->Button(-text=>'Ok',-command=>\my $recupPages)->pack(-side=>'left', 
expand=>1);
$main->Button(-text=>"Fermer",-command=>sub {exit;})->pack(-side=>'right', 
expand=>1);
MainLoop();

sub recupPages
{
# my $rep= my $resupPages->get();
my $result = shift;
# Récupération des lignes du fichier
open (F,"$recupPages");
open (SORTIE,">> my $result");
my $i = 0;
while(<F>)
{
$i ++;
}
print SORTIE " my $recupPages $i\n";
close F;
close SORTIE;
}
#my $emplacement = @rep;
my $ficResultat = "e:\\result.txt";
recupPages($_, $ficResultat) for glob '$nomFic\*.pl';

I don't understand where are my errors! Please Help me again!



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

Date: Tue, 17 Feb 2004 16:56:40 GMT
From: thumb_42@yahoo.com
Subject: Re: RDBMS to hold Perl objects?
Message-Id: <cJrYb.338768$xy6.1676500@attbi_s02>

Aaron Sherman <ajs@ajs.com> wrote:
> Robert <bobx@linuxmail.org> wrote in message news:<EPGdnc6NrZvyeb_d4p2dnA@adelphia.com>...
>> Randal L. Schwartz wrote:
>> > If you want a free RDBMS, there's plenty.  I recommend DBD::SQLite as
>> > a serverless solution, or DBD::Pg and PostgreSQL as a proper database.
>> > Stay away from MySQL for new installations, no point in it anymore.
>> > 
>> Simply wrong! Now once PG goes native on Windows THEN I see no point. 
>> Until then MySQL it is. Firebird is looking really good as well. ;-)
> 
> Using google groups, so please understand I would have set a
> followup-to if I could :-(
> 
> MySQL is the easiest database to maintain that I've ever used. It fits
> in with the UNIX Tao quite nicely and manages tables the way a UNIX
> admin would expect.

I'd have to agree with Randall Schwartz on this one. (well, kind of anyhow..)

Postgresql is better as a "proper database". Supports transactions, and as
far as I know, always did. MySQL - maybe it does, maybe it doesn't, you have
to check to be sure.

Transactional support is essential for any serious work.

MySQL is nice when you have data that is almost always read-only, until it
ships with transaction support enabled by default, AND mysql with
transaction support is most common, I don't trust it. (maybe it's changed
some since I last truly explored it)

I'd much perfer mysql for an addressbook, but even a recipe collection could
be riddled with issues, since the ingredients might be relational you could
end up with missing parts. If the application has no real support for adding
recipes, (Ie: it's added once or on occasion from a mirror or something, and
you just need a web query interface then MySQL might be an ideal choice)

Of course, mysql IS more common than postgresql. :-(

Jamie


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

Date: Tue, 17 Feb 2004 11:57:08 -0600
From: Camelback Jones <ignoromnibus@cochon.fr>
Subject: Reading & Posting Usenet News Messages
Message-Id: <c0tks60267p@enews4.newsguy.com>

Yep, that's ol' # 18.4 from O'Reilly's Perl Cookbook. 

It seems to work okay, except that when trying to print the results of, for 
example,

        $bodytext = $server->body($first) or die "aaaargh!!!\n";

all I can get is ARRAY(<some memory address>).

I've tried printing $bodytext[0], it's blank. I've tried a foreach loop, 
also blanks... I'm pretty sure the body isn't really blank, because the 
header does the same thing... No doubt I'm doing something stupid either in 
the retrieval or the print, but I haven't been able to print anything other 
than ARRAY(whatever) or blank...

I know this is ignorance on my part, but I've tried all the examples I can 
find in various "Printing Array Contents" helpful hints, with nothing 
resulting except the same (*&#@$ thing. And it doesn't seem to matter what 
newsgroups I pick - this one, alt.test, alt.conspiracy, rec.woodworking... 
whatever.

Any ideas?


-- 
The greatest unsolved problem in mathematics is why some people are
better at it than others.



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

Date: Tue, 17 Feb 2004 13:50:31 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Reading & Posting Usenet News Messages
Message-Id: <20040217134415.X23965@dishwasher.cs.rpi.edu>

On Tue, 17 Feb 2004, Camelback Jones wrote:

> Yep, that's ol' # 18.4 from O'Reilly's Perl Cookbook.
>
> It seems to work okay, except that when trying to print the results of, for
> example,
>
>         $bodytext = $server->body($first) or die "aaaargh!!!\n";
>
> all I can get is ARRAY(<some memory address>).
>
> I've tried printing $bodytext[0], it's blank. I've tried a foreach loop,
> also blanks... I'm pretty sure the body isn't really blank, because the
> header does the same thing... No doubt I'm doing something stupid either in
> the retrieval or the print, but I haven't been able to print anything other
> than ARRAY(whatever) or blank...


$bodytext has nothing to do with $bodytext[0].  $bodytext, as assigned
above, is an array reference.  $bodytext[0] is the first element of an
array named @bodytext.  $bodytext and @bodytext have nothing to do with
each other.  If you want to print out the array referenced by $bodytext,
you have a few choices:

Dereference and copy the entire array:
@body = @$bodytext;
print "Body: @body\n";

Dereference the array only:
print "Body: @$bodytext\n";

print just the element of the referenced array you want:
print "Body line $i: $$bodytext[$i]\n";
or
print "Body line $i: $bodytext->[$i]\n";

Please take a look at
perldoc perlref
for more information.

Paul Lalli


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

Date: Tue, 17 Feb 2004 17:47:04 +0100
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: Threadsafe writing to files
Message-Id: <40324685.0@juno.wiesbaden.netsurf.de>

Yash wrote:

> Our perl program has to write lines to a large number of files. To
> make use of a multiprocessor architecture, we use threads.
> Some of the files will be written to by more than one threads. Which
> function should I use so that lines do not get split by different
> threads writing to the same file?
> Is it WRITE or PRINT that I should be using? Basically I am looking
> for a thread-safe function to write to files.
> We use Perl 5.8 on Windows 2000.
> 
> Thanks

You could use Thread::Queue to build a queue for each file. Then the 
threads can enqueue lines in the appropriate queue and one printing thread 
can dequeue the lines and print them to the assigned file.

That should be thread safe :-)

Thomas

-- 
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</  #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#....>>e>r^..>l^...>k^..


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

Date: Tue, 17 Feb 2004 19:51:58 +0100
From: "Dr. Ugo Gagliardelli" <dont@spam.please>
Subject: Re: When i try to implement a server program giving UDP as protocol , it works fine ,  but if the same code is executed with TCP as protocol option, it gives an error.
Message-Id: <c0to04$rss$1@panco.nettuno.it>

Tompyna wrote:

> Hi All,
> 
>         I am a newbie to Socket Programming . I had written a socket
> program in perl , implementing  client and server.
> 
> Now coming to the problem i am stuck:
> 
> 1.When i implement the program with "UDP" as protocol option, the code
> works
>   fine,but When i try to implement the same program , giving TCP as
> the
>   protocol  option,  it gives me an error:
>  "Can't call method "recv" on an undefined value at servermodulenew.pl
> line 18"
[cut]
> # Create a new socket
> $MySocket=new IO::Socket::INET->new(LocalPort=>($port),Proto=>(getprotobyname('udp')));
> 
> while(1)
>   {    
>     #Receiving a message from the client
>     $receive_status = $MySocket->recv($text,128);
> 	
>     if($text ne '')

As far as I know to use a connection oriented socket in general (with recv as 
well), as tcp is, you must connect first.
-- 
Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñejoAlcoolInside
Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
Spamers iros a la mierda/Spamers allez vous faire foutre
Spammers loop schijten/Spammers macht Euch vom Acker



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

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


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