[22876] in Perl-Users-Digest
Perl-Users Digest, Issue: 5097 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 9 09:06:08 2003
Date: Mon, 9 Jun 2003 06:05:07 -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 Mon, 9 Jun 2003 Volume: 10 Number: 5097
Today's topics:
CGI and JAVA (David)
Re: CGI and JAVA <matthew@weierophinney.net>
Re: CGI and JAVA <flavell@mail.cern.ch>
Re: char to number conversion w/ a twist (John D)
exclude a word using regexp (paaro)
Re: exclude a word using regexp <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: exclude a word using regexp <jvs+nospam@india.ti.com>
Re: Formatting and encoding of words <tassilo.parseval@rwth-aachen.de>
How many perlers here have switched? (Scott)
Re: How many perlers here have switched? <tassilo.parseval@rwth-aachen.de>
Re: How many perlers here have switched? <aa@nospam.ukrecscuba.org.uk>
Re: how to find no of elements in array/hash/array pass (Bhaskar Kurapati)
Re: newbie: will a big array hurt performance? <grazz@pobox.com>
Re: Pack/Unpack with templates 'p' and 'P' (Graham Smith)
Re: Perl exam - fair or not? <nobull@mail.com>
Re: Perl exam - fair or not? <nobull@mail.com>
Re: Perldoc formatting on Linux <androflux@remove.to.reply.softhome.net>
Unbuffered output from another program? (Gareth Glaccum)
Re: Unbuffered output from another program? <thens@nospam.com>
upload file without cgi.pm <ghostnr1@telia.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 Jun 2003 03:22:35 -0700
From: csp1dc@surrey.ac.uk (David)
Subject: CGI and JAVA
Message-Id: <212241a.0306090222.61e59777@posting.google.com>
Hi!
Could someone help me with this?
I have a perl CGI script that calls Java class (using xalan (XSLT) to
convert a XML file to a HTML file). When running it from the command
line, it works fine, but when running it from the webserver, nothing
was returned. Checking the server log, it shows:
cspcl01.mcs.surrey.ac.uk - - [09/Jun/2003:11:14:44 +0100] "GET
/cgi-bin/lsp2003/test/test2.cgi HTTP/1.1" 200 130
It seems the system call was completed without error. I use the
following cgi to invoke the java class:
------------------------------------------------
#!/usr/bin/perl -w
use CGI qw(:standard);
$java = "/java/j2sdk1.4.1_03";
$path = $ENV{'PATH'};
$ENV{'JAVA_HOME'} = "$java/";
$ENV{'PATH'}="/java/j2sdk1.4.1_03/bin:$path";
$ENV{'CLASSPATH'}=".:$java/lib/xalan.jar:$java/lib/RmiJdbc.jar:$java/lib/Tidy.jar:$java/lib/xerces.jar;";
print "Content_type:text/html\n\n";
print "<HTML>\n<HEAD>";
print "</head>\n<body bgcolor=\"#FFFFE6\">\n";
print "<p>\n";
$process = system('java fundamentals.fundamental');
--------------------------------------------------
I am sure the classpath and the premission to acess all the java class
are set correctly. Can anyone help? Thanks in advance.
David
------------------------------
Date: Mon, 09 Jun 2003 11:33:25 GMT
From: Matthew Weier O'Phinney <matthew@weierophinney.net>
Subject: Re: CGI and JAVA
Message-Id: <slrnbe8s48.1ot.matthew@kavalier.weierophinney.net>
* David <csp1dc@surrey.ac.uk>:
> I have a perl CGI script that calls Java class (using xalan (XSLT) to
> convert a XML file to a HTML file). When running it from the command
> line, it works fine, but when running it from the webserver, nothing
> was returned. Checking the server log, it shows:
> cspcl01.mcs.surrey.ac.uk - - [09/Jun/2003:11:14:44 +0100] "GET
> /cgi-bin/lsp2003/test/test2.cgi HTTP/1.1" 200 130
>
> It seems the system call was completed without error. I use the
> following cgi to invoke the java class:
> ------------------------------------------------
> #!/usr/bin/perl -w
> use CGI qw(:standard);
>
> $java = "/java/j2sdk1.4.1_03";
> $path = $ENV{'PATH'};
> $ENV{'JAVA_HOME'} = "$java/";
> $ENV{'PATH'}="/java/j2sdk1.4.1_03/bin:$path";
> $ENV{'CLASSPATH'}=".:$java/lib/xalan.jar:$java/lib/RmiJdbc.jar:$java/lib/Tidy.jar:$java/lib/xerces.jar;";
>
> print "Content_type:text/html\n\n";
Why are you doing this if you're using CGI.pm? First off, you have it
typed incorrectly (should be "Content-type: text/html\n\n"), but this
can be more accurately and easily done using CGI's header() function:
$q = CGI::new();
print $q->header();
This error alone would cause problems with output.
> print "<HTML>\n<HEAD>";
> print "</head>\n<body bgcolor=\"#FFFFE6\">\n";
> print "<p>\n";
>
> $process = system('java fundamentals.fundamental');
> --------------------------------------------------
> I am sure the classpath and the premission to acess all the java class
> are set correctly. Can anyone help? Thanks in advance.
Did you do a "print $process;" anywhere? Where's the rest of the script?
--
Matthew Weier O'Phinney
matthew@weierophinney.net
http://matthew.weierophinney.net
------------------------------
Date: Mon, 9 Jun 2003 13:48:24 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CGI and JAVA
Message-Id: <Pine.LNX.4.53.0306091342310.15694@lxplus096.cern.ch>
On Mon, Jun 9, David inscribed on the eternal scroll:
> #!/usr/bin/perl -w
Fair start, but what did the group's posting guidelines say about
"strict" ? And since this is a CGI, I'd want to turn -T on also.
> print "Content_type:text/html\n\n";
Seems like a case of getting a good dog, and still barking for
yourself.
> $process = system('java fundamentals.fundamental');
Have you read this?
<
http://www.perldoc.com/perl5.8.0/pod/perlfaq8.html#
Why-can't-I-get-the-output-of-a-command-with-system()-
>
------------------------------
Date: 9 Jun 2003 04:53:43 -0700
From: johndageek@yahoo.com (John D)
Subject: Re: char to number conversion w/ a twist
Message-Id: <c608545f.0306090353.449eb9a0@posting.google.com>
mfabache@yahoo.com (MF) wrote in message news:<2855726c.0306071358.63cd6b8f@posting.google.com>...
> Spoke to soon! ;)
>
> I can do an indivual char/number conversion with the code previously
> provided, but how can I use it to manipulate the following data?
>
> Input:
> 32,18,27,172,483.0M,,6.23,,1,3,20.0K,116.0K
>
> Desired Output:
> 32,18,27,172,483000000,,6.23,,1,3,20000,116000
>
> Im trying to figure something out at the moment...
Just for fun try:
$in = "32,18,27,172,483.0M,,6.23,,1,3,20.0K,116.0K";
print "$in\n";
$in=~ s/(\d+\.*\d+)([MBK])/$1*{K=>1e3,M=>1e6,B=>11e9}->{$2}/eig;
print "$in\n";
Thanks to Bob, but I could not get yoiur answer from his code.
Enjoy
------------------------------
Date: 9 Jun 2003 04:07:11 -0700
From: paaro@hockeymail.com (paaro)
Subject: exclude a word using regexp
Message-Id: <c7395c40.0306090307.5ccceda6@posting.google.com>
Yo,
I have a following problem: I read a HTML file into a variable, and
then I want to find all links (<a ....>...</a>) and check whether they
have an attribute "target". If they don't, then I want to add
target="_blank".
So the logic would be: find
<a .*?>, but .*? should not contain word "target" (I don't want to
complicate things, let's just assume that href wouldn't containt a
word "target", because if it would, then I would have to check whether
"target" is in the href itself or is it a attribute that I search).
I tried something like
<a ([^target]*?)>
and simmilar, but it doesn't work.
Any ideas of how to exclude particular word?
Thanks,
Paaro
------------------------------
Date: Mon, 9 Jun 2003 11:15:43 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: exclude a word using regexp
Message-Id: <Xns9395868AEF801elhber1lidotechnet@62.89.127.66>
paaro wrote:
> Yo,
>
> I have a following problem: I read a HTML file into a variable, and
> then I want to find all links (<a ....>...</a>) and check whether they
> have an attribute "target". If they don't, then I want to add
> target="_blank".
>
> So the logic would be: find
> <a .*?>, but .*? should not contain word "target" (I don't want to
> complicate things, let's just assume that href wouldn't containt a
> word "target", because if it would, then I would have to check whether
> "target" is in the href itself or is it a attribute that I search).
>
> I tried something like
> <a ([^target]*?)>
> and simmilar, but it doesn't work.
>
> Any ideas of how to exclude particular word?
Run
perldoc perlre
and look for (?! ).
Or better yet, use an HTML parser. Look for one which will suit you here:
search.cpan.org
--
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: 9 Jun 2003 11:40:29 GMT
From: Jahagirdar Vijayvithal S <jvs+nospam@india.ti.com>
Subject: Re: exclude a word using regexp
Message-Id: <bc1rnd$p7v$1@home.itg.ti.com>
Use a standard off the shelf html parser from CPAN. it will ease your job
* paaro <paaro@hockeymail.com>:
> Yo,
>
> I have a following problem: I read a HTML file into a variable, and
> then I want to find all links (<a ....>...</a>) and check whether they
> have an attribute "target". If they don't, then I want to add
> target="_blank".
>
> So the logic would be: find
> <a .*?>, but .*? should not contain word "target" (I don't want to
> complicate things, let's just assume that href wouldn't containt a
> word "target", because if it would, then I would have to check whether
> "target" is in the href itself or is it a attribute that I search).
>
> I tried something like
> <a ([^target]*?)>
> and simmilar, but it doesn't work.
>
> Any ideas of how to exclude particular word?
>
> Thanks,
> Paaro
--
Serial killer strikes! Mouse and modem found dead.
Jahagirdar .V.S
IC Design Engineer , Texas Instruments (India) Ltd.
91-80-5099129(O)
------------------------------
Date: 9 Jun 2003 08:43:58 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Formatting and encoding of words
Message-Id: <bc1hce$935$1@nets3.rz.RWTH-Aachen.DE>
Also sprach slash:
> I apologize for the simplicity of this question in advance as I am new
> to Perl.
> I have a table of words generated dynamically from Text::Table CPAN
> module. I am trying to select certain columns.
> Here is my code:
>
> use CPAN;
> use Text::Table;
Heh, I like this. Even though Text::Table is a module from the CPAN (and
you are thus using the CPAN somewhat) you don't have to use the CPAN
module. This module is for accessing the CPAN repository
programmatically. Just 'use Text::Table;'.
>
> my @words = qw( Use this form to post your message...);
>
> my $n_cols = 3;
> my $col = { align => 'left'};
> my $tb = Text::Table->new( ( $col) x $n_cols);
>
> my @stack = ( '*' ) x $n_cols;
> for my $word ( @words ) {
> shift @stack;
> push @stack, $word;
> $tb->add( @stack);
> }
>
> print $tb;
>
> How do I select the columns? Let's say, if the columns had titles and
> they were following (but they do not have column titles currently): a,
> b, c
>
> and I wanted the following output:
>
> b, a b, c
The select() method takes columns and returns a new table consisting
only of those columns. Between those columns you can sprinkle in
directives how to format the whole thing. For your problem, you can
write this:
my $t1 = $tb->select(1, 0, { is_sep => 1,
body => "\t" },
1, 2);
print $t1;
__END__
* * * Use
Use * Use this
this Use this form
form this form to
to form to post
post to post your
your post your message...
> I tried using the select() method from the module specification but I
> guess I wasn't using it correctly. For whatever column i chose,
> my $sub = select ($b, $a, $b, $c), the output would be always be 4
> copies of column a. Can someone please help me?
You give column-numbers to select them. First column has index 0. I
guess $a .. $c were strings and thus converted into the number 0.
> Secondly, can I also sort table columns? I didn't see this in the
> specification. For instance, if I wanted to sort column a and column c
> based on their "value", i.e., whatever their memory encoding
> representation value is.
I haven't found anything like that either. Anno, some work for you. :-)
> Which brings me to the next point...How is a Perl string stored in
> memory? Can I write a script so that words are encoded in binary? If I
> do that then the string comparisons will be faster, right? So, can I
> encode them in base64 or any base I want? I guess, all I would have to
> do is generate a lookup key or table of the alphabet. Any suggestions
> would be greatly appreciated.
Strings aren't stored much differently than in C. The variable that
holds them (a scalar which in the sourcecode is referred to as 'SV*')
has some administrative overhead when you look at the internals but
eventually it is just a 'char*' pointer.
Encoding your strings wont change anything about it and you wont gain
speed advantages from it. Consider: Perl was initially designed to work
with text so it can do that very fast. Don't yet worry about those
optimizations. You should start to worry once your programs run too
slowly...but I doubt that encoding your strings is the right angle to
look at it.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 9 Jun 2003 02:32:30 -0700
From: admin@webhostingvoice.com (Scott)
Subject: How many perlers here have switched?
Message-Id: <f81dc3ae.0306090132.565f37e2@posting.google.com>
How many of you perl programmers have switched to doing most of your
coding in PHP, and why?Scottadmin@webhostingvoice.com Grand
Opening!!!www.webhostingvoice.comThe friendliest and most focused web
hosting forums on the web!
------------------------------
Date: 9 Jun 2003 09:37:27 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: How many perlers here have switched?
Message-Id: <bc1kgn$at8$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Scott:
> How many of you perl programmers have switched to doing most of your
> coding in PHP, and why?Scottadmin@webhostingvoice.com Grand
> Opening!!!www.webhostingvoice.comThe friendliest and most focused web
> hosting forums on the web!
None, because otherwise they wouldn't hang around in this group.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 9 Jun 2003 10:08:03 GMT
From: Alasdair Allan <aa@nospam.ukrecscuba.org.uk>
Subject: Re: How many perlers here have switched?
Message-Id: <bc1ma3$1d4dgv$1@athena.ex.ac.uk>
Scott wrote:
> How many of you perl programmers have switched to doing most of your
> coding in PHP, and why?
Err, it depends what you use Perl for, personally I've got 33,000 lines
of "mission critical" Perl and absolutely none of it is Perl CGI scripts.
Perl isn't just for web pages... ;)
Al.
------------------------------
Date: 8 Jun 2003 21:38:57 -0700
From: bhas_kurapati@yahoo.com (Bhaskar Kurapati)
Subject: Re: how to find no of elements in array/hash/array passed to subroutine without reference?
Message-Id: <3c0c6539.0306082038.1b167b62@posting.google.com>
bob <bob@nowhere.com> wrote in message news:<3ee230db$1_1@127.0.0.1>...
> Damn straight. Since I NEVER plan on doing anything like this myself, I
> didn't test it, as I noted. But you are absolutely correct.
>
> On Sat, 07 Jun 2003 13:32:03 -0500, dw wrote:
>
> > don't you also need something like
> > my $L1 = shift;
> > my $L2 = shift;
> > my $L3 = shift;
> > to get those first few items out of @_
> >
>
>
> ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
> http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
> ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Hi All,
Thanks for giving reply. Sorry for posting a confusing question. What
i want is exaclty what 'Steve Grazzini' and 'Jürgen Exner' understood.
I got answers from them.
regards,
Bhaskar Kurapati
------------------------------
Date: Mon, 09 Jun 2003 06:20:02 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: newbie: will a big array hurt performance?
Message-Id: <mGVEa.53111$ca5.21405@nwrdny02.gnilink.net>
Nicholas Dronen <ndronen@io.frii.com> wrote:
>
> If you want to do *some* read-ahead, then something like
> this might work. I don't know if it has any pitfalls.
At least one :-)
> # Grab two lines after root's. This too is arbitrary.
> @d[0,1] = <$f>, <$f>;
That's list context, so the first readline() slurps the rest
of the file.
--
Steve
------------------------------
Date: 9 Jun 2003 01:40:48 -0700
From: grehom@ntlworld.com (Graham Smith)
Subject: Re: Pack/Unpack with templates 'p' and 'P'
Message-Id: <98eb7f13.0306090040.625124e6@posting.google.com>
I think you need to look at the documentation:
perldoc -f pack
the first line:
my $s = pack("Csss", 65, 0x1234, 0x1235, 0x1236);
does what it says on the packet
Takes a LIST of values and converts it into a string using the
rules given by the TEMPLATE. The resulting string is the
concatenation of the converted values. Typically, each converted
value looks like its machine-level representation. For example,
on 32-bit machines a converted integer may be represented by a
sequence of 4 bytes.
so $s is 7 bytes long = 1 (unsigned character) + 6 (3 signed shorts)
if you were to look at it in the debugger on a M$ Windows machine you
would see:
"A4\x125\x126\x12"
this looks little confusing at first until you realize that each of
the
unsigned shorts is displayed low byte then high byte!
what the second line:
my $r = pack("p", $s);
is create a pointer to a null-terminated string, $r is a reference to
the string $s. The actual contents of $r are irrelevant you just have
to remember what it refers to.
the third line:
my @a = unpack("asss", unpack("p", $r));
should be considered in two bits, the innermost unpack:
unpack("p", $r)
exactly reverses what the second line did, so we end up with a 7 byte
string identical to $s, if we consider the third line as:
my @a = unpack("asss", $s);
the array 'a' will contain four values:
@a = ("A", 4660, 4661, 4662);
we would have got the original four values however we packed the first
value (65) with a template of 'C' and then unpacked with a template of
'a', so we
the character with the ascii value 65 i.e. A
As for what you got up in your experiments - sorry but I think adding
to value of pointer is very unsafe thing to do in Perl, languages like
Java I think forbid it. Don't go there!
------------------------------
Date: 09 Jun 2003 12:14:33 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Perl exam - fair or not?
Message-Id: <u9of177bae.fsf@wcl-l.bham.ac.uk>
tadmc@augustmail.com (Tad McClellan) writes:
> anon <> wrote:
>
> > A friend of mine took a Perl class in college and was given this exam.
>
>
> > 5. What special meanings does the caret (^) character have in regular
> > expressions?
>
>
> > (b) When it is the first character inside a character class ([]), it
> > represents a "not" in the set.
>
> > (d) Represents a beginning of line anchor.
>
>
> Those are _both_ (kinda) correct.
>
> (beginning of _string_ anchor, not "line")
Er, no, the beginning of string anchor is \A.
The carret is defined as being the beginning of line anchor.
However without the /m qualifier the regex engine will treat the
beginning of line anchor as a beginning of string anchor.
Tad, I'm sure you knew this - I'm only correcting you for the beniefit
of on-lookers.
> The answer must be (d) because if the caret is in a char class,
> then it is not in a "regular expression", it is in a char class.
That, I think, is undue pedantry.
The question asked for _meanings_ (plaural) so the answer is (b,d).
> > 17. Which function allows you read a certain byte position within a
> > file? (Choose only ONE)
> > (a) tell
> > (b) find
> > (c) raccess
> > (d) seek
>
>
> (what is "raccess"?)
>
> None of those read *anything* !
And you didn't read the question - it said "allows you read". It is
more likely this was meant to say "allows you to read" rather than
"reads".
> There is no correct answer for the question as asked.
Only because it is not gramatically correct.
> > 19. What is true about the ARGV array?
> > (a) Identical to the ARGV array in C.
> > (b) ARGV[0] holds the name of the program.
> > (c) When no arguments are given to a program, the array evaluates to
> > FALSE.
> > (d) Its array index starts at 1.
>
>
> There is no correct answer for that question either.
>
> What it evaluates to depends on what context it is evaluated in.
When one says "EXPR evaluates to false" it is implicit in this
statement that one means in a boolean context.
> > 35. An anonymous subroutine is created by using the keyword sub and
> ^^^^^^^^^
> > prefixing the subroutine name with string "anon_" (true/false).
> ^^^^
>
> Anonymous things do not _have_ names.
Anonymous GLOBs do. :-)
(Please, no pedantic contradictions).
> You don't need to know Perl, or even programming in order to
> answer that one correctly. :-)
Yes but knowing Perl may actually make you doubt what you know.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 09 Jun 2003 13:13:10 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Perl exam - fair or not?
Message-Id: <u9llwb78kp.fsf@wcl-l.bham.ac.uk>
hudson@swcp.com (Tramm Hudson) writes:
> And neither 'local' nor 'my' are functions. They are keywords that
> modify the storage class of variables.
No, 'my' is a storage class modifier, 'local' is not. You may or may
not wish to consider local() to be a function depending on how you
define that. I, however, choose to consider 'local' to be a function.
You may even wish to consider storage class modifiers 'my' and 'our'
as functions that have compile-time side-effects.
> It seems to me that calling 'my' and 'local' functions
> indicates a misunderstanding of Perl.
I disagree.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sun, 8 Jun 2003 18:25:24 -0600
From: Jason Creighton <androflux@remove.to.reply.softhome.net>
Subject: Re: Perldoc formatting on Linux
Message-Id: <20030608182524.2d5170d7.androflux@remove.to.reply.softhome.net>
On Sun, 08 Jun 2003 14:21:33 +0100
"S. Anthony Sequeira" <tony@sequeira.com> wrote:
> This is what I get with a $ perldoc perl
>
> PERL(1) User Contributed Perl Documentation
> PERL(1)
>
>
>
> ESC[1mNAMEESC[0m
> perl - Practical Extraction and Report Language
>
> ESC[1mSYNOPSISESC[0m
> ESC[1mperl ESC[22m[ ESC[1m-sTuU ESC[22m] [ ESC[1m-hv ESC[22m] [
> ESC[1m-V
> ESC[22m[:ESC[4mconfigvarESC[24m] ]
The problem here is that the "pager" (probably 'less') is "catching" (ie,
printing "ESC" instead the actual escape character) the escape sequences,
preventing your terminal from displaying the text correctly. Using 'less' with
the '-r' ("raw" output) should fix this, so I would try:
export PERLDOC_PAGER='less -r'
Jason Creighton
------------------------------
Date: 9 Jun 2003 03:19:01 -0700
From: verycoldpenguin@hotmail.com (Gareth Glaccum)
Subject: Unbuffered output from another program?
Message-Id: <991491a9.0306090219.49ba4606@posting.google.com>
I need to open a program from within a perl script, and then read the
output of that program occasionally. Not a problem usually,
open(FH,"prog |")||die("Stupid proggy: $!");
$t=<FH>;
assuming that FH does not over buffer.
However, I now need to make this nicer, so that other items can occur
at all times.
Therefore, I need to read the input from the program, if it exists,
and not pause until it exists, and do stuff with the input. And, if
the input is not there I will continue to do stuff with the OLD input.
Does this make sense?
It is like a forked program, but the data from one part of the fork
must be made available to the other part, without the other part
needing to pause until the data exists.
Thanks for any help
Would prefer not to start up sockets though if easily avoidable.
Gareth.
------------------------------
Date: Mon, 9 Jun 2003 17:34:05 +0530
From: Thens <thens@nospam.com>
Subject: Re: Unbuffered output from another program?
Message-Id: <20030609173405.30004b6e.thens@nospam.com>
On 9 Jun 2003 03:19:01 -0700
verycoldpenguin@hotmail.com (Gareth Glaccum) wrote:
>I need to open a program from within a perl script, and then read the
>output of that program occasionally. Not a problem usually,
>
>open(FH,"prog |")||die("Stupid proggy: $!");
>$t=<FH>;
>
>assuming that FH does not over buffer.
>
>However, I now need to make this nicer, so that other items can occur
>at all times.
>Therefore, I need to read the input from the program, if it exists,
>and not pause until it exists, and do stuff with the input. And, if
>the input is not there I will continue to do stuff with the OLD input.
>Does this make sense?
>It is like a forked program, but the data from one part of the fork
>must be made available to the other part, without the other part
>needing to pause until the data exists.
perldoc perlipc
and open2() are your friends here.
-Thens
>Thanks for any help
>Would prefer not to start up sockets though if easily avoidable.
>Gareth.
------------------------------
Date: Mon, 09 Jun 2003 12:23:20 GMT
From: "GhostNr1" <ghostnr1@telia.com>
Subject: upload file without cgi.pm
Message-Id: <Y__Ea.14322$dP1.27512@newsc.telia.net>
I don't know where the other post get but I try again.
I need to upload a file without useing cgi.pm or cgi-lib. Don't ask why.
I need example code. I have been looking for the entire internet (allmoust)
but many houre but I can't find any code that work.
Then if it possible I need code to upload that file to an database.(mysql)
It should work like this.
I have a webpage and someone should upload an file from his local disk into
the database on the server. So the file should be moved from local to server
drive.
thx
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.488 / Virus Database: 287 - Release Date: 6/5/2003
------------------------------
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 5097
***************************************