[24115] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6309 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 27 03:05:35 2004

Date: Sat, 27 Mar 2004 00:05:06 -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           Sat, 27 Mar 2004     Volume: 10 Number: 6309

Today's topics:
        Choosing Perl/Python for my particular niche <fma@doe.carleton.ca>
    Re: Choosing Perl/Python for my particular niche <fma@doe.carleton.ca>
    Re: Filehandles Referenced with a Variable <uri.guttman@fmr.com>
    Re: Filehandles Referenced with a Variable <mikeflan@earthlink.net>
    Re: Filehandles Referenced with a Variable <mikeflan@earthlink.net>
    Re: Filehandles Referenced with a Variable <uri@stemsystems.com>
    Re: Filehandles Referenced with a Variable <uri@stemsystems.com>
        getting realtime progress output from rsync <perlcdr@mail.rumania>
    Re: getting realtime progress output from rsync (Anno Siegel)
    Re: getting realtime progress output from rsync <perlcdr@mail.rumania>
        New module: Array::Each <bmb@ginger.libs.uga.edu>
        Perl Programmer Wanted for Games Web Site Development (Kerrin)
    Re: Perl:  Generate registration code <arodland@eSntPerAmaMil.net>
        Read a file from /dev/mqueue directory. (Chilla)
    Re: Read a file from /dev/mqueue directory. <invalid-email@rochester.rr.com>
        Select with named pipes example (John Saalwaechter)
    Re: sendmail/cgi issue <tadmc@augustmail.com>
    Re: sendmail/cgi issue <tadmc@augustmail.com>
    Re: sendmail/cgi issue <noreply@gunnar.cc>
    Re: Signal handling in objects.  Good idea?  Best pract (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 27 Mar 2004 07:19:47 GMT
From: Fred Ma <fma@doe.carleton.ca>
Subject: Choosing Perl/Python for my particular niche
Message-Id: <40652B0D.7C313F77@doe.carleton.ca>

Hello,

This is not a troll posting, and I've refrained from
asking because I've seen similar threads get all
nitter-nattery.  But I really want to make a decision
on how best to invest my time.  I'm not interested on
which language is better in *general*, just for my
purpose.  My area of research is in CAD algorithms,
and I'm sensing the need to resort to something more
expedient than C++, bash scripting, or sed scripting.
What I hope to do is a bit multifaceted.  What I don't
do dabble in is web apps (though I'm not sure of the
similarities).  No XML processing or database
interaction in what I do.

One thing I expect to have to do is to modify design
files.  For example, there is a tool which takes ASCII
hardware desscription language (HDL) and converts it
to a C++ (augmented by hardware simulation library).
The translator is freeware, so has limitations which I
have to make up for by tweaking the HDL code.  In the
past, I've eeked out sed scripts for such tasks, but
would appreciate a more traditional language.  Since
Perl is used alot in digital IC design, I took a stab
at that, motivated by the simple need to convert my
mail aliases from one mail reader to the other.  It
took a while to do, and I'm concerned at the difficulty
level.  If I did this kind of thing constantly, I
would probably get proficient and use the power behind
it, but it's not my main area.

The alternative is Python, which is easier to read
from what I've read.  My concern there is that I cut
myself off from large availability of stuff that's
out there.  For example, I use a PC-to-solaris
viewer called VNC, and I've banged my head against the
startup script to change it a bit for my situation.
Likewise, the above translator uses Perl extensively
in its operation, as well as it's building and
installation.  If I wasn't passingly familiar with
Perl, I would have had a much harder time installing
it.  Being in the approximate area digit circuits,
I'm concerned about being on the band wagon, if only
to avoid reinventing things, or impediments to sharing
things.

An additional usage scenario is to (if reasonable)
replace my shell scripting e.g. I just converted to
bash from tcsh to write scripts that push a document
through a series of filters, or simply as a wrapper
around a tough-to-use utility e.g. pstops.  A final
example is to take a file of design information and
do more than tweak it e.g. extract all the information
about interconnections between circuit building blocks,
including which is the source block, and which are the
destination blocks.  Typically, this information will
be read by matlab scripts and passed to my C++ code
(I've managed to avoid writing code to parse the
input file from C++).

Whichever way I go, I would like to avoid the overhead
of learning both Perl and Python.  I will sculpt out some
time in a miserly fashion to slowly get to know one.  Since
I spend most of my time exploring the algorithm in Matlab or
C++/STL, there's only so much time to pick up higher level
languages (it took years before I shelled out the time
to switch from tcsh to bash).  One of the things that
makes the decision not clear is that despite Python's
claim to a gentler learning curve and clearer code, I
often like the expedience of sed e.g. a terse one-liner
that can be pipelined with other shell commands.  I
also note that Perl's unweldiness only comes for big
projects, and I don't expect to using Perl quite that
way.

I've seen mention of parrot and perl6, which is quite a
ways off.  I'm not sure how much that should weigh into
my decision, since it isn't real yet.

Thanks for any comments/suggestions.
-- 
Fred Ma
Dept. of Electronics, Carleton University
1125 Colonel By Drive, Ottawa, Ontario
Canada, K1S 5B6


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

Date: 27 Mar 2004 07:53:34 GMT
From: Fred Ma <fma@doe.carleton.ca>
Subject: Re: Choosing Perl/Python for my particular niche
Message-Id: <406532F7.D56DC671@doe.carleton.ca>

Just wanted to add another example of stuff that
I encounter alot of.  As in many computer languages,
various kinds of scopes are delineated by things
like braces or begin/end statements.  I often find
it valuable to find an occurance of certain things
(e.g. certain data declaration) within certain
scope structures.  Sed is convenient for that:

	/SomeStartPattern/,/SomeEndPattern/{
		Do some stuff,
		including conditional branching
	}

To avoid the hassle of writing a script file and
filtering the input source file to an output source
file, I often use gvim's awesome pattern matching
and macro recording abilities.  A sed script file
can look pretty cryptic, especially when I want
to search across physical lines (lots of conditional
flow to append things to the hold buffer, etc..).
For that reason, I tend to stay with quick/dirty
practices in gvim.  Crypticness (though not of the
same variety) is one of the things that I found
hard about ramping up on Perl, to the degree that
I did.  As I hinted earlier, a fair comparison would
account for the fact that its power would be more 
apparent if I became adequately guru-like, but
realistically, I will not spend enough time with
it on a regular basis to expect that.  Here again
is a dichotomy; I appreciate the sed terseness because
I can make a command line pipe stage out of it, but
the same brevity in a scripting language can make for
rough going.  Maybe it's wishful thinking to expect
one language to cover all the bases that I initially
mentioned.

Fred
-- 
Fred Ma
Dept. of Electronics, Carleton University
1125 Colonel By Drive, Ottawa, Ontario
Canada, K1S 5B6


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

Date: 26 Mar 2004 16:02:51 -0500
From: Uri Guttman <uri.guttman@fmr.com>
Subject: Re: Filehandles Referenced with a Variable
Message-Id: <siscn063gw3o.fsf@tripoli.fmr.com>


use IO::Handle or Symbol to get anon glob refs. or use recent perl's
with open that will autovivify a handle. stay away from all that
symbolic ref and glob stuff. it is not needed at all.

uri


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

Date: Sat, 27 Mar 2004 03:00:30 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Filehandles Referenced with a Variable
Message-Id: <4064EE59.4D257A6E@earthlink.net>


Eric Schwartz wrote:

> > foreach $st (@states) {
> >     open *$st, ">$st.txt" or die "Cannot open $st.txt: $!"; # THIS IS
> > LINE 16
> > }
>
> @states is an array of strings.  So when you try to treat $st as if
> it's a reference to a filehandle, when it's a string, naturally it
> says, "Can't use string as a symbol ref".

I got rid of the quotes:
my @states = (AK, AL, AR, AS, AZ, CA, etc  );
but obviously that is not going to change anything.  It still works
with 'use strict' commented out, but otherwise gives error:
Bareword "AK" not allowed while "strict subs" in use at line 10.


> Furthermore, you open all
> these files, and then do nothing with them.  I don't get it-- are you
> just trying to see if you can open the files without actually opening
> them?  If so, then you can replace that with:
>
> map { -r "$_.txt" or die "Cannot open $_.txt: $!" } @states;

Yeah, that is just a script in development.  The records contain a
field like this:  GA, Georgia; FL, Florida

In that case I would write that record to the GA file and the FL
file.  Most records only have one state listed in that field.

My script works now, so there isn't much need to spend any
time on it.  Well, I say it works.  Actually, the only time I have
run it, it got about 1/3 of the way through the 1.7 million
records and locked up my machine.  But I expect it will
get all the way through - maybe the next time I run it.

I'm on Win2000.



>
> You can just use $. (perldoc perlvar)

Yeah.  I haven't gotten used to using those special variable
too much yet.


> >     print "Did not find good pattern at line # $num.\n$line\n\n" unless
> >  ($line =~ m/\t([^\t]*)\t[^\t]*\n$/);
> >     $stm = $1;
>
> This variable could stand to be named more verbosely-- I have no idea
> what a 'stm' is, and your code doesn't help me much.

Sorry, it's the state field I described above.  I think I first
thought of state match.



> >     print "problem with record # $num\n$line\n\n" unless (@sttemp = grep
> > $line =~ m/$_, /i, @states);
>
> FYI, this error message doesn't help much-- it says there's a problem,
> which is good, but not what the problem is, or how to fix it.  I'm on
> a campaign recently to get better error messages, so you may take this
> with a grain or two of salt.  Also, since @sttemp appears to be an
> array with the names of the states found in $line, perhaps a name like
> @statesfound might help a reader understand better what you're trying
> to do with it.
>
> > #    print "Did not find 2 character state at line # $num.\n$line\n\n"
> > unless ($stm =~ m/^(\w{2}),[^;]*\n?$/);
>
> I think this unless should be commented out as well; it doesn't
> actually do anything as written.

Right, that is just a word wrap problem.  Not sure why usenet
wraps when other e-mail lists don't.

>
> >     foreach $st (@sttemp) {
> >         $count{$st}++;
> >         if ($st eq 'DC') {
> >             print { *$st } "$line";
> >         }
>
> This print line is probably going to cause you trouble as well; you're
> confusing symrefs and strings again.  Also, don't quote $line there;
> it's unnecessary, and could cause trouble later.

Thanks.  I didn't have $line quoted at first, but changed it to
quoted mainly out of habit.  It's not quoted now.


>
> In this case, $st is a string, 'DC'.  You're trying to print to a
> filehandle, which I imagine you thought you were opening on line 16
> above.  If you're only printing to 'DC.txt', then maybe you should
> open it just before that loop, and close it afterwards:
>
> open my $dc_count, '>', "DC.txt" or die "bah: $!";
> foreach(...) {
>   if(...) {
>      print $dc_count $line;
> }
> close $dc_count or die "grr: $!";
>
> If you're going to be doing this for more than one state later on,
> maybe your loop on line 16 should use a hash instead:
>
> my %state_files;
> foreach my $state (@states) {
>   open $state_files{$state}, '>', "$state.txt" or die "bah: $!"
> }
>
> Then you can do something like:
>
> foreach my $state (@sttemp) {
>   $count{$state}++;
>   print $state_files{$state} $line; # or maybe
>   print $state_files{$state} $line if $state eq 'DC';
> }
>
> and at the end of the program, of course:
>
> foreach my $state(keys %state_files) {
>   close $state_files{$state} or die "bah: $!";
> }
>
> >     }
> >     print "$num\n" if $num % 50000 == 0;
> > }
>
> Again, you can use $. here.
>
> -=Eric
>

I write to all 60 files at once, basically, as you can see below.

Thanks for all your help.


This is what I am running now.  It works for 300,000+ record
files, but got hung up on my 1.7 MM file.  If I really have to, I'll
break my file up and run append writes.  BTW, this thing
is going to take almost an hour to run through all 1.7 MM
records, if it ever does :-)



#use strict;
use warnings;

my $infile = 'USAshorter.txt';

my $fileout = 'out.txt';
my ($line, $stm, $state, $st, @sttemp, %count, $k, $v);
my $num=0;
my $prn=0;
my @states = (AK, AL, AR, AS, AZ, CA, CO, CT, DC, DE, FL, FM, GA, GU, HI, IA,
ID, IL, IN, KS, KY, LA, MA, MD, ME, MH, MI, MN, MO, MP, MS, MT, NC, ND, NE,
NH, NJ, NM, NV, NY, OH, OK, OR, PA, PR, PW, RI, SC, SD, TN, TX, UM, UT, VA,
VI, VT, WA, WI, WV, WY);

chdir 'C:\Copy2';

foreach $st (@states) {
    open *$st, ">$st.txt" or die "Cannot open $st.txt: $!";
}

open OUT, ">", $fileout or die "Cannot open $fileout: $!";

open INPUT, "<", $infile or die "Cannot open $infile: $!";

while ($line = <INPUT>) {
    $num++;
    print OUT "Did not find good pattern at line # $num.\n$line\n\n" unless
($line =~ m/\t([^\t]*)\t[^\t]*\n$/);
    $stm = $1;

    print OUT "problem with record # $num\n$line\n\n" unless (@sttemp = grep
$line =~ m/$_, /i, @states);

    foreach $st (@sttemp) {
        print { *$st } $line;
        $prn++;
    }
    print "$num\n" if $num % 50000 == 0;
}

foreach $st (@states) {
    close *$st;
}

print "\n\nProcessed $num lines.\nBut printed $prn times.\n";
print OUT "\n\nProcessed $num lines.\nBut printed $prn times.\n";

close INPUT;
close OUT;

__END__



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

Date: Sat, 27 Mar 2004 03:02:38 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Filehandles Referenced with a Variable
Message-Id: <4064EEEB.C9D0480B@earthlink.net>


Uri Guttman wrote:

> use IO::Handle or Symbol to get anon glob refs. or use recent perl's
> with open that will autovivify a handle. stay away from all that
> symbolic ref and glob stuff. it is not needed at all.
>
> uri

I'm running v5.8.0 for Win.  I suspect that is not recent
enough for autovivify, but am not sure.

I'll check into IO::Handle.  I need to learn that module anyway.


Mike




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

Date: Sat, 27 Mar 2004 03:48:22 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Filehandles Referenced with a Variable
Message-Id: <x7smfvvtkp.fsf@mail.sysarch.com>

>>>>> "MF" == Mike Flannigan <mikeflan@earthlink.net> writes:

  MF> Uri Guttman wrote:

  >> use IO::Handle or Symbol to get anon glob refs. or use recent perl's
  >> with open that will autovivify a handle. stay away from all that
  >> symbolic ref and glob stuff. it is not needed at all.
  >> 
  >> uri

  MF> I'm running v5.8.0 for Win.  I suspect that is not recent
  MF> enough for autovivify, but am not sure.

read perldoc perlopentut. 5.6 added autovivified handles so you have
them. 

  MF> I'll check into IO::Handle.  I need to learn that module anyway.

and all the related IO:: modules that inherit from IO::Handle. but plain
open is all you need for your problem. you just need proper scalar
handles and stay away from globs. they are almost never needed anymore
for files.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Sat, 27 Mar 2004 04:01:41 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Filehandles Referenced with a Variable
Message-Id: <x7ptazvsyn.fsf@mail.sysarch.com>

>>>>> "MF" == Mike Flannigan <mikeflan@earthlink.net> writes:

  MF> Eric Schwartz wrote:

  >> > foreach $st (@states) {
  >> >     open *$st, ">$st.txt" or die "Cannot open $st.txt: $!"; # THIS IS
  >> > LINE 16
  >> > }
  >> 
  >> @states is an array of strings.  So when you try to treat $st as if
  >> it's a reference to a filehandle, when it's a string, naturally it
  >> says, "Can't use string as a symbol ref".

  MF> I got rid of the quotes:
  MF> my @states = (AK, AL, AR, AS, AZ, CA, etc  );

that is not what he meant. use qw(). read perldoc perldata for that.

  MF> but obviously that is not going to change anything.  It still works
  MF> with 'use strict' commented out, but otherwise gives error:
  MF> Bareword "AK" not allowed while "strict subs" in use at line 10.

because you need strings there with either ('AK', 'AL') or qw( AK AL )

  >> You can just use $. (perldoc perlvar)

  MF> Yeah.  I haven't gotten used to using those special variable
  MF> too much yet.

you need to learn a few as they are very important.

  >> >     print "Did not find good pattern at line # $num.\n$line\n\n" unless
  >> >  ($line =~ m/\t([^\t]*)\t[^\t]*\n$/);
  >> >     $stm = $1;
  >> 
  >> This variable could stand to be named more verbosely-- I have no idea
  >> what a 'stm' is, and your code doesn't help me much.

  MF> Sorry, it's the state field I described above.  I think I first
  MF> thought of state match.

choosing names are the most important decisions you ever make in
coding. most coders don't spend nearly enough time on good names.

rule: names should reflect their use and not just be a mnemonic. 

at work today i was struggling with old code which had short abbreviated
names like mmnURL. no one could remember what mmn meant as it was named
many years ago. learn this lesson now. :)


  MF> Right, that is just a word wrap problem.  Not sure why usenet
  MF> wraps when other e-mail lists don't.

usenet is not an email list. and your newsreader is the guilty culprit
when it comes to line wrapping.

  MF> Thanks.  I didn't have $line quoted at first, but changed it to
  MF> quoted mainly out of habit.  It's not quoted now.

there is an FAQ on that. read it.

  MF> #use strict;
put back strict.

  MF> use warnings;

  MF> my $infile = 'USAshorter.txt';

  MF> my $fileout = 'out.txt';
  MF> my ($line, $stm, $state, $st, @sttemp, %count, $k, $v);

declare vars when you first use them.

  MF> my $num=0;
  MF> my $prn=0;

  MF> my @states = (AK, AL, AR, AS, AZ, CA, CO, CT, DC, DE, FL, FM, GA, GU, HI, IA,

qw()


  MF> chdir 'C:\Copy2';

  MF> foreach $st (@states) {
  MF>     open *$st, ">$st.txt" or die "Cannot open $st.txt: $!";
  MF> }

gack!! that is the whole problem. use IO::Handle or my $st and save the
handle in a hash indexed by the state name.

  MF> foreach $st (@states) {
  MF>     close *$st;
  MF> }

no need to close them by hand. exiting the program will do it for you.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 26 Mar 2004 23:51:33 GMT
From: perl coder <perlcdr@mail.rumania>
Subject: getting realtime progress output from rsync
Message-Id: <9m39c.10669$b_2.10523@bignews4.bellsouth.net>

I'm trying to figure out how to retrieve status output from an rsync
command ("rsync --progress").  The --progress option shows a percentage
of the file transfered and estimated ETA, on one line.  But since rsync
overwrite the status line each time with the current info (instead of
going to the next line), I can't use stdio to retrieve it.  Well, I
can, but I'll only get the final write, which pretty much defeats my
purpose.

I also can't use select because this must work on win98. :-(  And from
what I've seen from browsing google, Expect and IO::Pty don't work on
the win32 platform.

That doesn't seem to leave many options.  In fact, I have only one idea
right now, but it's inefficient as hell:

system("rsync --progress ${host}::$user/$file . </dev/null >log 2>&1");

# $ ./r.pl &
# [1] 2049
# $ cat log
#     1245184  11%    1.01MB/s    0:00:08
# $ cat log
#     3604480  34%    1.06MB/s    0:00:06
# $ cat log
#     5963776  57%    1.07MB/s    0:00:04
# $ cat log
#     6815744  65%  920.61kB/s    0:00:03
# $ cat log
#     8585216  82%  953.70kB/s    0:00:01
# $ cat log
#    10059776  96%  973.35kB/s    0:00:00
# [1]+  Done                    ./r.pl
# $ cat log
#     10442514 100%  980.37kB/s    0:00:10
 
In other words:  redirect rsync output to a file, and read it at regular
intervals.  But this is kinda kludgy, and just makes rsync hog even more
I/O...

Anyone got a better idea?


-- 
No crazy stuff in my email. ;-)


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

Date: 27 Mar 2004 00:20:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: getting realtime progress output from rsync
Message-Id: <c42hbi$nmd$2@mamenchi.zrz.TU-Berlin.DE>

perl coder  <perlcdr@mail.rumania> wrote in comp.lang.perl.misc:
> I'm trying to figure out how to retrieve status output from an rsync
> command ("rsync --progress").  The --progress option shows a percentage
> of the file transfered and estimated ETA, on one line.  But since rsync
> overwrite the status line each time with the current info (instead of
> going to the next line), I can't use stdio to retrieve it.  Well, I
> can, but I'll only get the final write, which pretty much defeats my
> purpose.

You only *see* the final write, you get them all.  The messages are
separated by carriage returns ("\r"), not by line feeds ("\n").
Set local $/ accordingly, and read the program's STDOUT or STDERR,
whichever (untested).

[snip]

Anno


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

Date: Sat, 27 Mar 2004 01:05:46 GMT
From: perl coder <perlcdr@mail.rumania>
Subject: Re: getting realtime progress output from rsync
Message-Id: <Kr49c.21209$fl6.15583@bignews1.bellsouth.net>

Anno Siegel said:
> You only *see* the final write, you get them all.  The messages are
> separated by carriage returns ("\r"), not by line feeds ("\n").
> Set local $/ accordingly, and read the program's STDOUT or STDERR,
> whichever (untested).

Hey that works great!  And so simple too.  Thank you!


-- 
No crazy stuff in my email. ;-)


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

Date: Sat, 27 Mar 2004 00:03:33 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: New module: Array::Each
Message-Id: <Pine.A41.4.58.0403262342190.10634@ginger.libs.uga.edu>

Note: this is sort of a continuation of the thread,
    Proposal: new module, Array::Each?
http://groups.google.com/groups?threadm=Pine.A41.4.58.0312091240460.6362%40ginger.libs.uga.edu

I've uploaded version 0.02 of Array::Each to CPAN,
    http://www.cpan.org/authors/id/B/BB/BBAXTER/

It's also available from my web site, where you can read a bit more of the
docs without unpacking anything,
    http://www.vitabrevis.com/perl/modules/Array-Each

This is my first CPAN contribution, and it has been a bit of a
professional development project.  I wanted to study and use best
practices as regards module design, coding, documentation, testing, and
packaging.  In the process, my appreciation for maintaining test suites
has *skyrocketed*.

I would still appreciate discussion, criticism, or any other feedback
about the module.

For starters, the following line of code returns an element from each
array in $set (plus $c):

    return ( (map $_->[$i], @$set), $c )

And this code returns groups of elements from each array, and it returns
the value in $undef if we've gone past the end of any array:

    my @ret;
    foreach my $aref ( @$set ) {
        push @ret, map {$_<@$aref ? $aref->[$_] : $undef}
            ($i..$i+$group-1) }
    return ( @ret, $c );

I'd like to think this could be done with two maps in succession, but
inspiration just hasn't come.

Thanks,

Brad


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

Date: 26 Mar 2004 16:16:40 -0800
From: kerrin.hardy@ntlworld.com (Kerrin)
Subject: Perl Programmer Wanted for Games Web Site Development
Message-Id: <b803b120.0403261616.18b70d45@posting.google.com>

I have started a project, and require people to join me.
We will develop a web site, that has turn based games (see
http://main.planetarion.com/ or http://www.evernight.com/ for an
example of the type of games I mean)
I currently have the outlines of numerous games that fit well in to
this design, I have develop the structure these games will use, and
and part way through one of the games.
A pricing structure for the web site has also been outlined, but
payment to use the web site will not be required (just limiting).
I have connections with a payment solution service, so this will be
taken care of by me.
I am not rich (yet :), so there will be *no* salary for these role.
What I can offer is profits of the web site, once up and running.
Online games are very big at the moment.
I am looking for people with many and varied skills, these include,
but are not exclusively:
·	Perl
·	Graphics
·	HTML
·	Online advertisement
·	SQL
·	Linux
·	Web server (i.e. Apache, etc.)
·	Linux Security

If you have programming skills, but not Perl, you can still be useful,
if you are prepared to learn.

Knowledge of CVS is also a bonus.

No previous experience is required, no age limits. All I require is
some of your spare time to assist in the various areas of developing,
releasing, maintaining, and advancing this web site.

If you can get to the Cambridge (UK) area, this is a bonus, as I would
like to meet with all applicants in person we possible, to gauge you
skills, and explain the web site in more detail.

The design of the game structure, and games is not final, and
successful applicants will have control over the final designs.

Kerrin
Interested Applicants Should Email: kez.comp@ntlworld.com


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

Date: Sat, 27 Mar 2004 00:22:17 GMT
From: Andrew Rodland <arodland@eSntPerAmaMil.net>
Subject: Re: Perl:  Generate registration code
Message-Id: <ZO39c.141$y4.74626@newshog.newsread.com>

John wrote:

> I am new to Perl.  I want to write a Perl script that generates a
> registration code on my website.  It's basically a hex of the week of
> the year and year, plus and multiplied by some number.  I have a
> sample of what I would like in VB.  Can someone help convert this to
> Perl.  I'm hoping it's as simple as VB.  Thanks for your help...
> 
> ------- VB Code ------------
> Sub RegCode()
> Dim strCode as String
> strCode = Hex(((DatePart("ww", Date) & Year(Date)) + 12345) * 12345)
> Debug.Print strCode
> End Sub
> ---------------------------

use Date::Format;

sub regcode {
        print sprintf('%x', timetostr('%W%Y', time));
}

or so.



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

Date: 26 Mar 2004 17:41:19 -0800
From: jchilla1@hotmail.com (Chilla)
Subject: Read a file from /dev/mqueue directory.
Message-Id: <348c9941.0403261741.672c82f0@posting.google.com>

Hi,

I am using Perl version 5.005_02 built for x86-qnx.

I would like to read a text file from /dev/mqueue directory,using Perl. 
some thing like..

open( FD, "/dev/mqueue/filename" ) or die "Error...\n";
while ( <FD> )
{
print;
}

Any pointers in this direction are sincerely appreciated.

The following works..
open( FD, "cat /dev/mqueue/filename |") or die... 
do
{
$line = <FD>;
}while ( line matches some pattern );

But the process "cat.. " as it is still running has to be deleted separately.

I could not use sysopen or syscall.


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

Date: Sat, 27 Mar 2004 02:50:36 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Read a file from /dev/mqueue directory.
Message-Id: <4064EBDF.4030308@rochester.rr.com>

Chilla wrote:

 ...
> I am using Perl version 5.005_02 built for x86-qnx.


Well, 5.005_02 is only a lot old...


> 
> I would like to read a text file from /dev/mqueue directory,using Perl. 
> some thing like..


You're missing:

   use warnings;
   use strict;

Oh, um, does 5.005_02 have those?  Maybe not warnings...


> 
> open( FD, "/dev/mqueue/filename" ) or die "Error...\n";
> while ( <FD> )
> {
> print;
> }
> 
> Any pointers in this direction are sincerely appreciated.
> 


Well, um, what is it about the above that doesn't work?  It looks fine. 
  Is it perhaps some arcane piece of weirdness with the QNX device file 
/dev/mqueu/filename that you are asking about?  If so, maybe a QNX 
newsgroup would be better?

You might add $! somewhere in the die() message so you will get a better 
idea what was wrong if it does die on you.

It is also a bit verbose -- try:

    perl -pe '' </dev/mqueue/filename


> The following works..
> open( FD, "cat /dev/mqueue/filename |") or die... 
> do
> {
> $line = <FD>;
> }while ( line matches some pattern );
> 
> But the process "cat.. " as it is still running has to be deleted separately.
> 
> I could not use sysopen or syscall.
> 


Well, this one runs fine on my system (Windoze 98SE with AS Perl build 
806), too (with "type" replacing "cat" -- type terminates fine).  So 
maybe the issue is still something with QNX or the specific device file 
/dev/mqueue/filename?
-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: 26 Mar 2004 20:29:32 -0800
From: saalwaechter_jw@hotmail.com (John Saalwaechter)
Subject: Select with named pipes example
Message-Id: <154bae9.0403262029.3d5149a9@posting.google.com>

In a perl script, I need to run a task on a regular interval,
and also respond to other asynchronous events without waiting.
My thought was to make a named pipe, and then use select()
on it with a timeout.  If the asynchronous event occurred,
another process could drop a signal message into the named
pipe, and my perl script would return from select() immediately.
If no asynchronous event occurred, then the select() timeout
would occur and the script could perform the periodic task
before going back in to the select().

I found lots of bits of information in the perldocs and by
googling, but no good explicit examples.  There is one major
bit that's hard to locate: you need to open the named pipe
as read/write.  I finally got it all straightened out, so in
the hope of saving someone else the search grief, here is a
full example of using select() on a fifo:

#!/usr/bin/perl -Tw
#
# Example script that uses select() with
# a timeout on a named pipe.
#
use strict;
my $interval=10;  # seconds
my $fifo="/tmp/testfifo";  # create from shell with "mkfifo /tmp/testfifo"
if (!(-p $fifo && -w _ && -r _))
{
    print STDERR "Bad fifo $fifo!\n";
    exit(1);
}
# Open the fifo read/write, not just read.  This is necessary because
# of the POSIX rules about using select() on named pipes when no writers
# are present.  This is a very key step that is hard to find documentation
# about.
open(FIFOFH,"+<",$fifo) || die $!;
while(1)
{
    my $rin='';
    vec($rin,fileno(FIFOFH),1)=1;
    my $nfound=select($rin,undef,undef,$interval);
    print "It is now ",scalar(localtime),"\n";
    if($nfound)
    {
        my $fifodata=<FIFOFH>;
        print $fifodata,"\n";
    }
    # Do some other periodic tasks here...
}
__END__


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

Date: Fri, 26 Mar 2004 17:04:10 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: sendmail/cgi issue
Message-Id: <slrnc69dna.pm7.tadmc@magna.augustmail.com>

Joe Cipale <joec@aracnet.com> wrote:

> The funny thing is, I can encode/use this (code below) simply as a
> generic perl script, and the data is delivered as expected. It is not
> being collected and deliverd from with the CGI script via the web.


Does the CGI program run as a different user than when you use
the command line?

You can try running this both ways to find out:

   my $login = getpwuid($<);
   print "my login ID is '$login'\n";


> Can someone tell me what I am missing here?


Some difference in the environment (permissions, paths, env vars...).


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


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

Date: Fri, 26 Mar 2004 17:10:21 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: sendmail/cgi issue
Message-Id: <slrnc69e2t.pm7.tadmc@magna.augustmail.com>

Joe Cipale <joec@aracnet.com> wrote:


> -- 


Please don't put non-sig stuff below the sig-dash.

It makes it hard to quote on many newsreaders.


> open(FILE, "$read_path/$dte");


You should always, yes *always*, check the return value from open():

   open(FILE, "$read_path/$dte") or die "could not open '$read_path/$dte' $!";


> open(SM, "| /usr/sbin/sendmail -t -fjoec\@aracnet.com");


You won't have to mentally filter out backslashes if you don't
put backslashes in in the first place:

   open(SM, '| /usr/sbin/sendmail -t -fjoec@aracnet.com') or die ...

> my @email_body = <FILE>;
> print "@email_body";


That will print an extra space character at the beginning of
every line except the first line.

Is that what you want it to do?


> print SM <<EOF;
> From: evbc\@aracnet.com
> To: joec\@aracnet.com
> Subject: Race Refund Request
> 
> EOF

You won't have to mentally filter out backslashes if you don't
put backslashes in in the first place:

print SM <<'EOF';
From: evbc@aracnet.com
To: joec@aracnet.com
Subject: Race Refund Request

EOF


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


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

Date: Sat, 27 Mar 2004 00:25:27 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: sendmail/cgi issue
Message-Id: <c42e40$2e8qes$1@ID-184292.news.uni-berlin.de>

Tad McClellan wrote:
> Joe Cipale <joec@aracnet.com> wrote:
> 
>> I have a file that is generated via CGI.

<snip>

>> The funny thing is, I can encode/use this (code below) simply as
>> a generic perl script, and the data is delivered as expected. It
>> is not being collected and deliverd from with the CGI script via
>> the web.
> 
> Does the CGI program run as a different user than when you use the
> command line?

That does not sound as a plausible explanation, since the file is
generated via CGI. A CGI generated file has the same owner as the user
as which CGI is run.

>> Can someone tell me what I am missing here?
> 
> Some difference in the environment (permissions, paths, env
> vars...).

I would guess paths before permissions...

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



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

Date: 27 Mar 2004 00:11:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Signal handling in objects.  Good idea?  Best practices?
Message-Id: <c42gru$nmd$1@mamenchi.zrz.TU-Berlin.DE>

Carlton Brown <carltonbrown@hotmail.com> wrote in comp.lang.perl.misc:
> Tad McClellan <tadmc@augustmail.com> wrote in message
> news:<slrnc67cuq.mh9.tadmc@magna.augustmail.com>...
> > Carlton Brown <carltonbrown@hotmail.com> wrote:
> > 
> > > #!/usr/local/bin/perl
> > 
> > 
> > You should ask for all the help you can get:
> 
> The minor pecadillos are duly noted, but neither they nor the
> stricture messages shed any light on the larger question of if, why,
> whether, or how one would design signal handlers into objects.  The
> toy program was not a debugging request, it was to illustrate how I
> attempted to approach the problem (Also to anticipate the question
> "What did you try?").

The question here isn't so much "What did you try?", but "What are you
up to?".

What your example does can't be described as "design(ing) signal handlers
into objects".  What you do is install an object-specific signal handler.
That may make sense (or be a design error) in so many ways, it is
impossible to say anything general.

What is strange is that you do this in the new() method.  That means
another object controls the signal handler each time you create one.
I fail to see a scenario where this makes sense, though there may be
one.  I wonder why *this* is in the example code.

Anno


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

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


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