tobold.org

correct • elegant • free

△ comp.lang.perl △

◅ Help with removing a line from a file

A "getc()" problem ▻

How to Redirect STDOUT?

In article <312209AB.3ACA@evitech.fi>,
Atte Lahtiranta  <attetl@evitech.fi> wrote:
>        How
>can I redirect this STDOUT to some variable (not file) or can it be done
>directly?

Perl understands backquotes, just like the shells.  Well, almost
like the shells: Perl doesn't hide any of the output from you, so
if the command produces newlines you will see them too.  You can
use `chop' if you don't want them.

    # Not the most efficient (but perhaps the most terse) way to
    # fill an array with the names of the files in the current
    # directory.
    chop(@files = `ls`);

Tim.
--
Tim Goodwin   | "I just noticed that a SUN SLC takes longer to
UUnet PIPEX   | get to its boot prompt than it takes to build
Cambridge, UK | its [ Plan 9 ] kernel." -- Phil Winterbottom

Original headers:

From: tim@pipex.net (Tim Goodwin)
Newsgroups: comp.lang.perl.misc
Subject: Re: How to Redirect STDOUT?
Date: 14 Feb 1996 17:38:45 GMT
Organization: Unipalm PIPEX
Message-ID: <4ft6n5$h72@wave.news.pipex.net>
References: <312209AB.3ACA@evitech.fi>

△ comp.lang.perl △

◅ Help with removing a line from a file

A "getc()" problem ▻