[21954] in Perl-Users-Digest
Perl-Users Digest, Issue: 4176 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 26 00:10:42 2002
Date: Mon, 25 Nov 2002 21:10:16 -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, 25 Nov 2002 Volume: 10 Number: 4176
Today's topics:
my/local Scoping subtlies (Gerry Grieve)
Re: my/local Scoping subtlies <jkeen@concentric.net>
Re: my/local Scoping subtlies (Damian James)
Re: my/local Scoping subtlies (Damian James)
Re: Newbie needs help- trying to submit command-line fu (D)
Re: Newbie needs help- trying to submit command-line fu (Tad McClellan)
Re: Newbie needs help- trying to submit command-line fu <palladium@spinn.net>
Newbie, split function, and counter (Westy)
Re: Newbie, split function, and counter <jkeen@concentric.net>
Re: Newbie, split function, and counter <robertbu@hotmail.com>
Re: Perl/Tk <bwalton@rochester.rr.com>
perlcc and perl modules (Return Jasmin)
Re: Question about IO::Socket Usage... <nospam@nospam.com>
Sentence splitter (Caie)
Re: Urgent request for help -- posting to a FORM from a <bart.lateur@pandora.be>
Re: Why can't code print an @array?? <uri@stemsystems.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Nov 2002 02:15:20 GMT
From: grieve@astro.ubc.ca (Gerry Grieve)
Subject: my/local Scoping subtlies
Message-Id: <arulfo$ell$1@nntp.itservices.ubc.ca>
I've blithely using the "my" directive to scope variables in
perl scripts. Now I've stumbled upon a case where the nuances
between my and local seems to be critical. I trying to accessing
list elements with references to their list names. This does not
seem to fall in the categories listed (in PCB) as requiring local.
In reference to the example below, can anyone explain why
the my'ing an array variable doesn't work?
#!/usr/local/bin/perl -w
{
my @I = qw [ i0 i1 i2 ]; # I want to use this
local @C = qw [ c0 c1 c2 ]; # but this works !!
foreach my $stx ( qw [ I C ] )
{
push @{$stx}, $stx."3"; # add to the list
print $stx,":: "; # print list name
print join " ", @{$stx}; # and its elements
print "\n"
}
print "after the ref'ing...\n";
print "I::", join " ", @I, "\n";
print "C::", join " ", @C, "\n";
exit;
}
------------------------------
Date: 26 Nov 2002 02:42:11 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: my/local Scoping subtlies
Message-Id: <arun23$4vt@dispatch.concentric.net>
"Gerry Grieve" <grieve@astro.ubc.ca> wrote in message
news:arulfo$ell$1@nntp.itservices.ubc.ca...
>
> I've blithely using the "my" directive to scope variables in
> perl scripts. Now I've stumbled upon a case where the nuances
> between my and local seems to be critical. I trying to accessing
> list elements with references to their list names. This does not
> seem to fall in the categories listed (in PCB) as requiring local.
>
> In reference to the example below, can anyone explain why
> the my'ing an array variable doesn't work?
>
> #!/usr/local/bin/perl -w
>
> {
> my @I = qw [ i0 i1 i2 ]; # I want to use this
Are you sure you didn't overlook the fact that, in this context, the square
brakcets after 'qw' have nothing to do with referencing. qw [ i0 i1 i2 ] is
exactly the same as qw(i0 i1 i2) or qw |i0 i1 i2|, etc.
> local @C = qw [ c0 c1 c2 ]; # but this works !!
>
>
> foreach my $stx ( qw [ I C ] )
> {
> push @{$stx}, $stx."3"; # add to the list
Hence, the above is wrong: $stx is not an array reference; it's an ordinary
scalar. So @{$s5x} is a syntax error.
If, having commented out the line beginning with 'local', you had run the
script with 'use strict;', you would have immediately gotten this error
message:
Global symbol "@C" requires explicit package name at my.pl line 21.
Motto: Try out your scripts with 'use strict' before posting them to this
newsgroup.
------------------------------
Date: 26 Nov 2002 02:59:13 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: my/local Scoping subtlies
Message-Id: <slrnau5os1.h30.damian@puma.qimr.edu.au>
On 26 Nov 2002 02:15:20 GMT, Gerry Grieve said:
>
>I've blithely using the "my" directive to scope variables in
>perl scripts. Now I've stumbled upon a case where the nuances
>between my and local seems to be critical. I trying to accessing
>list elements with references to their list names. This does not
>seem to fall in the categories listed (in PCB) as requiring local.
PCB? THe Camel book? Anyway, you are using symbolic references, which
the documentation (perlref) explicitly says will not work with lexical
variables (ie, those declared with my()).
Symrefs are probably *not* what you want to do for other reasons.
See:
http://www.plover.com/~mjd/perl/varvarname.html
>In reference to the example below, can anyone explain why
>the my'ing an array variable doesn't work?
To quote perlref:
Only package variables (globals, even if localized) are
visible to symbolic references. Lexical variables
(declared with my()) aren't in a symbol table, and thus
are invisible to this mechanism.
I'd suggest using a hash of (explicit references to) lists instead.
And *always* use strict 'vars'.
[suggestions untested]
>#!/usr/local/bin/perl -w
use strict;
>
>{
> my @I = qw [ i0 i1 i2 ]; # I want to use this
>local @C = qw [ c0 c1 c2 ]; # but this works !!
my %lists = (
I => [ qw [ i0 i1 i2 ] ],
C => [ qw [ c0 c1 c2 ] ]
);
>
>foreach my $stx ( qw [ I C ] )
>{
for my $stx (keys %lists) {
> push @{$stx}, $stx."3"; # add to the list
push @{ $lists{$stx} }, "$stx.3";
> print $stx,":: "; # print list name
> print join " ", @{$stx}; # and its elements
local $" = ' '; # See perlvar
print "$stx:: @{$lists{$stx}}";
> print "\n"
>
>}
>print "after the ref'ing...\n";
>
>print "I::", join " ", @I, "\n";
>print "C::", join " ", @C, "\n";
print "I:: @{ $lists{I} }\n";
#yadda, yadda...
}
>
>exit;
>}
HTH
--damian
------------------------------
Date: 26 Nov 2002 03:03:23 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: my/local Scoping subtlies
Message-Id: <slrnau5p3q.h30.damian@puma.qimr.edu.au>
On 26 Nov 2002 02:59:13 GMT, Damian James said:
>...
>I'd suggest using a hash of (explicit references to) lists instead.
>And *always* use strict 'vars'.
Err, that's 'refs'. D'oh!
--damian
------------------------------
Date: 25 Nov 2002 19:07:45 -0800
From: bbcrock@hotmail.com (D)
Subject: Re: Newbie needs help- trying to submit command-line function to perl script via web
Message-Id: <22e171df.0211251907.6ecd56a7@posting.google.com>
hmm... it does seem like we are on different ends of the development
spectrum! If you don't use CMSs in your daily life then you don't do
development like I do. Content Management Systems are used in like
all of the Fortune 500 companies and people on my team must use the
term CMS a dozen times a day. I have a contract that has about 4k
static html pages that we're quickly moving to a CMS. You generally
need to run a CMS if you have 30-40 stakeholders or writers who you
don't want to have root access to your servers.
Similarly it sounds like you use the term CGI often and I haven't
heard that since 1996.
HOWEVER, thanks for responding and I will take a look at the
information you gave me.
Because I know nothing about the general architecture of PERL scripts
on a network, I am not surprised that I described things incorrectly.
I worked with NT-based solutions for the last 8 years and terms like
"batch files that mimic the command line interface" get tossed around
a lot.
What I want to do is-- inside a PERL file, I want to send information
to another file written in PERL. That second PERL file will return a
response. That second file was written as a standalone file to be run
from the command line in Unix.
I tried to send the command to this second file by using OPEN.
Clearly that's not working. In order to see what the heck was going
on, I tried to capture the response that the second file returns to
the screen. To be honest, I have no idea if that's possible.
In some respects, yes, this is probably a CGI by your standards. I
receive data from the users, check the apache user database (using
code that I swiped) and if there is a user there then I want to delete
that user. Problem is that when I originally tried to do this, my
code to communicate with dbmmanage didn't work and no errors were
generated. I don't know how to debug in PERL. So, sez I, I'll use
the existing PERL file that we use to delete records by hand. I want
to send data from my file to that file. I would also like to capture
the response that this file normally sends out.
thanks!
Don
tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnau4og1.1pd.tadmc@magna.augustmail.com>...
> D <bbcrock@hotmail.com> wrote:
>
> > I want to write a VERY simple and quick Perl file that creates an HTML
> > form to send information to another Perl script that already exists.
>
>
> To send the info to a *CGI program* or to a Perl script?
>
> They are not the same thing. They take input differently.
> The answer will be different depending on which it is that
> your really want.
>
> Which one do you really want?
>
>
> If you want to "fill out" forms and submit the info to a CGI
> program (whether written in Perl or not), you can use this
> module to make your Perl program "look like" a web browser
> to the CGI program's web server:
>
> use LWP::UserAgent;
>
> http://search.cpan.org/author/GAAS/libwww-perl-5.65/lib/LWP/UserAgent.pm
>
>
> If you want to run a Perl script, then use system() or backticks.
>
>
> > The entire site
>
>
> What site?
>
> Your site or the site that you want to communicate with?
>
>
> > will be rewritten for a CMS
>
>
> What is a CMS?
>
>
> > I am not sending in the information right and I want to save all the
> > information that the perl script I want to run would normally send to
> > the command line to a file.
>
>
> Huh?
>
>
> > here is what I wrote:
> > ################
> > open ('deletessn.pl', ' ' . $ssn . ' delete');
>
>
> That does not run the deletessn.pl program.
>
> Does deletessn.pl support GET or POST or both?
>
> Is it written using the CGI.pm module?
>
> Or is it written as a command line program that takes
> command line arguments?
>
>
> > $myresponse = ???
>
>
> If deletessn.pl is a normal (non-CGI) program, then
> you can run it and capture its outputs using backwards
> single quotes (backticks):
>
> my $output_from_deletessn = `deletessn.pl $ssn delete`;
> or
> my $output_from_deletessn = qx/deletessn.pl $ssn delete/;
>
>
> If it is a CGI program that you don't want to run in a CGI
> environment, then you must supply its input in an env var
> (GET) or from STDIN (POST). This will be really easy to do
> if deletessn.pl uses the CGI.pm module.
>
> If it is a CGI program that you want to run in a CGI
> environment, then use UserAgent.
>
>
> > open(OUT, ">>/opt/ns-server/www/hrsc/error.txt");
>
>
> You should always, yes *always*, check the return value from open():
>
> open(OUT, ">>/opt/ns-server/www/hrsc/error.txt")
> or die "could not open '/opt/ns-server/www/hrsc/error.txt' $!";
------------------------------
Date: Mon, 25 Nov 2002 22:17:34 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Newbie needs help- trying to submit command-line function to perl script via web
Message-Id: <slrnau5tet.1vk.tadmc@magna.augustmail.com>
[ TOFU quoting style repaired (somewhat) ]
D <bbcrock@hotmail.com> wrote:
> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnau4og1.1pd.tadmc@magna.augustmail.com>...
>> D <bbcrock@hotmail.com> wrote:
>>
>> > I want to write a VERY simple and quick Perl file that creates an HTML
>> > form to send information to another Perl script that already exists.
>>
>> To send the info to a *CGI program* or to a Perl script?
>>
>> They are not the same thing. They take input differently.
>> The answer will be different depending on which it is that
>> your really want.
>>
>> Which one do you really want?
>> If you want to run a Perl script, then use system() or backticks.
>> > will be rewritten for a CMS
>>
>> What is a CMS?
>> you can run it and capture its outputs using backwards
>> single quotes (backticks):
>>
>> my $output_from_deletessn = `deletessn.pl $ssn delete`;
>> or
>> my $output_from_deletessn = qx/deletessn.pl $ssn delete/;
> hmm... it does seem like we are on different ends of the development
> spectrum!
What is the development spectrum?
Is one end harder or more complicated, or is it some other
quality that is spread across some spectrum?
> If you don't use CMSs in your daily life then you don't do
> development like I do.
I've programmed in Perl daily for about eight years.
Almost none of that programming was CGI programs.
Perl has a million and one uses, CGI is only one of them.
> don't want to have root access to your servers.
There are most often no "web servers" involved in my Perl programming.
> HOWEVER, thanks for responding and I will take a look at the
> information you gave me.
Here's some more, the Posting Guidelines that are posted here weekly:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
> Because I know nothing about the general architecture of PERL scripts
^^^^
> on a network,
You mean Perl scripts.
You were spelling it correctly before, don't change to the wrong way. :-)
See the Perl FAQ:
What's the difference between "perl" and "Perl"?
> I am not surprised that I described things incorrectly.
Precise terminology is essential when discussing technical topics.
If you ask the wrong question, you'll get the wrong answer.
> I worked with NT-based solutions for the last 8 years
Everybody has problems. :-) :-)
> What I want to do is-- inside a PERL file, I want to send information
> to another file written in PERL.
Stop talking about files "doing" things.
Files are storage. You can store programs in files, but the files
do not "do" anything.
"programs" (or "processes") do things.
Data (stored in files or not) does not "do" things, it
"has things done to it".
> That second PERL file will return a
> response. That second file was written as a standalone file to be run
> from the command line in Unix.
Then I've already told you what you need to know.
> In some respects, yes, this is probably a CGI by your standards.
Your misuse of terminology leads me to believe that your
understanding of how this technology works might also need
some improvement.
Your program either runs in a CGI environment or it does not.
There are no personal "standards" involved.
> I would also like to capture
> the response that this file normally sends out.
I've already answered your question in my earlier followup.
Did you try it?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 25 Nov 2002 21:32:38 -0700
From: "Palladium Solutions" <palladium@spinn.net>
Subject: Re: Newbie needs help- trying to submit command-line function to perl script via web
Message-Id: <uu5uo3qododb85@corp.supernews.com>
Not that we don't understand the CMS term. I myself have written many hooks,
interfaces
into some of the well known CMS systems. It sounds as if this is your
scenario.
A perl script that is evoked via an apache front end runs, checks blah blah
for user.
Then executes another perl script with that information to delete the user.
The second file then responds to the original post to remove the user.
First of all that's too complicated.
From your initial script just call the second perl file with backticks.
my $command=`/path/to/perl/interp/perl
/path/to/second/perl/file/secondfile.pl $input $more_input
$even_more_input`;
Then the results of running the second script are contained within the
scalar $command
Then just send back to the client via normal methods or parse and replace
text etc...
This sound like what you want?
"D" <bbcrock@hotmail.com> wrote in message
news:22e171df.0211251907.6ecd56a7@posting.google.com...
> hmm... it does seem like we are on different ends of the development
> spectrum! If you don't use CMSs in your daily life then you don't do
> development like I do. Content Management Systems are used in like
> all of the Fortune 500 companies and people on my team must use the
> term CMS a dozen times a day. I have a contract that has about 4k
> static html pages that we're quickly moving to a CMS. You generally
> need to run a CMS if you have 30-40 stakeholders or writers who you
> don't want to have root access to your servers.
>
> Similarly it sounds like you use the term CGI often and I haven't
> heard that since 1996.
>
> HOWEVER, thanks for responding and I will take a look at the
> information you gave me.
>
> Because I know nothing about the general architecture of PERL scripts
> on a network, I am not surprised that I described things incorrectly.
> I worked with NT-based solutions for the last 8 years and terms like
> "batch files that mimic the command line interface" get tossed around
> a lot.
>
> What I want to do is-- inside a PERL file, I want to send information
> to another file written in PERL. That second PERL fe will return a
> response. That second file was written as a standalone file to be run
> from the command line in Unix.
>
> I tried to send the command to this second file by using OPEN.
> Clearly that's not working. In order to see what the heck was going
> on, I tried to capture the response that the second file returns to
> the screen. To be honest, I have no idea if that's possible.
>
> In some respects, yes, this is probably a CGI by your standards. I
> receive data from the users, check the apache user database (using
> code that I swiped) and if there is a user there then I want to delete
> that user. Problem is that when I originally tried to do this, my
> code to communicate with dbmmanage didn't work and no errors were
> generated. I don't know how to debug in PERL. So, sez I, I'll use
> the existing PERL file that we use to delete records by hand. I want
> to send data from my file to that file. I would also like to capture
> the response that this file normally sends out.
>
> thanks!
>
> Don
>
> tadmc@augustmail.com (Tad McClellan) wrote in message
news:<slrnau4og1.1pd.tadmc@magna.augustmail.com>...
> > D <bbcrock@hotmail.com> wrote:
> >
> > > I want to write a VERY simple and quick Perl file that creates an HTML
> > > form to send information to another Perl script that already exists.
> >
> >
> > To send the info to a *CGI program* or to a Perl script?
> >
> > They are not the same thing. They take input differently.
> > The answer will be different depending on which it is that
> > your really want.
> >
> > Which one do you really want?
> >
> >
> > If you want to "fill out" forms and submit the info to a CGI
> > program (whether written in Perl or not), you can use this
> > module to make your Perl program "look like" a web browser
> > to the CGI program's web server:
> >
> > use LWP::UserAgent;
> >
> > http://search.cpan.org/author/GAAS/libwww-perl-5.65/lib/LWP/UserAgent.pm
> >
> >
> > If you want to run a Perl script, then use system() or backticks.
> >
> >
> > > The entire site
> >
> >
> > What site?
> >
> > Your site or the site that you want to communicate with?
> >
> >
> > > will be rewritten for a CMS
> >
> >
> > What is a CMS?
> >
> >
> > > I am not sending in the information right and I want to save all the
> > > information that the perl script I want to run would normally send to
> > > the command line to a file.
> >
> >
> > Huh?
> >
> >
> > > here is what I wrote:
> > > ################
> > > open ('deletessn.pl', ' ' . $ssn . ' delete');
> >
> >
> > That does not run the deletessn.pl program.
> >
> > Does deletessn.pl support GET or POST or both?
> >
> > Is it written using the CGI.pm module?
> >
> > Or is it written as a command line program that takes
> > command line arguments?
> >
> >
> > > $myresponse = ???
> >
> >
> > If deletessn.pl is a normal (non-CGI) program, then
> > you can run it and capture its outputs using backwards
> > single quotes (backticks):
> >
> > my $output_from_deletessn = `deletessn.pl $ssn delete`;
> > or
> > my $output_from_deletessn = qx/deletessn.pl $ssn delete/;
> >
> >
> > If it is a CGI program that you don't want to run in a CGI
> > environment, then you must supply its input in an env var
> > (GET) or from STDIN (POST). This will be really easy to do
> > if deletessn.pl uses the CGI.pm module.
> >
> > If it is a CGI program that you want to run in a CGI
> > environment, then use UserAgent.
> >
> >
> > > open(OUT, ">>/opt/ns-server/www/hrsc/error.txt");
> >
> >
> > You should always, yes *always*, check the return value from open():
> >
> > open(OUT, ">>/opt/ns-server/www/hrsc/error.txt")
> > or die "could not open '/opt/ns-server/www/hrsc/error.txt' $!";
------------------------------
Date: 25 Nov 2002 18:27:31 -0800
From: intlone@hotmail.com (Westy)
Subject: Newbie, split function, and counter
Message-Id: <28b2c540.0211251827.517fa9d@posting.google.com>
Been working on this for HOURS - continual errors on the split
function and the counter lines (after making every change imaginable)
, any insight would be appreciated.
#!/usr/bin/perl
#classelection.cgi - saves form data to a file, creates a dynamic Web
page
#that displays a message and election results
print "Content-type:text/html\n\n";
use CGI qw(:standard);
use strict;
#declare variables
my ($election, @records);
my @count = ( 0, 0, 0);
#assign input item to a variable
$election = param( 'election' );
#save form data to file
open(OUTFILE, ">>", "classelection.txt")
or die "Error opening classelection.txt. $!, stopped";
print OUTFILE "$election\n";
close(OUTFILE);
#calculate election results
open(INFILE, "<", "classelection.txt")
or die "Error opening classelection.txt. $!, stopped";
@records = <INFILE>;
close(INFILE);
foreach my $vote (@records)
{
chomp($vote);
$election = split(/,/, $vote);
$count[$election] = $count[$election] + 1;
}
#generate HTML results
print "<HTML><HEAD><TITLE> Jefferson High School Class President
Election</TITLE></HEAD>\n";
print "<BODY>\n";
print "<CENTER><H2>Thank you for voting for class president</H2>\n";
print "<TABLE>\n";
print "<TR><TD>Jeff Stone</TD> <TD>$count[0]</TD></TR>\n";
print "<TR><TD>Sheima Nadkarni</TD> <TD>$count[1]</TD></TR>\n";
print "<TR><TD>Sam Perez</TD> <TD>$count[2]</TD></TR>\n";
print "</TABLE>\n";
print "</CENTER></BODY></HTML>\n";
------------------------------
Date: 26 Nov 2002 02:46:10 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Newbie, split function, and counter
Message-Id: <arun9i$eju@dispatch.concentric.net>
"Westy" <intlone@hotmail.com> wrote in message
news:28b2c540.0211251827.517fa9d@posting.google.com...
> Been working on this for HOURS - continual errors on the split
> function and the counter lines (after making every change imaginable)
> , any insight would be appreciated.
>
>
> my ($election, @records);
>
> open(INFILE, "<", "classelection.txt")
> or die "Error opening classelection.txt. $!, stopped";
> @records = <INFILE>;
> close(INFILE);
>
> foreach my $vote (@records)
> {
> chomp($vote);
> $election = split(/,/, $vote);
> $count[$election] = $count[$election] + 1;
> }
>
You don't provide us with enough information on the strings coming in from
INFILE and being stored in @records for us to be able to diagnose the
problem with your use of the split function. Are the incoming strings
comma-delimited data records?
------------------------------
Date: Tue, 26 Nov 2002 02:54:29 GMT
From: "robertbu" <robertbu@hotmail.com>
Subject: Re: Newbie, split function, and counter
Message-Id: <FnBE9.356$qe.95@nwrddc03.gnilink.net>
"Westy" <intlone@hotmail.com> wrote in message
news:28b2c540.0211251827.517fa9d@posting.google.com...
> Been working on this for HOURS - continual errors on the split
> function and the counter lines (after making every change imaginable)
> , any insight would be appreciated.
>
>
> my @count = ( 0, 0, 0);
[Lines removed]
>
> $election = split(/,/, $vote);
>
> $count[$election] = $count[$election] + 1;
>
A sample input file would really help to understand
what you are trying to do. Assuming the input lines
are of the form:
foo,bar,baz
$election will be 3 for three fields found. Your array
$count is zero based, so you will be incrementing
the fourth entry. Even with this fixed, the file formats
that I can imagine that would make the code do the
right thing are strange.
== Rob ==
------------------------------
Date: Tue, 26 Nov 2002 04:19:08 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Perl/Tk
Message-Id: <3DE2F631.9050000@rochester.rr.com>
fafanie wrote:
> Bob Walton <bwalton@rochester.rr.com> wrote in message news:<3DE13DA3.4050808@rochester.rr.com>...
>
>>fafanie wrote:
>>
>>...
>>
>>
>>
>>>I want to build a graphical interface in Perl/Tk.
>>>Via this interface, I want to run a script perl from a button.
>>>For the moment, this script run via a console MS-Dos or a xterm unix.
>>>
>>>How to do?
>>>The command system("perl test.pl") or system("start perl test.pl") fails.
>>>
>>>Thus, my script writes some messages in STDOUT (console,xterm).
>>>How can I see theses outputs in my interface?
>>>
>>...
>>
>>
>>
>>>fafanie
>>>
>
>>If you would like to capture the standard output of a program which is
>>run from within Perl, use:
>>
>> $output=`program command line`;
>>
>>Those are "grave accent" characters (to the left of the 1 key on many
>>keyboards, although I don't know about French ones). See:
>>
>> perldoc perlop
>>
>>for additional information (look in the quote and quote-like operators
>>section, or look for the qx operator (its other implementation).
>>
>
> I don't understand your answer.
> Can you explain more?
> Thanks
> fafanie
>
Sure. When you run a command -- any command, including a Perl script --
from a Perl script, you have several choices available:
system("command arg1 arg2 ...");
exec("command arg1 arg2 ...");
$output=`command arg1 arg2 ...`;
$output=qx/command arg1 arg2 .../;
and probably some others. These all do distinctly different things,
besides the simple act of running the exteral command. You stated you
specifically want to put the output of the external command into
something or other in one of your Tk windows. If you have the output of
the external program in a Perl string, it is easy to put it into an
appropriate Tk widget. The method of getting the standard output of an
external command into a Perl string variable is the back-tick quote
method, otherwise implemented as the qx// quote-like operator. So:
$output=`command arg1 arg2 ...`;
will run the given command with the specified arguments and put the
resulting standard output stream into Perl variable $output. You can
then do with that string anything you wish, including display it in a Tk
widget.
Note that the external command run could be the invocation of another
Perl script. Consider the following pair of scripts, for example:
#script1.pl
print "This is script1.pl\n";
#script2.pl
$output=`perl script1.pl`;
print "output = $output\n";
Running:
perl script2.pl
should print out:
output = This is script1.pl
Generate those two scripts, and then run script2.pl, and verify the
output you get. Things will be no different if the invocation is from a
Perl/Tk script.
HTH.
--
Bob Walton
------------------------------
Date: 25 Nov 2002 17:05:01 -0800
From: princccess@aol.com (Return Jasmin)
Subject: perlcc and perl modules
Message-Id: <78a7045a.0211251705.d52c63c@posting.google.com>
When you compile with perlcc, is there anyway to find out what
standard perl modules were used? I need to find out what's included in
the executable you get after compiling with perlcc. Can anyone help me
out on this? Thanks in advance!
------------------------------
Date: Mon, 25 Nov 2002 16:32:22 -0800
From: "Tan Nguyen" <nospam@nospam.com>
Subject: Re: Question about IO::Socket Usage...
Message-Id: <3de2c077$1_5@nopics.sjc>
"Extended Partition" <extendedpartition@NOSPAM.yahoo.com> wrote in message
news:3de29129_1@nntp2.nac.net...
> Then, I am going to place my "sending" code in a while loop. So I know
that
> code will send my entire list. BUT, how do I test if the socket is still
> connected BEFORE I send?
Well, you might want to send something to the server to see if the
connection is still good. Of course, the server should understand the
command, sorta like a ping. Are you in control of the server? Is it in Perl
as well?
------------------------------
Date: 25 Nov 2002 16:32:21 -0800
From: caie@elixa.co.uk (Caie)
Subject: Sentence splitter
Message-Id: <9fd5216f.0211251632.650a8f43@posting.google.com>
Hi all,
I'm currently making an "Automated Plagiarism Detector" as a project
for my final year project. To do so, I am reading in a text file,
analysing each sentence for "well-written-ness" and producing an HTML
page with the results of this analysis. One major hurdle I have run
into is splitting the given text into sentences. I am using
ActivePerl (the computer I must work on is Win98) and downloaded the
Lingua::EN::Sentence-0.23 module. Unfortunatly this crashes the PC I
am working on and therefore I need a different method.
The only other module I've seen for download from CPAN is
Text::Sentence, and this is too basic for my needs. Basically I was
wondering if anyone has written their own script or knows of an
alternative one that will return an correct array of sentences:
1. Identifying that " . ! ? ', etc and abbreviations may all signal
the end of sentences in certain cases.
2. Supports a user defined list of abbreviations.
Your help is much appreciated and I'll promise to send you a fully
working copy in April 2003 when I'm done with the beast.
Caie
------------------------------
Date: Mon, 25 Nov 2002 23:09:57 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Urgent request for help -- posting to a FORM from a Perl Script
Message-Id: <90b5uukca7n3acifmnccvmk6vannn10f5v@4ax.com>
RK wrote:
>Any idea how I can use the Cookie defined above to GET "welcome.asp"?
I'm on thin ice now, I've never done this kind of thing before. But I
think LWP::UserAgent can be convinced to handle cookies transparently.
The docs would lead me to believe that all you have to do, is use a
cookie jar. Call the $ua->cookie_jar($jar) method with $jar a
HTTP::Cookies argument. Ah, yes. I found some docs in Lincoln Steins
book "Network Programming with Perl", chapter 9, and I quote:
We won't go through the complete HTTP::Cookies API, which allows
you to examine and manipulate cookies, but here is the idiom to
use if you wish to accept cookies for the current session, but
not save them between sessions:
$agent->cookie_jar(new HTTP::Cookies);
which will likely work just fine for you.
--
Bart.
------------------------------
Date: Mon, 25 Nov 2002 23:47:46 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Why can't code print an @array??
Message-Id: <x7wun16wkd.fsf@mail.sysarch.com>
>>>>> "DC" == Dave Cross <dave@dave.org.uk> writes:
DC> On Thu, 21 Nov 2002 05:37:52 +0000, Carlos C. Gonzalez wrote:
>> while (@stack = caller($i++))
DC> Later on you only use the first four items from this array. As others have
DC> pointed out, later items can be undef. So why not just take the items that
DC> you are interested in.
DC> while (@stack = (caller($i++))[0 .. 3])
or even:
while( @stack[0 .. 3] = caller($i++) )
which is a trifle shorter and cleaner IMO.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
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.
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 4176
***************************************