[25269] in Perl-Users-Digest
Perl-Users Digest, Issue: 7514 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 13 09:05:49 2004
Date: Mon, 13 Dec 2004 06:05:07 -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 Mon, 13 Dec 2004 Volume: 10 Number: 7514
Today's topics:
Communication between Cgi and another perl application <giojo81@hotmail.com>
Re: Communication between Cgi and another perl applicat <nospam@bigpond.com>
Re: Consecutive Numbers <graham.drabble@lineone.net>
Re: Consecutive Numbers <apeiron+usenet@coitusmentis.info>
Re: Consecutive Numbers <someone@example.com>
Re: forwarding cgi->param() (Anno Siegel)
Re: get startup / running time of a process? <a.newmane.remove@eastcoastcz.com>
Re: grammar function <bart.lateur@pandora.be>
Re: Loop Logic Question (Anno Siegel)
Re: mod_perl headaches <ceo@nospam.on.net>
Re: mod_perl headaches <kkeller-usenet@wombat.san-francisco.ca.us>
Re: mod_perl headaches <joe@inwap.com>
Re: Need help with constants and package names. <just@say.no>
Re: Need help with constants and package names. <just@say.no>
Re: Newbie questions, migrating from c++ <do-not-use@invalid.net>
Re: Newbie questions, migrating from c++ <do-not-use@invalid.net>
Re: Paragraph separation for DOS files on Unix <ahamm@mail.com>
Re: perl port to my m68k calculator <ahamm@mail.com>
Re: rsh daemon written in perl? <ceo@nospam.on.net>
Re: rsh daemon written in perl? <joebloggs74@hotmail.com>
Sending a binary file through a script (binmode/stdout/ <200410+news@pobox.com>
Re: Sending a binary file through a script (binmode/std <nobull@mail.com>
Text::Reform - Words are wrapped whole?? (Graham Smith)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 13 Dec 2004 13:14:24 GMT
From: "Giojo" <giojo81@hotmail.com>
Subject: Communication between Cgi and another perl application
Message-Id: <QAgvd.506161$35.21626906@news4.tin.it>
Hello boy!
I have to make 2 applications in perl running on the same server.. One is
always active and using an infinite loop do something on the server, the
other one is a cgi script that have to comunicate with the always active
application... So I can control remotely my application using a cgi and the
apache server...
Now, I don't know in witch way they should communicate...
1)through text file shared?
2)through memory shared?
I'd prefer the second one, I think is more useful then the first... What do
you think?
Consider that the message are very simple, for example start this... stop
that... etc...
Thank you :)
Giojo
------------------------------
Date: Mon, 13 Dec 2004 23:38:35 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Communication between Cgi and another perl application
Message-Id: <325kasF3eo8utU1@individual.net>
Giojo wrote:
> Hello boy!
> I have to make 2 applications in perl running on the same server.. One is
> always active and using an infinite loop do something on the server, the
> other one is a cgi script that have to comunicate with the always active
> application... So I can control remotely my application using a cgi and
> the apache server...
> Now, I don't know in witch way they should communicate...
> 1)through text file shared?
> 2)through memory shared?
> I'd prefer the second one, I think is more useful then the first... What
> do you think?
> Consider that the message are very simple, for example start this... stop
> that... etc...
> Thank you :)
> Giojo
Use standard interprocess communication mechanisms - shared
memory/semaphores or sockets.
gtoomey
------------------------------
Date: Mon, 13 Dec 2004 01:13:00 GMT
From: Graham Drabble <graham.drabble@lineone.net>
Subject: Re: Consecutive Numbers
Message-Id: <Xns95BEC60DA3FBgrahamdrabblelineone@ID-77355.user.dfncis.de>
On 12 Dec 2004 Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote in
news:cpifp9$qjh$1@agate.berkeley.edu:
> [A complimentary Cc of this posting was sent to
> Graham Drabble
> <graham.drabble@lineone.net>], who wrote in article
> <Xns95BDB5D279355grahamdrabblelineone@ID-77355.user.dfncis.de>:
>> I have a file that contains a list of numbers. I'm trying to
>> process the file to find out how many rows start with 4
>> consecutive digits (either ascending or decending). Currently
>> I've got
>
> I'm puzzled at all complications: what is wrong with using
> something like
>
> my $four = substr $in, 0, 4;
> print 'OK' if length $four == 4 and
> (0 <= index '0123456789', $four or 0 <= index '9876543210',
> $four);
Thanks everyone. I think I'm going to go with this one, partly for
speed and partly because it's simple enough that when I come back to
it I'll know what it does!
Is there any reason that you've used 0<= index rather than index >=0?
--
Graham Drabble
If you're interested in what goes on in other groups or want to find
an interesting group to read then check news.groups.reviews for what
others have to say or contribute a review for others to read.
------------------------------
Date: 13 Dec 2004 01:36:52 GMT
From: Christopher Nehren <apeiron+usenet@coitusmentis.info>
Subject: Re: Consecutive Numbers
Message-Id: <slrncrpsho.r6d.apeiron+usenet@prophecy.dyndns.org>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
On 2004-12-13, Graham Drabble scribbled these
curious markings:
> Is there any reason that you've used 0<= index rather than index >=0?
It's an extension of a technique used to prevent the all-too-common:
if($var = 0) { mumble() }
where
if($var == 0) { mumble() }
is what was meant. At least, that's how I understand it. I personally
don't see the point of doing that with relational operators other than
==, but I'm sure that someone can specify a reason.
Best Regards,
Christopher Nehren
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.6 (FreeBSD)
iD8DBQFBvPI4k/lo7zvzJioRAkFFAJ4yzuG6Ln/q2gPwb9G14fGqC7+C+gCgsfYg
jNKKQEOABKaheJAjVJEaICQ=
=RnOJ
-----END PGP SIGNATURE-----
--
I abhor a system designed for the "user", if that word is a coded
pejorative meaning "stupid and unsophisticated". -- Ken Thompson
If you ask the wrong questions, you get answers like "42" and "God".
Unix is user friendly. However, it isn't idiot friendly.
------------------------------
Date: Mon, 13 Dec 2004 07:03:47 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Consecutive Numbers
Message-Id: <n9bvd.64215$6f6.6294@edtnps89>
Graham Drabble wrote:
> On 12 Dec 2004 Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote in
> news:cpifp9$qjh$1@agate.berkeley.edu:
>
>>[A complimentary Cc of this posting was sent to
>>Graham Drabble
>><graham.drabble@lineone.net>], who wrote in article
>><Xns95BDB5D279355grahamdrabblelineone@ID-77355.user.dfncis.de>:
>>
>>>I have a file that contains a list of numbers. I'm trying to
>>>process the file to find out how many rows start with 4
>>>consecutive digits (either ascending or decending). Currently
>>>I've got
>>
>>I'm puzzled at all complications: what is wrong with using
>>something like
>>
>> my $four = substr $in, 0, 4;
>> print 'OK' if length $four == 4 and
>> (0 <= index '0123456789', $four or 0 <= index '9876543210',
>> $four);
>
> Thanks everyone. I think I'm going to go with this one, partly for
> speed and partly because it's simple enough that when I come back to
> it I'll know what it does!
>
> Is there any reason that you've used 0<= index rather than index >=0?
Because of precedence (see perlop.) "index $a, $b >= 0" would require
parentheses "index( $a, $b ) >= 0" or it would be interpreted by perl as
"index $a, ( $b >= 0 )" while "0 <= index $a, $b" does not require parentheses.
John
--
use Perl;
program
fulfillment
------------------------------
Date: 13 Dec 2004 11:16:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: forwarding cgi->param()
Message-Id: <cpjtlq$7e2$1@mamenchi.zrz.TU-Berlin.DE>
<krakle@visto.com> wrote in comp.lang.perl.misc:
>
> David Efflandt wrote:
> > On Fri, 10 Dec 2004 21:27:14 +0000, Colombo <colo@megapolis.pl>
> wrote:
> > > hi,
> > > how to forward parameters from $cgi->param() to another page when I
>
> > > don't know how many parameters are there and how they are called?
> >
> > Not clear if you are generating another form and want to pass
> variables
> > through it, or attempting to redirect them to some other handler.
> But to
> > pass submitted variables through another form as hidden variables,
> > somewhere within the CGI generated form do something like:
> >
> > foreach ($cgi->param) { print $cgi->hidden($_), "\n"; }
> Their is VARS..
Sloppy English...
> my $FORM = $cgi->Vars;
>
> now $FORM{'name'}
...sloppy code.
Nothing new there.
Anno
------------------------------
Date: Sun, 12 Dec 2004 15:59:54 -0800
From: "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com>
Subject: Re: get startup / running time of a process?
Message-Id: <3244buF3hng0rU1@individual.net>
Sherm Pendley wrote:
> Crom wrote:
>
>> Is there a portable way of obtaining the start up and/or elapsed time
>> since start (which I suppose could be calculated given the start
>> time, so no biggy, just need the start time.)
>>
>> I've been searching exhaustively in both google groups without many
>> leads. My target systems are Linux and Freebsd, though a portable
>> solution would be nice, but not necessary.
>
> A minute of perldoc is worth an hour of Google. From 'perldoc
> perlvar':
>
> $BASETIME
> $^T The time at which the program began running, in seconds since
> the epoch (beginning of 1970). The values returned by the
> -M, -A, and -C filetests are based on this value.
Correct me if I'm wrong but isn't that only for the running script
itself? I got the impression the op wanted to do it for any given app
thats running on the system out side of the script.
------------------------------
Date: Mon, 13 Dec 2004 13:55:26 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: grammar function
Message-Id: <8h7rr01d6go9o0k8tm0bfspjov6obgotr4@4ax.com>
Ala Qumsieh wrote:
>Ken Sington wrote:
>> } elsif ($word =~ m/ey$/){
>> $returnIt = $word =~ s/ey$/ies/; # monkey -> monkies
>
>What about "key"? -> keys.
Webster (USA) says the plural of "monkey" is "monkeys", which makes more
sense to me anyway. Ditto with the other online dict.
<http://www.webster.com/cgi-bin/dictionary?va=monkey>
<http://dictionary.reference.com/search?q=monkey>
What dialect is "monkies" supposed to be, anyway?
"Freesearch", a UK based site, mentions "monkeys" too, though not so
explicitely: "Monkeys are primates"
<http://www.freesearch.co.uk/dictionary/monkey+%28animal%29>
--
Bart.
------------------------------
Date: 13 Dec 2004 13:13:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Loop Logic Question
Message-Id: <cpk4if$ei8$1@mamenchi.zrz.TU-Berlin.DE>
John W. Krahn <krahnj@telus.net> wrote in comp.lang.perl.misc:
> Chip wrote:
> >
> > I have a text file that I need to convert
> > from a vertical list to a horizontal comma
> > delimited file that will always have the
> > same number (12) items in it.
> >
> > The first item in each line is a serial
> > number that is always 17 characters followed
> > by a model number, stock number, sale price,
> > cost, color, then a list of options which
> > can vary between 1 to 6.
[...]
> > Example files;
> >
> > <vertical.txt>
> > 2G1WF52E849457786
> > 1WF19
> > 9457786
> > 24600.00
> > 22988.78
> > White/Lt Gray/cloth
> > B34 FLOOR MATS
> > FE9 FEDERAL EMISSION EQUIPMENT
> > K34 ELECTRONIC SPEED CONTROL
> > 2G1WF52EX49457241
> > 1WF19
> > 9457241
> > 22725.00
> > 21282.53
> > White/Light Gray Clth
> > B34 FLOOR MATS
> > FE9 FEDERAL EMISSION EQUIPMENT
> > K34 ELECTRONIC SPEED CONTROL
> > LA1 3.4 V6 ENGINE
> > MX0 4 SPEED AUTO W/OVERDRIVE
> > 2G1WP551449281308
> > 1WP19
> > 9281308
> > 32835.00
> > 30542.19
> > Black/Lt Gray Leather
> > AW6 DRIVERS SIDE AIRBAG
> > CF5 ELECTRIC SUNROOF
> > FE9 FEDERAL EMISSION EQUIPMENT
> > L67 SUPERCHARGED 3.8L SFI V6
> > MX0 4 SPEED AUTO W/OVERDRIVE
> > UP0 AM/FM CASS/CD PLAYER
> > </vertical.txt>
> >
> > <formatted file>
> > 2G1WF52E849457786,1WF19,9457786,24600.00,22988.78,White/Lt Gray/cloth,B34
> > FLOOR MATS,FE9 FEDERAL EMISSION EQUIPMENT,K34 ELECTRONIC SPEED CONTROL,,,,
> > 2G1WF52EX49457241,1WF19,9457241,22725.00,21282.53,White/Light Gray Clth,B34
> > FLOOR MATS,FE9 FEDERAL EMISSION EQUIPMENT,K34 ELECTRONIC SPEED CONTROL,LA1
> > 3.4 V6 ENGINE,MX0 4 SPEED AUTO W/OVERDRIVE,,
> > 2G1WP551449281308,1WP19,9281308,32835.00,30542.19,Black/Lt Gray Leather,AW6
> > DRIVERS SIDE AIRBAG,CF5 ELECTRIC SUNROOF,FE9 FEDERAL EMISSION EQUIPMENT,L67
> > SUPERCHARGED 3.8L SFI V6,MX0 4 SPEED AUTO W/OVERDRIVE,UP0 AM/FM CASS/CD
> > PLAYER,
> > </formatted file>
These output lines have 13 items each, not 12.
> This appears to do what you require:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> my $filename = 'vertical.txt';
> open FILE, '<', $filename or die "Could not open $filename: $!";
>
> my @data;
> while ( <FILE> ) {
> chomp;
> if ( /^\w{17}$/ or eof FILE ) {
> push @data, $_ if eof FILE;
> if ( @data ) {
> no warnings 'uninitialized';
> print join( ',', @data[ 0 .. 12 ] ), "\n";
> }
> @data = $_;
> }
> else {
> push @data, $_;
> }
> }
>
> __END__
That can be simplified a little. The only situation you need to
recognize in the loop is "is there a complete output record".
(I'm going for 12 items per record, not 13):
my @data;
while ( <DATA> ) {
chomp;
if ( ( /^\S{17}$/ or eof) and @data ) {
print join( ',', @data, ( '') x (12 - @data)), "\n";
@data = ();
}
push @data, $_;
}
Anno
------------------------------
Date: Mon, 13 Dec 2004 03:08:12 GMT
From: ChrisO <ceo@nospam.on.net>
Subject: Re: mod_perl headaches
Message-Id: <wI7vd.32056$Rf1.31667@newssvr19.news.prodigy.com>
Andrew Burton wrote:
>>Well probably the mod_perl mailing list would be the most appropriate.
>
>
> Thank you. I will try and report there. Hack finding and searching the
> archive may solve my problem. Thanks.
>
>
>
>>What do you mean by "refuses to run"?
>
>
> Basically, it just doesn't run. When I comment out the libperl.so line, Apache
> runs. I can view files, see directories, PHP works, etc. However, when I
> leave the libperl.so line uncommented, nothing happens. I start up Apache with
> the standard "apachectl start" command, it says that it's started, but trying
> to access webpages does nothing.
>
>
>
>>Can you please show the Apache directives you use to load mod_perl?
>
>
> I think so. Is this what you mean:
>
> perl Makefile.PL USE_APXS=1 WITH_APXS=/usr/local/apache/bin/apxs EVERYTHING=1
>
> ...or did you mean the LoadModule line from httpd.conf:
>
> #LoadModule perl_module libexec/libperl.so
>
> (It's currently commented out, so ignore the pound at the beginning of the
> line.)
>
The latter is what Brian meant, I'm sure. I'm by NO MEANS a mod_perl
expert, but as I recall, getting mod_perl and PHP to work together was a
bit of an issue and remember the symptoms being the same as yours: using
only PHP, I was fine -- as soon as I tried to "turn on" mod_perl, Apache
refused to run. If memory serves, my problem was solved by the order of
the directives in httpd.conf which turned out to be:
LoadModule perl_module modules/mod_perl.so
LoadModule php4_module modules/libphp4.so
PerlModule Apache2
I'm running Apache 2 as you can see. I also have mono running
successfully as well, but I stripped that LoadModule for simplicity.
HTH, and again this is by no means an authoritative reply. It worked
for me.
-ceo
------------------------------
Date: Sun, 12 Dec 2004 20:58:53 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: mod_perl headaches
Message-Id: <56kv82xabe.ln2@goaway.wombat.san-francisco.ca.us>
On 2004-12-12, Andrew Burton <tuglyraisin@aol.commcast> wrote:
> If this needs to be in c.l.p.mods, please let me know and I will repost there.
> The topic seems kind of module-ish, kind of Perl-ish, and kind of Apache-ish;
> so I thought misc would be best.
It looks like you've already gotten an answer, but I'll throw in anyway:
there's a mod_perl mailing list, which you can find at
http://perl.apache.org where you might get a faster and/or better answer
to mod_perl difficulties.
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
------------------------------
Date: Mon, 13 Dec 2004 09:06:44 GMT
From: Joe Smith <joe@inwap.com>
Subject: Re: mod_perl headaches
Message-Id: <EYcvd.751938$8_6.350237@attbi_s04>
Andrew Burton wrote:
> I stopped Apache, uncommented the line, and cleared error_log -- I went inn
> with vi, and deleted every line; that seemed safer than deleting the file and
> touch'ing a new one.
The command
: >/var/log/httpd/error_log
works with both csh/tcsh and sh/bash for truncating a file to 0 bytes.
-Joe
------------------------------
Date: Mon, 13 Dec 2004 01:00:10 GMT
From: Terry <just@say.no>
Subject: Re: Need help with constants and package names.
Message-Id: <g4qpr0l8b3g5ibiee7757j7iu6rs1irsg3@4ax.com>
On Sun, 12 Dec 2004 17:24:16 -0500, Sherm Pendley <spamtrap@dot-app.org>
wrote:
>I haven't found a way to do that either - and believe me I've tried. In
>my CamelBones project I have one file with over a hundred constants -
>each one appears twice, once to define its value and once in @EXPORT.
Thanks anyway. I looked at your CamelBones project too - very
interesting!
>To call a class method like new(), you need to specify the full class
>name, not just the last component of it:
>
>my $obj = One::Two::Obj->new();
Ah, got it. I was expecting it to be Java-ish, where after the package
is imported, it can be instantiated via its class name only.
Thanks again for the help Sherm.
-Terry
------------------------------
Date: Mon, 13 Dec 2004 01:01:32 GMT
From: Terry <just@say.no>
Subject: Re: Need help with constants and package names.
Message-Id: <pbqpr0l9fdouk7mvhoicg4vnti00n8d8os@4ax.com>
On 12 Dec 2004 21:40:32 GMT, "A. Sinan Unur" <1usa@llenroc.ude.invalid>
wrote:
>Christopher Nehren <apeiron+usenet@coitusmentis.info> wrote in
>news:slrncrpeet.2dsb.apeiron+usenet@prophecy.dyndns.org:
>
>> In further addition, I'd like to suggest Module::Starter (and its
>> command-line frontend, module-starter) as a modern alternative /
>> complement to h2xs.
>
>I did not know about this module. Thanks very much.
>
>Sinan.
Thanks for the help on this thread! I'm working with a refactor of some
existing code, but I'll remember this the next time I need to create a
module.
-Terry
------------------------------
Date: 13 Dec 2004 11:13:27 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Newbie questions, migrating from c++
Message-Id: <yzdwtvmld4o.fsf@invalid.net>
Paul Lalli <mritty@gmail.com> writes:
> gg500@lycos.com wrote:
> > Thanks, that seems is the correct way. However I get those warnings
> > which I have mentioned and I have to add the weird condition not to
> > receive warning:
> > /^(\s+)/;
> > $i=defined ($1) ? length($1) : 0;
> > If I write:
> > /^(\s+)/;
> > $i=length($1);
> > I get "Use of uninitialized value in length..."
>
> That's because you snipped a very important part of the code:
>
> if(/^(\s+)/) {
> print length($1),"\n";
> }
>
> You should never ever use $1, $2, etc without ensuring that the
> pattern match succeeded. A better way to write this might be:
>
> $len = (/^(\s+)/ ? length($1) : 0);
> print "$len space characters start the string\n";
For some reason I don't get the mentioned warnings in my perl 5.005;
maybe more modern perls do. I do get a warning if I try to print $1.
But why not do
/^(\s*)/;
$i=length($1);
in this case? The match is guaranteed to succeed (isn't it?), and the
number 0 is not treated as a special case.
------------------------------
Date: 13 Dec 2004 11:24:35 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Newbie questions, migrating from c++
Message-Id: <yzdsm6alcm4.fsf@invalid.net>
gg500@lycos.com writes:
> If I write "split /\./, $ENV(REMOTE_ADDR)" I get warning about using
> undefined variable, so without knowing how exactly I should proceed I
> have written abundant amount of lines like "defined $ENV{REMOTE_ADDR} ?
> $ENV{REMOTE_ADDR} : """. Obviously I do not understand the
> fundamentals, so could you please explain what I do wrong since I get
> myself into this situation?
If your aim is to avoid repeating code, you can use an auxiliary variable:
$e = $ENV{REMOTE_ADDR};
$e = "" unless defined $e;
Or you can write a subroutine to obtain a value, defaulting if needed
(not tested):
sub getvar {
my ($name, $default) = @_;
defined $ENV{$name} ? $ENV{$name} : $default;
}
... = getvar("REMOTE_ADDR", "");
Others have suggested using packages from CPAN. Studying the
source code for them may give you insights on how to write similar
code yourself.
------------------------------
Date: Mon, 13 Dec 2004 16:18:01 +1100
From: "Andrew Hamm" <ahamm@mail.com>
Subject: Re: Paragraph separation for DOS files on Unix
Message-Id: <324n0cF3g7c6kU1@individual.net>
Ben Morrow wrote:
>>
>> Assuming you are using a sufficiently modern version of Perl, have a
>> fresh look at the "IO layers" or "disciplines" of the open call. I'm
>> actually struggling to find a suitable perldoc section (someone else
>> will surely post one),
>
> Err... the obvious place? perldoc -f open points you at perldoc open
> and perldoc PerlIO.
My perldoc doesn't detail much about the disciplines/layers... maybe I
didn't hunt long enough.
> The stuff in the Camel about IO 'disciplines' is mostly incorrect in
> detail, as it hadn't been written at that time. They are now called
> 'layers', and there is no :para. :crlf, however, will do what the OP
> wants (though not what I think it should do... :) ).
ok. It did sound really bleeding edge from the Camel book - in fact I
think it includes a disclaimer that it's not even complete yet. I haven't
had need to use any disciplines in my work.
hahahah - PerlIO literally. Damn. Interesting stuff - it's quite changed
from Camel book days.
------------------------------
Date: Mon, 13 Dec 2004 16:11:40 +1100
From: "Andrew Hamm" <ahamm@mail.com>
Subject: Re: perl port to my m68k calculator
Message-Id: <324mkiF3iliboU1@individual.net>
bulk88@hotmail.com wrote:
>
> It has 256KB RAM, 188KB after OS, and 2.7MB FlashROM (effectivly hard
> drive). Its a 12mhz Motorola 68000 processor, faster than the
> Macintosh Classic realeased in 1993 (which has 8mhz).
OK. Well, I think nobody else is responding because they don't take it
seriously, or even think you are trolling, but I'm willing to entertain
another reply.
Given those resources, faggeddaboudit !
you'll be much better off with a free-source version of Tiny BASIC from
somewhere. I have no idea where to look, but surely some google searches
will turn up a whole rash of source code for BASIC's. Pick one that sounds
like it's got string handling that you can live with.
------------------------------
Date: Mon, 13 Dec 2004 03:37:43 GMT
From: ChrisO <ceo@nospam.on.net>
Subject: Re: rsh daemon written in perl?
Message-Id: <b88vd.32064$Rf1.27028@newssvr19.news.prodigy.com>
Joe Bloggs wrote:
> Wondering if anyone has already written a rsh daemon in Perl?
>
> Have found rsh client, but no rsh daemon server element.
> http://cpan.uwinnipeg.ca/dist/Net-Rsh
>
I've written both an "rsh" client and server solution in Perl using
XML-RPC. It's rather trivial to do:
SERVER CODE:
#!/usr/bin/perl
$|++;
## Pragmas.
use strict;
use warnings qw( all );
## Modules.
use Frontier::Daemon;
## Setup XML-RPC web service on designated port.
Frontier::Daemon->new(
LocalPort => 8192,
methods => {
'test.rpc' => sub { 'Hello, mate!' )
'my.shell' => sub { my $o = shell( @_ ); $o },
}
);
## Subroutine: shell
## Executes each parameter and returns results in one array (ref).
sub shell {
my @output;
for (@_) { push @output, `$_` }
chomp @_;
return wantarray ? @output : \@output;
}
__END__
CLIENT CODE:
#!/usr/bin/perl
$|++;
## Pragmas.
use strict;
use warnings qw( all );
## Modules.
use Carp;
use Frontier::Client;
## Make RPC shell call.
my $url = shift || croak "Need URL";
## Or hardcode URL:
##
## my $url = "http://my_local_lan_web_server/RPC2";
my $rpc = Frontier::Client->new( url => $url, proxy => $ENV{http_proxy} );
my $rv = $rpc->call( 'my.shell', @ARGV );
## Display remote shell output.
puts( @{$rv} );
## Subroutine: puts
## Puts output to STDOUT, Ruby-style.
sub puts { for (@_) { print "$_\n" } }
__END__
Example where client code is called "rpcsh.pl":
$ rpcsh http://myserver.local/RPC2 "ls -l /home/chris"
total 57
drwxr-xr-x 4 chris users 376 Sep 14 09:23 Desktop
drwxr-xr-x 6 chris users 152 May 24 2001 GNUstep
drwxr-xr-x 4 chris users 104 Mar 10 2003 apps
drwxr-xr-x 9 chris users 360 Dec 2 19:06 bck
drwxr-xr-x 3 chris users 512 Oct 14 23:29 bin
drwxr-xr-x 33 chris users 3384 Dec 12 20:27 doc
-rw------- 1 chris users 30496 Dec 27 2003 mbox
drwxr-xr-x 26 chris users 624 Nov 24 11:45 misc
drwxr-xr-x 7 chris users 1528 Nov 22 21:26 pub
drwxr-xr-x 10 chris users 280 Oct 9 19:44 public_html
drwxr-xr-x 21 chris users 544 Dec 2 20:41 src
drwxr-xr-x 3 chris users 80 Nov 23 12:49 var
drwxr-xr-x 27 chris users 2944 Dec 10 23:02 work
drwxr-xr-x 45 chris users 16680 Dec 10 22:23 xfer
Understand that this is EXTREMELY wide-open with absolutely NO security
whatsoever. I'm running this on a server that's behind a firewall where
no one else can get to it and the port selected above (8192) is not
exposed to anyone else (except on the local LAN). But as skeleton code,
it works perfectly. Adding your own security through SSL and/or an
authentication layer shouldn't be any trouble at all.
If you want a CGI-based solution in XML-RPC running over port 80, the
server code is a little different and I can provide that as well if you
like. This is just XML-RPC; there are a zillion other ways to go about
this. You asked for "a" solution.
-ceo
(I can't over-emphasize how UNSECURE this is!!!)
------------------------------
Date: 13 Dec 2004 01:42:55 -0800
From: "JoeBloggs" <joebloggs74@hotmail.com>
Subject: Re: rsh daemon written in perl?
Message-Id: <1102930975.866683.319710@z14g2000cwz.googlegroups.com>
ChrisO wrote:
> I've written both an "rsh" client and server solution in Perl using
> XML-RPC. It's rather trivial to do:
Chris - thanks - that's really useful.
Cheers,
Joe.
------------------------------
Date: Mon, 13 Dec 2004 12:50:01 +0100
From: "Alain Star" <200410+news@pobox.com>
Subject: Sending a binary file through a script (binmode/stdout/mime type)
Message-Id: <41bd81f2$0$16037$626a14ce@news.free.fr>
Hello,
I am trying to write a routine wich, when called from a browser, give the
possibility to download a file.
I have almost succeded but, the only things wich do not work properly is:
- there is no dialog box to choose save / open
- the saved name of the file is wronf (download.cgi.mp3)
Any idea what I am doing wrong? Thanks!
Following, example URL, sub.
http://www.cri.ch/cgi-bin/download.cgi?file=dassault.mp3&send=1
############################################################################
###
sub sendMP3 {
my $file = '/home/sites/site7/data/download/dassault.mp3' ;
open( TUNE, "< $file " ) ;
binmode TUNE ;
my $tunesize = ( stat(TUNE) )[7];
binmode STDOUT ;
print $q->header( -type => 'audio/x-mp3',
-Content_length => $tunesize
);
my $buf; while ( read(TUNE, $buf, 32768) ) { print STDOUT $buf; }
close(TUNE);
exit( 0 );
}
############################################################################
###
------------------------------
Date: Mon, 13 Dec 2004 12:29:34 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Sending a binary file through a script (binmode/stdout/mime type)
Message-Id: <cpk1m3$hmf$1@sun3.bham.ac.uk>
Alain Star wrote:
> Hello,
>
> I am trying to write a routine wich, when called from a browser, give the
> possibility to download a file.
> I have almost succeded but, the only things wich do not work properly is:
> - there is no dialog box to choose save / open
> - the saved name of the file is wronf (download.cgi.mp3)
>
> Any idea what I am doing wrong?
You are posting non-Perl-related questions to a Perl newsgroup. (How do
you think the answer to you question would be different if your CGI was
in C, Java, Bourne-shell, Pascal, FORTRAN...).
Take a look at the Content-disposition HTTP header. A google seach form
content-dispostion should also help you find work-rounds for various
browsers' ideosyncracies.
>
> my $file = '/home/sites/site7/data/download/dassault.mp3' ;
> open( TUNE, "< $file " ) ;
> binmode TUNE ;
>
> my $tunesize = ( stat(TUNE) )[7];
>
> binmode STDOUT ;
>
> print $q->header( -type => 'audio/x-mp3',
> -Content_length => $tunesize
> );
>
> my $buf; while ( read(TUNE, $buf, 32768) ) { print STDOUT $buf; }
>
> close(TUNE);
It is much better simply to generate an internal redirect and let the
web server serve the file directly (taking, if necessary, appropriate
measures in the server config to ensure that the download directory
cannot be accessed bypassing the script).
------------------------------
Date: 13 Dec 2004 02:39:19 -0800
From: grehom@ntlworld.com (Graham Smith)
Subject: Text::Reform - Words are wrapped whole??
Message-Id: <98eb7f13.0412130239.17e56558@posting.google.com>
must be doing something daft but text::reform not wrapping whole words
(sometimes)
my program:
use Text::Reform;
my $format1 = "
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[";
print form $format1, "A piece of text just long enough to demonstrate
peculiar behaviour in this test";
my $format2 = "
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[";
print form $format2, "A piece of text just long enough to demonstrate
peculiar behaviour in this test";
results (under Window XP Pro):
C:\perlSrcs\ebay\test>perl test_reform.pl
A piece of text just long enough to demonstrate peculiar be-
haviour in this test
A piece of text just long enough to demonstrate peculiar
behaviour in this test
why is first use hyphenating word?
------------------------------
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 7514
***************************************