[25833] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8070 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 11 14:05:33 2005

Date: Wed, 11 May 2005 11:05:05 -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           Wed, 11 May 2005     Volume: 10 Number: 8070

Today's topics:
    Re: Games.pl again <hackeras@gmail.com>
    Re: Games.pl again <no@email.com>
    Re: Games.pl again <1usa@llenroc.ude.invalid>
    Re: Games.pl again <tadmc@augustmail.com>
    Re: How can I prevent perl from exiting during a networ <Juha.Laiho@iki.fi>
        how to recursively search through files (not dirs)? (David Combs)
    Re: Storable - Win32 to Linux <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 11 May 2005 16:17:18 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: Games.pl again
Message-Id: <d5t0ks$k0l$1@nic.grnet.gr>

Not its like this but its till problematic:

my ($gamename, $gamedesc, $gamecounter);
my $select = $dbh->prepare( "SELECT count(*) FROM games WHERE gamename=?" );
my $insert = $dbh->prepare( "INSERT INTO games (gamename, gamedesc, 
gamecounter) VALUES (?, ?, ?)" );
my $update = $dbh->prepare( "UPDATE games SET gamedesc=?, 
gamecounter=?+1 where gamename=?" );

open (FILE, "<../data/games/descriptions.txt") or die $!;
     while (<FILE>) {
         chomp;

         ($gamename, $gamedesc) = split /\t/;

         $select->execute($gamename);
         my $record_exists = $select->fetchrow_array();

         if ($record_exists) {
            $update->execute( $gamedesc, $gamecounter, $gamename );
         }
         else {
            $insert->execute( $gamename, $gamedesc, 0 );
         }
     }
close (FILE);


-- 
"Of course I cant stop you. And that would really bum me out
if that were my job. But my job isnt to stop you, its to
make it as difficult as possible, for as many as possible,
for as long as possible ."


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

Date: Wed, 11 May 2005 14:25:14 +0100
From: Brian Wakem <no@email.com>
Subject: Re: Games.pl again
Message-Id: <3eefdrF2mr34U1@individual.net>

Nikos wrote:
> Not its like this but its till problematic:


Sorry I do not understand that.


-- 
Brian Wakem


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

Date: Wed, 11 May 2005 14:07:15 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Games.pl again
Message-Id: <Xns965366F41599Basu1cornelledu@132.236.56.8>

Nikos <hackeras@gmail.com> wrote in news:d5t0ks$k0l$1@nic.grnet.gr:

> Not its like this but its till problematic:

You are making absolutely no sense whatsoever.

If you want answers, you will have to read and follow:

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


Sinan


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

Date: Wed, 11 May 2005 12:17:08 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Games.pl again
Message-Id: <slrnd84fgk.ho2.tadmc@magna.augustmail.com>

A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:

> If you want answers, you will have to read and follow:
> 
> comp.lang.perl.misc guidelines on the WWW:
> http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


It also helps to get an answer if you actually _ask_ some question...


(questions are easily identified, as they end with a question mark.)


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


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

Date: Wed, 11 May 2005 16:39:46 +0000 (UTC)
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: How can I prevent perl from exiting during a network error?
Message-Id: <d5tcgi$83m$2@ichaos.ichaos-int>

songlining@gmail.com (Song Lining) said:
>Thanks guys!
>
>Got the problems solved according to your suggestions, here's the
>code:
 ...
>		select(undef, undef, undef, 10); 

Out of curiosity, why the above instead of just 'sleep(10)'?
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: 11 May 2005 13:59:51 -0400
From: dkcombs@panix.com (David Combs)
Subject: how to recursively search through files (not dirs)?
Message-Id: <d5th6n$9hj$1@panix1.panix.com>

What I want to do traverse files that recursively
"include" or (as in csh .cshrc-files) "source"
other files -- then come back and continue
to process the "sourcing" file.

Files like these:

375 ====> head -5000 test{1,2,3}.source
==> test1.source <==
foo
source test2.source
bar
bletch

==> test2.source <==
this is test2.source, line ONE
source test3.source
this is test2.source, line THREE
this is test2.source, line FOUR

==> test3.source <==
this is test3.source, line ONE.
this is test3.source, line TWO.
376 ====> !! >! foo.out
head -5000 test{1,2,3}.source > ! foo.out
377 ====> 

I have tried lots of (probably wrong) things in trying
to have the file-handle being lexically-bound,
so it would reappear in the same state upon
(recursive) return, and the while would keep
reading the lines *after* the "source" line up to
the end of file.

No such luck.  You'll see three triples of statements,
two of the triples commented out, and I can't
get any of them to work -- heck, not even to compile!

(Heck, I also have problems getting cperl-mode (emacs)
bounce-parens correctly, eqivalently it complains
when I regionsize the sub, and try cperl-indent-region,
for which cperl-mode gives me:

   Scan error:  Unbalanced parentheses" 3059, 5237
( giving different locations depending on what triple is uncommented)
, and I have no luck finding anything wrong (unbalanced),
or missing trailing-semicolons, or missing double-quotes,
yada, yada, yada.

   
FYI: I've been using perl-5.8.6.

(I originally had it at least opening the files in
the right order, but not restoring the prior
filehandle on returning -- but that version
I didn't save away, and it's now transmuted
into this mess:

(Crazy, but I can find no example in any of my many
perl books, nor in any of the (huge amount of) stuff
(threads) I've downloaded from here.  The only mention
of "recursive" in the camel-3 is about doing it through
*directories* -- and they (well, he) cheats by using
file::find, instead of doing it "by hand" (to show
how lexical handles would do the right thing on the dfs).)

Thanks much for any help!

(syntax, semantics, as well as the cperl-mode?) 


----------------- here it is (ugh!):


#!/me-FIRST-in-PATH-bin/perl-5.8.6/bin/perl5.8.6  -w  traverse-via-SOURCE-stmts.pl
use strict;
use diagnostics;
use warnings;
use Carp;
use IO::Handle;  # test of 11may05:  (recursive opens)
use FileHandle;  # ---- from pg 895 in camel 3rd:

# ------------------------------------------------------------------------
# ------------------------------------------------ processOneFile():::
# ------------------------------------------------------------------------

# cperl-indent-region on the entire sub, complains (unfortunately
#   the err-msg doesn't make it to *Messages*):
#      Scan error: "Unbalanced parentheses", 3002, 5180"


sub processOneFile {
  my $fileName = shift;
  my $level = shift;

  print("\n========================= ENTERING processOneFile(\"$fileName\", $level\n");

# ---- from pg 895 in camel 3rd,  (with "my" added):

  my $fh = new FileHandle;
  die "Cannot open \"$fileName\"!" if (! fh->open( $fileName ));
  while (defined(my $line = <$fh>)) { # while: 

#    my MYFIN;     # or is it "my *MYFIN" ... or what?
#     open(MYFIN, "<" . $fileName)   or   die "Cannot open!";
#    while (defined(my $line = <MYFIN>)) { # while:

#  my $fh = new IO::Handle $fileName, "r";
#  die "Cannot open \"$fileName\"!" if (! defined $fh);
#  while (defined(my $line = <$fh>)) { # while: 

    chomp($line);
    print "EARLY: $line\n";	# debug.

    if ( ( $line =~ /^source / ) && 
	 ( $line =~ /^source\s+([A-Za-z0-9._-]+)/ ) ) { # dive-in:
    #  CPERL-MODE won't bounce on either rparen   ^ ^ -- WHY?
            my $diveIntoFName = $1;

            print("Now, we'll try to source-in file \"$diveIntoFName\"\n"); # debug.

           processOneFile($diveIntoFName, $level + 1); # RECURSE

        print("LATE: $line\n"); # debug.

  } # dive-in.

} # end-while.

   print("----- EXITING processOneFile(\"$fileName\", $level\n\n");
} # end-sub processOneFile.


processOneFile("test1.source", 1);





Thanks!

David




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

Date: Wed, 11 May 2005 13:17:59 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Storable - Win32 to Linux
Message-Id: <Xns96535E99F47Casu1cornelledu@132.236.56.8>

Joe Smith <joe@inwap.com> wrote in news:XpOdnTtnMJstnR_fRVn-1g@comcast.com:

> A. Sinan Unur wrote:
> 
>>>I would be more than happy to read it. If you intend to refer me to
>>>something called "network order" then it would be nice if this were
>>>defined first. 
>> 
>> http://www.google.com/search?q=define%3A+network+order
> 
> Thanks for posting that link.
> Going to http://en.wikipedia.org/wiki/Endianness brought back memories,
> resulted in some minor edits, and inspired me to create a new entry for
> the VT180 computer-in-a-terminal.

Enjoyed reading it, thanks.

Sinan


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

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


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