[27026] in Perl-Users-Digest
Perl-Users Digest, Issue: 8947 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 13 06:05:53 2006
Date: Mon, 13 Feb 2006 03:05:05 -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 Feb 2006 Volume: 10 Number: 8947
Today's topics:
Re: Absolute Novice (Mac Tiger) Needs Help <groleau+news@freeshell.org>
Re: Absolute Novice (Mac Tiger) Needs Help <tadmc@augustmail.com>
Re: Absolute Novice (Mac Tiger) Needs Help <kamins@dogeared.com>
Re: Perl vs. Python <bart.lateur@pandora.be>
Re: Perl vs. Python (Anno Siegel)
Re: Program to generate buttons for sequence of command (Raghuramaiah Gompa)
Re: Trim whitespace with cookbook recipe does not resul <tadmc@augustmail.com>
Re: Trim whitespace with cookbook recipe does not resul <uri@stemsystems.com>
Web form's reply on same page as form. <john@heathdrive.com>
Re: Web form's reply on same page as form. <noreply@gunnar.cc>
Re: Web form's reply on same page as form. <scobloke2@infotop.co.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 13 Feb 2006 03:20:23 GMT
From: Wes Groleau <groleau+news@freeshell.org>
Subject: Re: Absolute Novice (Mac Tiger) Needs Help
Message-Id: <XVSHf.2862$7C3.169@trnddc08>
James Taylor wrote:
> The modern Mac is indistinguishable from Unix for this sort of thing.
In shell and CLI. But not in the backwards-compatible GUI.
> The OP's problem turned out to be wrong newlines.
... caused by writing a shell(perl) script with a
GUI-oriented editor.
--
Wes Groleau
"A man with an experience is never
at the mercy of a man with an argument."
-- Ron Allen
------------------------------
Date: Sun, 12 Feb 2006 22:35:41 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Absolute Novice (Mac Tiger) Needs Help
Message-Id: <slrndv034t.o5h.tadmc@magna.augustmail.com>
James Taylor <usenet@oakseed.demon.co.uk.invalid> wrote:
> The OP's question was solved by getting
> his editor to save text files with linefeeds.
But I thought the OP said that one-liners gave no output either.
Changing editor settings won't change things when the editor
is not being used. :-)
<shrug>
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 12 Feb 2006 21:41:37 -0800
From: Scot Kamins <kamins@dogeared.com>
Subject: Re: Absolute Novice (Mac Tiger) Needs Help
Message-Id: <kamins-9D8CD7.21413712022006@sn-ip.vsrv-sjc.supernews.net>
In article <slrndv034t.o5h.tadmc@magna.augustmail.com>,
Tad McClellan <tadmc@augustmail.com> wrote:
> James Taylor <usenet@oakseed.demon.co.uk.invalid> wrote:
>
> > The OP's question was solved by getting
> > his editor to save text files with linefeeds.
>
>
> But I thought the OP said that one-liners gave no output either.
>
No I'm the OP; one-liners worked fine, as did pasting an entire program
at the command line interface after having entered "perl" and pressing
Return.
Changing the default EOL output in BBEdit to Unix from Mac made
everything work OK.
------------------------------
Date: Mon, 13 Feb 2006 08:27:58 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Perl vs. Python
Message-Id: <lnf0v1ht05ul43kaoph4r3vb0oko5t8m8o@4ax.com>
io wrote:
> it doesn't look to me as if Eric Raymond fully groks
> Perl.
I get the same fully, but then again, I've rejected other languages (and
software) based on no more than a gut feeling than Eric S Raymond
displays here, so I can't really blame him.
> Perl, it looks from
> Conway's book, has a perfectly capable, sane and flexible object
> system.
Well... Flexible, it is. But many very experienced Perl hackers think
that ut's not very sane. It's too easy to shoot yourself in the foot
with. Like, it's almost impossible to subclass a class without knowing
the implementation details of the superclass. For example, if in an
upgrade, the author adds a new (hidden) field, and you used the same
field in your subclass already... it'll blow up.
That's one of the reasons "inside-out objects" were invented. But as you
mention Damian Conway's books a few time, I guess you're familiar with
their existence.
<http://perlmonks.org/?node_id=178518>
--
Bart.
------------------------------
Date: 13 Feb 2006 08:53:04 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl vs. Python
Message-Id: <dsphdg$1cj$2@mamenchi.zrz.TU-Berlin.DE>
Bart Lateur <bart.lateur@pandora.be> wrote in comp.lang.perl.misc:
> io wrote:
>
> > it doesn't look to me as if Eric Raymond fully groks
> > Perl.
>
> I get the same fully, but then again, I've rejected other languages (and
s/fully/impression/ ?
> software) based on no more than a gut feeling than Eric S Raymond
> displays here, so I can't really blame him.
That was your personal decision. You didn't go and publish your gut
feelings as a recommendation at large.
Anno
--
$_='Just another Perl hacker'; print +( join( '', map { eval $_; $@ }
'use warnings FATAL => "all"; printf "%-1s", "\n"', 'use strict; a',
'use warnings FATAL => "all"; "@x"', '1->m') =~
m|${ s/(.)/($1).*/g; \ $_ }|is),',';
------------------------------
Date: Mon, 13 Feb 2006 01:27:16 +0000 (UTC)
From: rgompa@steel.ucs.indiana.edu (Raghuramaiah Gompa)
Subject: Re: Program to generate buttons for sequence of commands
Message-Id: <dson9k$7nm$1@rainier.uits.indiana.edu>
>
>Well I don't have windows to test, but I'll try to get
>you going. In the script, where you go into the launch sub
>
>sub launch {
> my $key = shift;
> my $command = $commands{$key}{'com'};
> if(fork==0){ exec "xterm -hold -e $command" }
>}
>
>you need to change the line
>if(fork==0){ exec "xterm -hold -e $command" }
>
>to something compatible with Windows.
>
>The links I posted showed a few methods.
>The easiest was using system with 1
>
>system(1, $file_to_run );
>
>So first, try changing the sub to
>
>sub launch {
> my $key = shift;
> my $command = $commands{$key}{'com'};
> system( 1, $command }
>}
>
>and don't forget to change the 'com' assignments in the
>%commands hash to your programs
>
>'1-1' => {text => 'Latex test',
> com => "c:\texmf\miktex\bin\latex.exe test",
> color=> 'pink'},
>
>etc
>etc
>
>#######################################################
>If the system( 1, $cmd) dosn't work, you may have to use
>the code from the other node
>
>use Win32::Process;
>Win32::Process::Create($ProcessObj,
> "C:\winnt\notepad.exe",
> "c:\sample.txt",
> 0,
> DETACHED_PROCESS,
> ".") || die "cant find the application";
>
>
>#########################################################
>
>Finally, you may have to experiment a bit yourself.
>Setup a simple script, to see if it launches your app.
>Keep trying until you succeed. :-)
>
>Like:
>##############################################
>#!/usr/bin/perl
>use warnings;
>use strict;
>
>system( 1, "c:\texmf\miktex\bin\latex.exe test");
>
><>; #wait for keypress to simulate continued operation
>__END__
>
>
>#############################################
>You may find that you need something like
>"c:\texmf\miktex\bin\latex.exe", "test",
>
>due to the syntax peculiarities of the windows command line.
>
>Good luck. :-)
>
Once again, thank you very much for all your help. I
followed your advise and modified the code (see below -
button.pl) and it works. :)
But I want a little more than this. Each button should
contain a sequence of commands - not just one - that are
executed one after the other once the button is pressed.
Moreover, these commands should have a options from
button.pl argument. For example,
perl button.pl exam
should make the button 1 to execute
c:\texmf\miktex\bin\latex.exe exam.tex
c:\texmf\miktex\bin\yap.exe exam.dvi
...
...
(in the code below, I had the second command in the
second button - but I want to have this as a second
command in button one - I may have to have more
commands) How can I do this? .. Raghu
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
my $mw = tkinit;
#$mw->geometry("400x400");
my $rF = $mw->Frame( -width => 400 )->grid;
my %buttons;
my %commands = (
'1-1' => {text => 'Latex ',
com => "c:\\texmf\\miktex\\bin\\latex.exe test",
color => 'pink'},
'1-2' => {text => 'yap',
com => "c:\\texmf\\miktex\\bin\\YAP.exe test",
color => 'lightblue'},
'1-3' => {text => 'Date', com =>'date', color=> 'pink'},
'1-4' => {text => 'top', com => 'ls -la', color
=> 'lightblue'},
'2-1' => {text => 'ps', com =>'date', color=> 'pink'},
'2-2' => {text => 'ls', com => 'ls -la', color
=> 'lightblue'},
'2-3' => {text => 'Dateyada', com =>'date',
color=> 'pink'},
'2-4' => {text => 'lsfoobar', com => 'ls -la', color =>
'lightblue'},
'3-1' => {text => 'Datexxxx', com =>'date',
color=> 'pink'},
'3-2' => {text => 'lsccc', com => 'ls -la', color =>
'lightblue'},
'3-3' => {text => 'Datebbbb', com =>'date',
color=> 'pink'},
'3-4' => {text => 'lsnnn', com => 'ls -la', color =>
'lightblue'},
'4-1' => {text => 'Date777', com =>'date',
color=> 'pink'},
'4-2' => {text => 'ls777', com => 'ls -la', color =>
'lightblue'},
'4-3' => {text => 'Dategggcom', com =>'date',
color=> 'pink'},
'4-4' => {text => 'lsgggcom', com => 'ls -la', color =>
'lightblue'},
);
foreach my $key(keys %commands){
my ($i, $j) = split /-/,$key;
$buttons{$key}{'button'} = $rF->Button(
-text => $commands{$key}{'text'},
-background => $commands{$key}{'color'},
-command => sub{ &launch( $key ) }
)->grid(-row=>$i, -column=> $j );
}
MainLoop;
sub launch {
my $key = shift;
my $command = $commands{$key}{'com'};
system( 1, $command );
}
__END__
------------------------------
Date: Sun, 12 Feb 2006 22:52:59 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Trim whitespace with cookbook recipe does not result in trimmed array
Message-Id: <slrndv045b.o5h.tadmc@magna.augustmail.com>
io <io@localhost.localdomain> wrote:
> My intent is to slurp a big text file (say, a chapter from the
> English literature). I then want to trim all the white space and
> newlines,
Here you say _all_ whitespace, but your code appears to be trying
to delete only leading and trailing whitespace.
Which is it?
The value of the implementation is directly proportional to
the value of the specification you know.
> so I get an array of compact text.
my @data = map { s/^\s+//; s/\s+$// } <INPUT>; # untested
> The array slurped up has as many spaces as
> the original. In fact, it looks the same.
^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^
I am afraid that I do not believe you...
> ####################################
> #!/usr/bin/perl
> use warnings;
>
> open INPUT, "textfile" or die $1;
^
^
You missed the SHIFT key there.
It should be $! not $1.
> while(<INPUT>) {
Here you read a line into the $_ variable, but you never output
it, so you should be missing every other line in your output,
ie. it won't "look the same" as the input file.
> my $fh = <INPUT>;
Here you read a 2nd line (you read 2 lines for each loop iteration).
I'd say that $fh is a really poor choice of name for something
that is not a filehandle.
> $fh =~ s/\+$//;
^^
^^
Here you miss an "s".
Please take more care in composing your posts, it is wasteful
to submit the wrong stuff to hundreds of people.
> Is the issue the print statement?
No.
> Is it the stream?
No.
> Is it a scope
> issue with push @data?
No.
> I don't get it!
Perl is doing exactly what you told it to do.
> Please help...
Tell Perl to do something else instead.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 13 Feb 2006 00:22:49 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Trim whitespace with cookbook recipe does not result in trimmed array
Message-Id: <x7mzgvsuhi.fsf@mail.sysarch.com>
>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:
TM> my @data = map { s/^\s+//; s/\s+$// } <INPUT>; # untested
tad, i ashamed of you for posting that line. :) you know the map block
returns its last value and not the original in $_? and even though that
is not in void context, i eschew any side effects in map/grep as they
are meant to be functional in style. so i would slurp first and trim
later:
use File::Slurp
my @data = read_file( 'whatever_file' ) ;
s/^\s+//, s/\s+$// for @data ;
>> The array slurped up has as many spaces as
>> the original. In fact, it looks the same.
TM> ^^^^^^^^^^^^^^^^^
TM> ^^^^^^^^^^^^^^^^^
TM> I am afraid that I do not believe you...
i don't either. since he is not being clear about his goal of removing
whitespace how could we trust his opinion of bad output? we don't even
have a proper spec to test against.
>> Please help...
TM> Tell Perl to do something else instead.
and be accurate in telling us what you actually want done (best with
input and expected output examples) and why you think it is not
working. otherwise we are doing brain surgery on you while wearing
boxing gloves. do you want that?
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: Mon, 13 Feb 2006 07:41:22 -0000
From: "John" <john@heathdrive.com>
Subject: Web form's reply on same page as form.
Message-Id: <gPednWfasvGwpW3eRVnyiw@eclipse.net.uk>
I have a HTML <form> on a page with
"action=www.fred999.com/cgi/hydrogen.pl".
When the form is submitted the answer appears on a new page.
Is there any way that the reply from the perl can *continue* on the same
page as the <form>?
Regards
John
------------------------------
Date: Mon, 13 Feb 2006 09:02:55 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Web form's reply on same page as form.
Message-Id: <45astbF5m01bU1@individual.net>
John wrote:
> I have a HTML <form> on a page with
> "action=www.fred999.com/cgi/hydrogen.pl".
>
> When the form is submitted the answer appears on a new page.
>
> Is there any way that the reply from the perl can *continue* on the same
> page as the <form>?
One way to do that is to let hydrogen.pl generate the form instead of
having it on a static HTML page.
print form();
if ( $ENV{REQUEST_METHOD} eq 'POST' ) {
print result();
}
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 13 Feb 2006 10:23:25 +0000 (UTC)
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Web form's reply on same page as form.
Message-Id: <dspmmt$q46$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com>
John wrote:
> I have a HTML <form> on a page with
> "action=www.fred999.com/cgi/hydrogen.pl".
>
> When the form is submitted the answer appears on a new page.
>
> Is there any way that the reply from the perl can *continue* on the same
> page as the <form>?
>
This is really an HTTP / HTML question, not a Perl question.
Googling for AJAX might help, if you want to see the results of form
submission without the browser fetching a whole web-page.
------------------------------
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 8947
***************************************