you treat it like a filehandle (a filehandle is just a specific case of a general IO), and say something like "while (<PIPE>) {}" to get the output a line at a time.
that is in the case of a unidirectional pipe, opened for reading. if you need a pipe you can write to and read to, you'll need to use 'IPC::Open2', which you can learn more about with 'perldoc IPC::Open2' (POSIX only). "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
open(LS,"ls -la|" || die;
while(<LS>){
print if /^d/;
}
this fragment of code will print the ls -la lines for all directories in the current directory. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
Ahhh -- *now* I see what you're after. You want a compiled version of your perl script.
Well -- it's possible.
PerlApp -- from ActiveState for NT is reputed to be quite good, but you have to buy it.
Perlcc -- comes with standard perl and is documented with the rest of perl. It's a translator rather than a compiler, it turns your perl code into C code, which you can then compile using the gnu compiler. You can also get it to produce bytecode that can be executed using perl, but can't be read by a person.
Is that what you meant? Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
your close statement should be:[tt]
close PERL;[/tt] (filehandles are case sensitive)
and you can also simplify your loop into this:[tt]
@compiled = <PERL>;[/tt]
but as for your intentions, did you want to make an executable out of the perl script? there are ways to do this (perl2exe, undump, that one thing from activestate), discussed recently on this forum... "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
Whatever, I just wrote that out real quick, hehe, I actually had other code I was using, Thanks though,
I don't have an NT server, and perlcc works fine, but of course only for linux, I'm more worried about NT.
So about perl2exe, it's a piece of crap. If you've gotten a script to run outside of dos without any Tk then I'd love you for it though. I'd buy it then.
Tony "Java?? Umm, I think that's the stuff I drink while I'm coding perl."
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.