[25713] in Perl-Users-Digest
Perl-Users Digest, Issue: 7953 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 8 03:05:27 2005
Date: Fri, 8 Apr 2005 00:05:12 -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 Fri, 8 Apr 2005 Volume: 10 Number: 7953
Today's topics:
A menu using framebuffer aulne2002@yahoo.ca
Re: A menu using framebuffer <spamtrap@dot-app.org>
Re: asynchronous system shell? <jurgenex@hotmail.com>
Re: asynchronous system shell? <joe@inwap.com>
Re: Basic Regular Expressions question... (Anno Siegel)
Re: Basic Regular Expressions question... <someone@example.com>
Re: Basic Regular Expressions question... (Anno Siegel)
Re: Need script to fix C++ "#include" statements <profmath.developers@gmail.com>
Re: OO and Inheritance <postmaster@castleamber.com>
Perl function for negative integers using the 2's compl <liam@nedernet.net>
Re: Perl function for negative integers using the 2's c <see_sig@invalid>
Re: Perl function for negative integers using the 2's c <joe@inwap.com>
Re: Perl on TRIPOD hosted sites..file uploading questio <jwkenne@attglobal.net>
Re: Perl on TRIPOD hosted sites..file uploading questio <jwkenne@attglobal.net>
Re: Perl on TRIPOD hosted sites..file uploading questio <wdflannery@aol.com>
Re: Perl on TRIPOD hosted sites..file uploading questio axel@white-eagle.invalid.uk
Re: Perl on TRIPOD hosted sites..file uploading questio <segraves_f13@mindspring.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Apr 2005 16:18:12 -0700
From: aulne2002@yahoo.ca
Subject: A menu using framebuffer
Message-Id: <1112915892.565960.148530@f14g2000cwb.googlegroups.com>
Hi all,
Is it possible at all to build a graphical menu system without X,
using Perl and modules ? I mean, is there some high-level toolkit
(module) for Perl that offers dialog boxes, windows, etc, needed for
menus ? Context is, after booting from a USB key, a graphical menu
proposes the user some choices.
Is this (easily) possible with Perl at all ?
Cheers,
Al
------------------------------
Date: Thu, 07 Apr 2005 20:12:51 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: A menu using framebuffer
Message-Id: <4uSdndxJIaoZUcjfRVn-hw@adelphia.com>
aulne2002@yahoo.ca wrote:
> Is it possible at all to build a graphical menu system without X,
> using Perl and modules ? I mean, is there some high-level toolkit
> (module) for Perl that offers dialog boxes, windows, etc, needed for
> menus ? Context is, after booting from a USB key, a graphical menu
> proposes the user some choices.
>
> Is this (easily) possible with Perl at all ?
GTK+ can be built for a framebuffer w/o X. You might be able to convince
Gtk-Perl to use that.
<http://developer.gnome.org/doc/API/2.0/gtk/gtk-framebuffer.html>
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Fri, 08 Apr 2005 00:53:20 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: asynchronous system shell?
Message-Id: <4Ck5e.950$qO6.354@trnddc05>
Ninja67 wrote:
> xhos...@gmail.com wrote:
>> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote:
>> Add an "&" to the end. see:
>> perldoc -q background.
>
> That worked! You're a genius! Now that sure was easy. I wonder why
> it was so hard to find anything on that.
Because it has nothing to do with Perl (in Perl you would fork() and exec())
but with how your shell starts processes in the background.
jue
------------------------------
Date: Thu, 07 Apr 2005 23:08:49 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: asynchronous system shell?
Message-Id: <4q2dnepGMc9sgsvfRVn-qQ@comcast.com>
Ninja67 wrote:
>>Add an "&" to the end. see:
>>perldoc -q background.
>
> That worked! You're a genius! Now that sure was easy. I wonder why
> it was so hard to find anything on that.
Hard to find?
perldoc -f system
system LIST
Does exactly the same thing as "exec LIST", except that a fork
is done first, and the parent process waits for the child pro-
cess to complete. Note that argument processing varies depend-
ing on the number of arguments. If there is more than one
argument in LIST, or if LIST is an array with more than one
value, starts the program given by the first element of the
list with arguments given by the rest of the list. If there is
only one scalar argument, the argument is checked for shell
metacharacters, and if there are any, the entire argument is
passed to the system's command shell for parsing (this is
"/bin/sh -c" on Unix platforms, but varies on other platforms).
That last line implies that you should look at the manual for the
Bourne shell to see how /bin/sh will handle the LIST. Since you
are using "2>/dev/null" is it obvious that you are at least
somewhat familiar with Bourne shell metacharacters.
-Joe
------------------------------
Date: 7 Apr 2005 22:06:43 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Basic Regular Expressions question...
Message-Id: <d34atj$89p$1@mamenchi.zrz.TU-Berlin.DE>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > Gunnar Hjalmarsson wrote:
> >> However, to take the /g modifier into consideration (which the OP
> >> originally used), you seem to need something like:
> >>
> >> my ($i, $length) = (0,0);
> >> while ( ( $i = index $thisPage, $find, $i+$length ) >= 0 ) {
> >> $length = length $find;
> >> substr $thisPage, $i, $length, $replace;
> >> }
> >>
> >> That's much typing to 'emulate'
> >>
> >> $thispage =~ s/\Q$find/$replace/g;
> >
> > A bit tighter:
> >
> > my $i = -1;
> > substr $thisPage, $i, length $find, $replace while
> > ( $i = index $thisPage, $find, $i + 1) >= 0;
>
> Yeah, but I just realized that neither of the above index() + substr()
> solutions would work on e.g. this set of input:
>
> my $thisPage = "It's a ball. The ball is brown.";
> my $find = 'ball';
> my $replace = 'football';
>
> Isn't it something like this that's needed:
>
> my $repl_length = length $replace;
> my $i = -$repl_length;
> while ( ( $i = index $thisPage, $find, $i + $repl_length ) >= 0 ) {
> substr $thisPage, $i, length $find, $replace;
> }
You're right, though I wouldn't bother with storing the length of
anything. Working backwards runs smoother:
my $i = length $thisPage;
substr( $thisPage, $i, length $find) = $replace while
( $i = rindex $thisPage, $find, $i) >= 0;
That way only the unchanged part of the string is ever searched.
> Maybe no wonder that the s/// operator is frequently used also for
> replacing non-regex patterns when efficiency is not a restriction.
I don't think I've used index for anything but simple location or just
presence/absence. Replacement is too much hassle with the substr() for
my taste.
Anno
------------------------------
Date: Thu, 07 Apr 2005 23:18:07 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Basic Regular Expressions question...
Message-Id: <Pcj5e.7249$VF5.3036@edtnps89>
Anno Siegel wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
>
>>Anno Siegel wrote:
>>
>>>Gunnar Hjalmarsson wrote:
>>>
>>>>However, to take the /g modifier into consideration (which the OP
>>>>originally used), you seem to need something like:
>>>>
>>>> my ($i, $length) = (0,0);
>>>> while ( ( $i = index $thisPage, $find, $i+$length ) >= 0 ) {
>>>> $length = length $find;
>>>> substr $thisPage, $i, $length, $replace;
>>>> }
>>>>
>>>>That's much typing to 'emulate'
>>>>
>>>> $thispage =~ s/\Q$find/$replace/g;
>>>
>>>A bit tighter:
>>>
>>> my $i = -1;
>>> substr $thisPage, $i, length $find, $replace while
>>> ( $i = index $thisPage, $find, $i + 1) >= 0;
>>
>>Yeah, but I just realized that neither of the above index() + substr()
>>solutions would work on e.g. this set of input:
>>
>> my $thisPage = "It's a ball. The ball is brown.";
>> my $find = 'ball';
>> my $replace = 'football';
>>
>>Isn't it something like this that's needed:
>>
>> my $repl_length = length $replace;
>> my $i = -$repl_length;
>> while ( ( $i = index $thisPage, $find, $i + $repl_length ) >= 0 ) {
>> substr $thisPage, $i, length $find, $replace;
>> }
>
>
> You're right, though I wouldn't bother with storing the length of
> anything. Working backwards runs smoother:
>
> my $i = length $thisPage;
> substr( $thisPage, $i, length $find) = $replace while
> ( $i = rindex $thisPage, $find, $i) >= 0;
>
> That way only the unchanged part of the string is ever searched.
Also, using the four argument substr() should be faster.
my $i = length $thisPage;
substr $thisPage, $i, length $find, $replace
while ( $i = rindex $thisPage, $find, $i ) >= 0;
John
--
use Perl;
program
fulfillment
------------------------------
Date: 8 Apr 2005 05:57:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Basic Regular Expressions question...
Message-Id: <d356gj$m99$1@mamenchi.zrz.TU-Berlin.DE>
John W. Krahn <krahnj@telus.net> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
[using index() instead of s///]
> > my $i = length $thisPage;
> > substr( $thisPage, $i, length $find) = $replace while
> > ( $i = rindex $thisPage, $find, $i) >= 0;
> >
> > That way only the unchanged part of the string is ever searched.
>
> Also, using the four argument substr() should be faster.
How so? I never heard of that.
I use "=" with substr() assignments because it reads better. Four argument
substr is for when I need the old value of the substring too.
> my $i = length $thisPage;
> substr $thisPage, $i, length $find, $replace
> while ( $i = rindex $thisPage, $find, $i ) >= 0;
Anno
------------------------------
Date: 7 Apr 2005 20:07:07 -0700
From: "profmath.developers@gmail.com" <profmath.developers@gmail.com>
Subject: Re: Need script to fix C++ "#include" statements
Message-Id: <1112929627.424969.122150@o13g2000cwo.googlegroups.com>
Ed J wrote:
> I'm porting a large Windows C++ application to Linux and ran into a
big
> hassle because of the case-sensitivity of filenames.
...
> I know a pro could write such a script in two minutes. I use Perl
once a
> year. It would take me two hours at least!
>
> Thanks bunches!!
> Ed
It would probably take a lot less time for you to program it then for
you to just sit around waiting for someone to quickly send you an email
saying "Don't worry! I've made your program for nothing because I
really want to to succeed in life, and I want you to learn how to
program like a 'pro'!"
------------------------------
Date: 8 Apr 2005 02:25:23 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: OO and Inheritance
Message-Id: <Xns9631D9890202Dcastleamber@130.133.1.4>
wrote:
> OK. Let's say I read that book cover to cover (I have read bits and
> pieces of it). Which sections or concepts should I pay particular
> attention to?
The part talking about Netiquette. Ah! You are not talking about a book on
Usenet :-)
>> That can be remedied with the book "Object Oriented Perl" by Conway.
I normally recommend to read a book cover to cover, not bits and pieces.
And then read it again and make notes :-D.
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 7 Apr 2005 18:42:01 -0700
From: "stylechief" <liam@nedernet.net>
Subject: Perl function for negative integers using the 2's complement in hex?
Message-Id: <1112924521.518881.126340@o13g2000cwo.googlegroups.com>
I cannot seem to find a Perl function that will return the 2's
complement of a negative integer represented in hex.
For example:
ffbe8e should return -16754, not 16760462
hex() works fine for positive integers but not here
pack/unpack don't seem to want to produce anything negative (just 0)
I imagine that there is a 'brute force' method, but it seems that there
should be an eloquent function that speaks in 2's complement . . . .
Thanks,
Liam
------------------------------
Date: Thu, 07 Apr 2005 22:36:08 -0400
From: Bob Walton <see_sig@invalid>
Subject: Re: Perl function for negative integers using the 2's complement in hex?
Message-Id: <4255ef0a$1_1@127.0.0.1>
stylechief wrote:
> I cannot seem to find a Perl function that will return the 2's
> complement of a negative integer represented in hex.
> For example:
> ffbe8e should return -16754, not 16760462
Well, on a 32-bit computer, that should be ffffbe8e. ffbe8e
would be the same as 00ffbe8e, which is positive.
Try:
perl -e "print unpack 'i',pack 'i',0xffffbe8e"
[exchange " and ' for Unix or Unix-like systems]
>
> hex() works fine for positive integers but not here
> pack/unpack don't seem to want to produce anything negative (just 0)
>
> I imagine that there is a 'brute force' method, but it seems that there
> should be an eloquent function that speaks in 2's complement . . . .
...
> Liam
>
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
------------------------------
Date: Thu, 07 Apr 2005 22:29:48 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Perl function for negative integers using the 2's complement in hex?
Message-Id: <i_mdndTh7pFRi8vfRVn-oA@comcast.com>
stylechief wrote:
> I cannot seem to find a Perl function that will return the 2's
> complement of a negative integer represented in hex.
> For example:
> ffbe8e should return -16754, not 16760462
You have to remember that 32-bit integers are represented by
eight hex digits, not six.
linux% perl -le 'printf "%d %d\n",0xffbe8e,0xffffbe8e'
16760462 -16754
If you have a 24-bit number you will need to sign-extend the
most significant bit in order to produce a 32-bit number.
linux% cat temp
$bits_24 = hex("ffbe8e");
$bits_32 = $bits_24 | (($bits_24 & 0x800000) ? 0xff000000 : 0);
printf "%d %.0f\n", $bits_32, $bits_32;
linux% perl temp
-16754 4294950542
------------------------------
Date: Thu, 07 Apr 2005 19:16:23 -0400
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Perl on TRIPOD hosted sites..file uploading question..
Message-Id: <dbj5e.112$2r1.44@fe12.lga>
joesplink wrote:
> www.tripod.com has free web hosting with CGI and PERL,
"CGI and PERL" in this case meaning "CGI written in Perl and nothing else".
> however there
> may be some limitations. I've got a PERL program that I use on another
> host to upload files..... and it works fine.... however, it doesn't
> work on my TRIPOD hosted site.....I asked support at TRIPOD about this
> but didn't get a response....(I've asked them again)....
Antique version of Perl -- 5.008.
Antique version of cgi.pm.
NO other standard modules at all (including pragmas). About four
moderately useful Tripod-written modules.
--
John W. Kennedy
"Never try to take over the international economy based on a radical
feminist agenda if you're not sure your leader isn't a transvestite."
-- David Misch: "She-Spies", "While You Were Out"
------------------------------
Date: Thu, 07 Apr 2005 19:18:33 -0400
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Perl on TRIPOD hosted sites..file uploading question..
Message-Id: <edj5e.113$1r1.59@fe12.lga>
joesplink wrote:
> TRIPOD has their own version of GCI, called TripodCGI....they don't
> provide any documentaton.
No, they also provide cgi.pm (but an ancient version). TripodCGI.pm is
something else.
--
John W. Kennedy
"...if you had to fall in love with someone who was evil, I can see why
it was her."
-- "Alias"
------------------------------
Date: 7 Apr 2005 18:33:39 -0700
From: "joesplink" <wdflannery@aol.com>
Subject: Re: Perl on TRIPOD hosted sites..file uploading question..
Message-Id: <1112924019.598645.95480@o13g2000cwo.googlegroups.com>
In response to my query about file uploades TRIPOD responded "We don't
support Perl".....seems like a no-go to me.
------------------------------
Date: Thu, 07 Apr 2005 21:28:29 -0500
From: axel@white-eagle.invalid.uk
Subject: Re: Perl on TRIPOD hosted sites..file uploading question..
Message-Id: <74WdnTKCRsrQccjfRVn-pQ@adelphia.com>
joesplink <wdflannery@aol.com> wrote:
> In response to my query about file uploades TRIPOD responded "We don't
> support Perl".....seems like a no-go to me.
Then it is probably best to look elsewhere for a site which supplies a
reasonably up-to-date version of Perl.
It is certainly possible to get webhosting including Perl, FTP,
and login access for about $US 40 p.a.
Axel
------------------------------
Date: Fri, 08 Apr 2005 04:35:09 GMT
From: "Bill Segraves" <segraves_f13@mindspring.com>
Subject: Re: Perl on TRIPOD hosted sites..file uploading question..
Message-Id: <1Sn5e.5341$44.1092@newsread1.news.atl.earthlink.net>
"joesplink" <wdflannery@aol.com> wrote in message
news:1112924019.598645.95480@o13g2000cwo.googlegroups.com...
> In response to my query about file uploads TRIPOD responded "We don't
> support Perl".....seems like a no-go to me.
>
Tripod appears to have Perl v. 5.8.0 and CGI.pm v. 2.30.
You can upload a later version of CGI.pm, if you wish. You'll have to
resolve the dependencies, e.g., missing modules, one-at-a-time, by uploading
the modules that CGI.pm requires/uses, as well as those that your script
requires/uses, as you discover them.
I've just done this exercise with a relatively recent version of CGI.pm,
finding the process to be onerous, but workable.
OTOH, I would not recommend that the OP try to use Tripod's Perl and CGI
capabilities, except for problems that can be solved with the versions of
Perl and the modules furnished by Tripod.
Finally, IMO, the OP's objective of uploading files via a CGI script at
Tripod may be reliable because of the one-second limit imposed by Tripod for
script execution.
--
Bill Segraves
------------------------------
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 7953
***************************************