[13300] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 710 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 3 09:07:24 1999

Date: Fri, 3 Sep 1999 06:05:12 -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           Fri, 3 Sep 1999     Volume: 9 Number: 710

Today's topics:
    Re: $# <kenhirsch@myself.com>
        Embedding perl in C++ - Why does this give me a runtime <pgrossma@cisco.com>
    Re: file redirect <bauer@zrz.tu-berlin.de>
    Re: file redirect <bauer@zrz.tu-berlin.de>
    Re: Help another Perl newbee <contact@novacrystals.ns.ca>
    Re: How to "use strict" in a "perl -s" program? <rhomberg@ife.ee.ethz.ch>
    Re: How to match as most as possible ? <kenhirsch@myself.com>
        Image Size in Bytes <jimmy@blackhole-designs.com>
        LWP::Simple <joeyandsherry@mindspring.com>
    Re: LWP::Simple <nguyend7@msu.edu>
        printing dgold1@my-deja.com
    Re: problem with Apache::DBI & mod_perl <pheuvel@optusnet.com.au>
        Problems useing modules (Peter Wilford)
    Re: shebang question for Win32 Perl/Apache <All@n.due.net>
    Re: shebang question for Win32 Perl/Apache <All@n.due.net>
    Re: shebang question for Win32 Perl/Apache (Bart Lateur)
    Re: String Length (Gabor)
    Re: tee cmd in PERL? <tchrist@mox.perl.com>
    Re: tee cmd in PERL? <tchrist@mox.perl.com>
    Re: tee cmd in PERL? <tchrist@mox.perl.com>
    Re: tee cmd in PERL? <bauer@zrz.tu-berlin.de>
    Re: tee cmd in PERL? <tchrist@mox.perl.com>
    Re: tee cmd in PERL? <tchrist@mox.perl.com>
    Re: tee cmd in PERL? <tchrist@mox.perl.com>
    Re: tee cmd in PERL? <tchrist@mox.perl.com>
    Re: That Cargo Date Code ( was Re: Y2K) <aa056@chebucto.ns.ca>
    Re: Where a subroutine gets called from? (Gabor)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 3 Sep 1999 07:31:57 -0400
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: $#
Message-Id: <7qobr0$jce$1@holly.prod.itd.earthlink.net>


Nick Downey <nead@neadwerx.com> wrote in message
news:01bef5bc$fe680800$73463d80@r70h115...
> Camel: p134, par 2.
>
> 'Use of $# is now deprecated and is allowed only for maintaining...'

The statement only refers to $# by itself, not $#array.
E. g. do not use
  $# = '%6.6f'






------------------------------

Date: Fri, 3 Sep 1999 08:14:21 -0400
From: "Peter Grossman" <pgrossma@cisco.com>
Subject: Embedding perl in C++ - Why does this give me a runtime error?
Message-Id: <936375526.808381@sj-nntpcache-2.cisco.com>

After building perlxsi.c under Windows NT the following code compiles in
Devstudio (5.0).  However, as soon as I call it I get a runtime error on the
line beginning with "retval = my_perl_eval_sv".  Any thoughts appreciated

#include "extern.h"
#include <perl.h>


 /** my_perl_eval_sv(code, error_check)
 ** kinda like perl_eval_sv(),
 ** but we pop the return value off the stack
 **/
 SV* my_perl_eval_sv(SV *sv, I32 croak_on_error)
 {
     dSP;
     SV* retval;
     STRLEN n_a;

     PUSHMARK(SP);
     perl_eval_sv(sv, G_SCALAR);

     SPAGAIN;
     retval = POPs;
     PUTBACK;

     if (croak_on_error && SvTRUE(ERRSV))
        croak(SvPVx(ERRSV, n_a));

     return retval;
 }

bool p_eval_expression(char *s, char *s1, char *s2, char *s3, char
*pcommand)
 {

     SV *command = NEWSV(1099, 0), *retval;
  SV *ret = NEWSV(1099, 0);
     STRLEN n_a;
  char *tmp;

     sv_setpvf(command, pcommand, s, s1, s2, s3);

     perl_eval_sv(command, G_SCALAR);
     retval = my_perl_eval_sv(command, TRUE);
     SvREFCNT_dec(command);

     ret = perl_get_sv("s", FALSE);
  tmp = SvPV(ret, n_a);
  strcpy(s, tmp);

     return TRUE;
 }





------------------------------

Date: Fri, 03 Sep 1999 14:37:01 +0200
From: Christoph Bauer <bauer@zrz.tu-berlin.de>
Subject: Re: file redirect
Message-Id: <37CFC0ED.D7FAEF5B@zrz.tu-berlin.de>

Hi,

Jim Cromie wrote:
> 
> Hi,
> 
> Im having trouble duplicating STDOUT to a file,  Im not able to get
> plain old prints to write to both STDOUT and a
> 
> $ perl -e  'open( STDOUT, ">swill"); print "junk"'
> 
> works as expected, and creates a file "swill" containing "junk".
> 
> $ perl -e 'open( STDOUT, ">&swill"); print "junk"'
> 
> doesnt work as I expect; it doesnt open a new file "swill",
> 
> I read perldoc -f open, and perldoc perlopentut without gaining real
> insight
> about how to get the above to work, I daresay I dont quite understand
> shell semantics for the  ">&" redirector.
> 
on a unixish system you might try
$ perl -e 'open (STDOUT, "|tee swill); print "junk"'

but that might behave strangely, too.

i'd probably use a sub
sub tee {
  my $text=shift;
  print $text;
  print FH $text;
}

opening/closing FH either each time or only at start/end of the script.
now you can type 
tee ('junk');


HTH
Christoph


------------------------------

Date: Fri, 03 Sep 1999 14:53:34 +0200
From: Christoph Bauer <bauer@zrz.tu-berlin.de>
Subject: Re: file redirect
Message-Id: <37CFC4CE.88C07A13@zrz.tu-berlin.de>

Christoph Bauer wrote:
> 
> Hi,
> 
> Jim Cromie wrote:
> >
> > Hi,
> >
> > Im having trouble duplicating STDOUT to a file,  Im not able to get
> > plain old prints to write to both STDOUT and a
> >

I just found this
http://www.cpan.org/modules/by-module/IO/IO-Tee-0.63.readme

Christoph


------------------------------

Date: Fri, 03 Sep 1999 10:08:32 -0300
From: Nova Crystals <contact@novacrystals.ns.ca>
Subject: Re: Help another Perl newbee
Message-Id: <37CFC850.41C6@novacrystals.ns.ca>

Thanks John, and thanks to John C. would e-mailed me.

Your help is greatly appreciated.  I can now on with my work.

One think though,  out of curiousity, I removed the -1900 and
it still gave me the same result, does this break timelocal at
some point?  I guess I will have to test that one.

Regards
Derek Cole


John M. O'Hara wrote: 
> o Take a look at perlre. In your pattern you're misusing the "?" 
>   quantifier, which matches 0 or 1. Since your date begins with 2
>   digits, the first grouping (\d?) fails, so the whole pattern fails
>   and none of the match variables are assigned. You should check for
>   this.
> 
> o Better to use Time::Local, and the 4-digit year needs to be adjusted
>   relative to 1900. See perlfunc, localtime.
> 
=======================================================================
Derek Cole                | Nova Crystals Ltd. is a producer of custom
                          | glassware and ceramic products.
Nova Crystals Ltd.        |   
5265 Morris Street,       | Ph:  +1 (902) 422 6752 
Halifax, Nova Scotia,     | Fax: +1 (902) 425 7216
Canada, B3J 1B6           | Web: www.novacrystals.ns.ca
=======================================================================


------------------------------

Date: Fri, 03 Sep 1999 13:24:45 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
To: Pierre Mart <pierremart@hotmail.com>
Subject: Re: How to "use strict" in a "perl -s" program?
Message-Id: <37CFAFFD.B667E7E@ife.ee.ethz.ch>

Pierre Mart wrote:
> 
> Dear all,
> 
>     Originally my program worked.
> 
> #!/usr/bin/perl -s
> # usage: hello.pl [-friend=Pierre]
> 
> print "Hello $friend\n" if $friend;    # $friend is passed by -s switch
> 
>     One day, I put "use strict" to restrict it.  It became
> 
> #!/usr/bin/perl -s
> # usage: hello.pl [-friend=Pierre]
> use strict;
> my $friend;    # I have to declare this to pass compiling
> print "Hello $friend" if $friend;
> 
>     I think the line "my $friend" must be wrong because $friend
> was initialized to undef rather than passed by the -s switch.

my $friend creates a new local instance of $friend in the current scope
The other $friend is no longer accessible
You can tell strict to use a variable with "use vars qw/$friend/"
see 'perldoc vars'

- Alex


------------------------------

Date: Fri, 3 Sep 1999 07:15:25 -0400
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: How to match as most as possible ?
Message-Id: <7qoasc$ipi$1@holly.prod.itd.earthlink.net>


<marcza@my-deja.com> wrote:
> Assume the following code:
>
> $A[3] = "one";
> $A[7] = "two";
> $A[73] = "three";
>
> $text = "aAbb3a abaA3baaaAAA bAA77aabA73aa\n";
> $text =~ s/(A([0..73]{1,2}))/$A[$2]/g;
>
> print "OUT=$text#$1#$2#$3#\n";
>
> In the example A3 and A7 is replaced as desired
> but A73 is replaced with $A[7] instead of $A[73].
>
> How can I perform maximal matching ?
>
> Bye
>
> Marcus
>

No.
Perl already does maximal matching.  In your example,
A3 is replaced by $A[$3]
A77 is replaced by $A[77]
A73 is replaced by $A[73]

The actual output from your example is:
OUT=aAbb3a abaonebaaaAAA bAaabthreeaa
#A73#73##

Note: The regular expression [0..73] matches the characters 0, 3, 7, or
period '.'  It is the same as [.037], not at all what is implied by your
notation.






------------------------------

Date: Fri, 03 Sep 1999 12:57:49 GMT
From: Jimmy Humphrey <jimmy@blackhole-designs.com>
Subject: Image Size in Bytes
Message-Id: <37CFC5C0.168C0F71@blackhole-designs.com>

I was wondering how it's possible for me to get an "image size" by bytes
on a CGI upload? I'd like to avoid having to write to the server to get
the size and then deleting it if it's not the write size.

Jimmy


------------------------------

Date: Fri, 3 Sep 1999 06:26:45 -0400
From: <joeyandsherry@mindspring.com>
Subject: LWP::Simple
Message-Id: <7qo7t2$2o6$1@nntp2.atl.mindspring.net>

Thanks in advance.

I've seen reference to this module in previous posts. Where may I locate it?

I've tried to find it on CPAN with no avail.

Thanks.


Joey
-The Race is to the Driven, not the Swift.







------------------------------

Date: 3 Sep 1999 12:18:20 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: LWP::Simple
Message-Id: <7qoeac$rto$1@msunews.cl.msu.edu>

joeyandsherry@mindspring.com wrote:
: I've seen reference to this module in previous posts. Where may I locate it?

: I've tried to find it on CPAN with no avail.

CPAN shouldn't be the first place to check.  Did you check if you
already have it?


-- 
       Dan Nguyen          | It is with true love as it is with ghosts;
    nguyend7@msu.edu       | everyone talks of it, but few have seen it.
     dnn@debian.org        |               -Maxime De La Rochefoucauld
            25 2F 99 19 6C C9 19 D6  1B 9F F1 E0 E9 10 4C 16


------------------------------

Date: Fri, 03 Sep 1999 12:23:39 GMT
From: dgold1@my-deja.com
Subject: printing
Message-Id: <7qoek2$9js$1@nnrp1.deja.com>

Is there a way to include printer control characters in an HTML doc. I
need to force page breaks, adjust headers and footers while printing
some pages. I am using a PERL cgi-script to generate the HTML. I have
tried counting lines, characters, etc... but depending on what is being
printing the counts are off.

Any ideas?


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: Fri, 03 Sep 1999 22:51:34 +1000
From: Pat Heuvel <pheuvel@optusnet.com.au>
Subject: Re: problem with Apache::DBI & mod_perl
Message-Id: <37CFC456.48B0A459@optusnet.com.au>

Gday there,

feketeroland11@my-deja.com wrote:
> 
> Hello !
> I have a little problem with the Apache::DBI module.

<...>

> bevitel is an access 97 database.
> In the ODBC manager i've checked the option: exclusive for the DSN..
> This script is working if it's run once in the same time.
> But if it is running twice in the same a time, "older" process is
> working, but the "newer"
> process is crashed. So, this is not a persistent database connection!

What has persistence to do with it? If you've selected "Exclusive", only
one process will be able to open the database at a time! Graphically
illustrated by what happens when you turn off "Exclusive". This is
exactly what the exclusive flag is for!

> If idon't check the exclusive mode in the DSN,  the several processes
> working
> correctly in the same time.
> 
Ditto.

Hope this helps.
Pat
-- 

+---------------------------------------------------------+
+  "Logic clearly dictates, that the strokes of the many  +
+   outweigh the strokes of the two..."                   +
+                             (Apologies to Mr Spock)     +
+---------------------------------------------------------+


------------------------------

Date: Thu, 02 Sep 1999 10:32:01 GMT
From: psw@net1plus.com (Peter Wilford)
Subject: Problems useing modules
Message-Id: <37ce4b4e.81463082@news.net1plus.com>

Greetings,

I am a 'newbie' at Perl, so I thought I would seek the 'Holy Grail'.
Sorry for this intrusion, however, I have scoured the FAQ's, to see if
my methodology was wrong (obviously it is) but I can't identify the
cause.  I then attempted to use PPM to install 'libwin32',
'Win32-NetResource' and 'libnet', but still have problems using the
modules...  I am running on Win'98 (not by choice), and have the
following 'snippet' in my Perl script:

#=====================
use Win32;
use Win32::NetResource;

Win32::NetResource::NetShareGetInfo( "share_a", \%SHARE, "Test" );
#=====================

When executed this way, the following error comes to my debug window:

Can't load 'C:/Perl/site/lib/auto/Win32/NetResource/NetResource.dll'
for module Win32::NetResource: load_file:A device attached to the
system is not functioning at C:/Perl/lib/DynaLoader.pm at line 169.

If I 'pound out' the "use Win32::NetResource;" line, and debug the
script, it states that I have an 'Undefined Subroutine'...

Can someone give me some direction as to where to look for this
problem (other than myself)...  Am I coding it correctly?  Is it
because I am on Win'98 (Not a true Win32 platform), that I am having
this problem...  Please help...

Thank you,

Peter Wilford


------------------------------

Date: Fri, 03 Sep 1999 10:34:04 GMT
From: "Allan M. Due" <All@n.due.net>
Subject: Re: shebang question for Win32 Perl/Apache
Message-Id: <wuNz3.124$gS2.126@news.rdc1.ct.home.com>

M van Oosterhout <s3100411@student.anu.edu.au> wrote in message
news:37CF3CCB.1632@student.anu.edu.au...
: Allan M. Due wrote:
: >
: > As you note, neither Perl nor Apache care about the
: > direction of your slashes...
: FYI, DOS didn't care either, I used it extensively.
: It wouldn't suprise me if that 'not caring' was not
: even a special case but simply worked because Windows
: understands it.

In a general sense that is true but in the specific it may lead to
unexpected results.  While there are many cases in which DOS doesn't care
there are many where it does matter.  A couple of simple examples: from the
root directory of C what does:
cd c:/windows do under your version of dos?
How about cd "C:/windows" as opposed to cd "C:\windows" ?

To my way of thinking, it might be a bit generous to say that DOS doesn't
care about the path separator.  DOS tends to be a bit fickle.

AmD
[posted and a similar version emailed (didn't catch the stealth cc at first)

--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--Random Quote--
Skill in manipulating numbers is a talent, not evidence of divine guidance.
  Ashley-Perry Statistical Axioms[2]





------------------------------

Date: Fri, 03 Sep 1999 11:03:18 GMT
From: "Allan M. Due" <All@n.due.net>
Subject: Re: shebang question for Win32 Perl/Apache
Message-Id: <WVNz3.129$gS2.158@news.rdc1.ct.home.com>

Allan M. Due <All@n.due.net> wrote in message
news:wuNz3.124$gS2.126@news.rdc1.ct.home.com...
: M van Oosterhout <s3100411@student.anu.edu.au> wrote in message
: news:37CF3CCB.1632@student.anu.edu.au...
: : FYI, DOS didn't care either,
[snip]
: In a general sense that is true but in the specific it may lead to
: unexpected results.  While there are many cases in which DOS doesn't care
: there are many where it does matter.  A couple of simple examples: from
the
: root directory of C what does:
: cd c:/windows do under your version of dos?
: How about cd "C:/windows" as opposed to cd "C:\windows" ?

Ok, I decided that was a bad example as it is more about feeding parameters
to a DOS command than DOS itself.  To use an example from this thread, at
the prompt:

c:\usr\local\bin\perl

starts up perl just fine but

c:/usr/local/bin/perl
does not.

AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--Random Quote--
I dunno, I dream in Perl sometimes...
   Larry Wall in  <8538@jpl-devvax.JPL.NASA.GOV>





------------------------------

Date: Fri, 03 Sep 1999 12:08:46 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: shebang question for Win32 Perl/Apache
Message-Id: <37cfb962.383706@news.skynet.be>

Allan M. Due wrote:

>To my way of thinking, it might be a bit generous to say that DOS doesn't
>care about the path separator.  DOS tends to be a bit fickle.

We're talking about the shebang ("#!") line. DOS doesn't know about
shebang lines.

(DOS) programs that do know about it, will also accept "/" as directory
separators. That definitely includes Perl. I have no experience with
Apache to know if the exact path (apart from the "perl" part) even
matters; but if it matters, forward slahes very likely will work.

-- 
	Bart.


------------------------------

Date: 3 Sep 1999 08:22:21 -0400
From: gabor@vmunix.com (Gabor)
Subject: Re: String Length
Message-Id: <slrn7svfbt.sga.gabor@vnode.vmunix.com>

In comp.lang.perl.misc, Jason Hurst <variant@pacifier.com> wrote :
# Ok, i'm sure there is a very simple solution to this and i'll feel real
# stupid when someone tells me, but i can't figure out how to get the length
# of a string.  Someone told me about a count function, but it didn't seam
# to work for me.  I'm using perl in a win32 invirontment, if that makes any
# differance, but i wouldn't think so.  Any help would be appreciated.
# Thanks!
# 
# Jason Hust
# jasonh@colubs.com
# 

Your question is also your answer.  Yeah, I've been waiting to say
that for a while. :)


------------------------------

Date: 3 Sep 1999 06:48:19 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: tee cmd in PERL?
Message-Id: <37cfc393@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    akluyskens@my-deja.com writes:
:Hi,
:
:I need the PERL equivalent of the unix "tee" command to redirect the
:output of a function to <STDOUT> and a FILE(HANDLE). Can anyone help me
:out of this problem.

    open(STDOUT, "| tee file1 file2 file3");

--tom
-- 
"...only here did the human soul in a higher sense acquire depth and become
 evil - and these are the two basic respects in which man has hitherto been 
 superior to other beasts!" - Friedrich Nietzsche


------------------------------

Date: 3 Sep 1999 06:49:25 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: tee cmd in PERL?
Message-Id: <37cfc3d5@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    akluyskens@my-deja.com writes:
:I need the PERL equivalent of the unix "tee" command to redirect the
:output of a function to <STDOUT> and a FILE(HANDLE). Can anyone help me
:out of this problem.

#!/usr/bin/perl
#
# tee clone that groks process tees (should work even with old perls)
# Tom Christiansen <tchrist@convex.com>
# 6 June 91

while ($ARGV[0] =~ /^-(.+)/ && (shift, ($_ = $1), 1)) {
    next if /^$/;
    s/i// && (++$ignore_ints, redo); 
    s/a// && (++$append,      redo);
    s/u// && (++$unbuffer,    redo);
    s/n// && (++$nostdout,    redo);
    die "usage tee [-aiun] [filenames] ...\n";
} 
if ($ignore_ints) {
    for $sig ('INT', 'TERM', 'HUP', 'QUIT') { $SIG{$sig} = 'IGNORE'; } 
}
$SIG{'PIPE'} = 'PLUMBER';
$mode = $append ? '>>' : '>';
$fh = 'FH000';
unless ($nostdout) { 
    %fh = ('STDOUT', 'standard output'); # always go to stdout
}
$| = 1 if $unbuffer;

for (@ARGV) {
    if (!open($fh, (/^[^>|]/ && $mode) . $_)) {
	warn "$0: cannot open $_: $!\n"; # like sun's; i prefer die
	$status++;
	next;
    }
    select((select($fh), $| = 1)[0]) if $unbuffer;
    $fh{$fh++} = $_;
} 
while (<STDIN>) {
    for $fh (keys %fh) {
	print $fh $_;
    } 
} 
for $fh (keys %fh) { 
    next if close($fh) || !defined $fh{$fh};
    warn "$0: couldn't close $fh{$fh}: $!\n";
    $status++;
}
exit $status;

sub PLUMBER {
    warn "$0: pipe to \"$fh{$fh}\" broke!\n";
    $status++;
    delete $fh{$fh};
} 
-- 
"Americans are broad-minded people. They'll accept the fact that a person
 can be an alcoholic, a dope fiend, a wife beater, and even a newspaperman,
 but if a man doesn't drive, there is something wrong with him."
				- Art Buchwald


------------------------------

Date: 3 Sep 1999 06:50:42 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: tee cmd in PERL?
Message-Id: <37cfc422@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    akluyskens@my-deja.com writes:
:I need the PERL equivalent of the unix "tee" command to redirect the
:output of a function to <STDOUT> and a FILE(HANDLE). Can anyone help me
:out of this problem.


    # see tee() function below
    tee("/tmp/foo", "/tmp/bar", "/tmp/glarch");

    while (<>) {
        print "$ARGV at line $. => $_";
    }
    close STDOUT;

    # tee via fork-open.
    sub tee {
        my @output = @_;
        my @handles = ();
        for my $path (@output) {
            local *FH;
            unless (open (FH, "> $path")) {
                warn "cannot write to $path: $!";
                next;
            }
            push @handles, *FH;
        }
        return if my $pid = open(STDOUT, "|-");
        die "cannot fork: $!" unless defined $pid;

        while (<STDIN>) {
            for my $fh (@handles) {
                print $fh $_;
            }
        }
        exit;
    }                                      

--tom
-- 
 complains about you having a gratuitous patent.
 "VAX. For those who care enough to steal the very best."
	 -- A microscopic message on the silicon chip inside
	    one of Digital Equipment's often stolen computer designs.


------------------------------

Date: Fri, 03 Sep 1999 14:52:25 +0200
From: Christoph Bauer <bauer@zrz.tu-berlin.de>
Subject: Re: tee cmd in PERL?
Message-Id: <37CFC489.BA816C4E@zrz.tu-berlin.de>

Hi,

akluyskens@my-deja.com wrote:
> 
> Hi,
> 
> I need the PERL equivalent of the unix "tee" command to redirect the
> output of a function to <STDOUT> and a FILE(HANDLE). Can anyone help me
> out of this problem.
> 
you might want to look at
http://www.cpan.org/modules/by-module/IO/IO-Tee-0.63.readme

HTH
Christoph


------------------------------

Date: 3 Sep 1999 06:56:05 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: tee cmd in PERL?
Message-Id: <37cfc565@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    akluyskens@my-deja.com writes:
:I need the PERL equivalent of the unix "tee" command to redirect the
:output of a function to <STDOUT> and a FILE(HANDLE). Can anyone help me
:out of this problem.

    $mode = $SHOULD_WE_APPEND ? ">>" : ">";
    @handles = ();
    for $filename ("file1", "file2", "file3") {
	local *FH;
	open(FH, "$mode $filename")	
	    || die "can't open $filename: $!";
	push @handles, *FH;
    } 

    for $fh (@handles) {
	print $fh "data\n";
    } 

or 

    sub mprint(\@@) {
	my ($aref, @data) = @_;
	for $fh (@$aref) {
	print $fh "data\n";
	} 
    } 

    mprint(@handles, "this", "that");

--tom
-- 
"Rarely do great beauty and great virtue dwell together.
				- Petrarch


------------------------------

Date: 3 Sep 1999 06:58:41 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: tee cmd in PERL?
Message-Id: <37cfc601@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    akluyskens@my-deja.com writes:
:I need the PERL equivalent of the unix "tee" command to redirect the
:output of a function to <STDOUT> and a FILE(HANDLE). Can anyone help me
:out of this problem.

    use Tie::Tee;
    tie *TEE, 'Tie::Tee', *STDOUT, *STDERR;
    print TEE "This line goes both places.\n";

Or a more elaborate example:

    use Tie::Tee;
    use Symbol;

    @handles = (*STDOUT);
    for $i ( 1 .. 10 ) {
        push(@handles, $handle = gensym());
        open($handle, ">/tmp/teetest.$i");
    } 

    tie *TEE, 'Tie::Tee', @handles;
    print TEE "This lines goes many places.\n";

And here's the Tie/Tee.pm file:

    package Tie::Tee;

    sub TIEHANDLE {
        my $class   = shift;
        my $handles = [@_];

        bless $handles, $class;
        return $handles;
    }

    sub PRINT {
        my $href = shift;
        my $handle;
        my $success = 0;

        foreach $handle (@$href) {
            $success += print $handle @_;
        }
        return $success == @$href;
    }                                     
    1;

--tom
-- 
    Q. Why is this so clumsy?
    A. The trick is to use Perl's strengths rather than its weaknesses.
            --Larry Wall in <8225@jpl-devvax.JPL.NASA.GOV>


------------------------------

Date: 3 Sep 1999 07:00:20 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: tee cmd in PERL?
Message-Id: <37cfc664@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    akluyskens@my-deja.com writes:
:I need the PERL equivalent of the unix "tee" command to redirect the
:output of a function to <STDOUT> and a FILE(HANDLE). Can anyone help me
:out of this problem.

s/PERL/Perl/
s/unix/Unix/

The Perl equivalent of the Unix "tee" command is of course the Unix
"tee" command.

Perl is not an operating system.  It is a programming language. 
Use the toolset.  That's what it's there for.

--tom
-- 
    Just don't compare it with a real language, or you'll be unhappy...  :-)
            --Larry Wall in <1992May12.190238.5667@netlabs.com>


------------------------------

Date: 3 Sep 1999 07:03:47 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: tee cmd in PERL?
Message-Id: <37cfc733@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    akluyskens@my-deja.com writes:
:I need the PERL equivalent of the unix "tee" command to redirect the
:output of a function to <STDOUT> and a FILE(HANDLE). Can anyone help me
:out of this problem.

I could tell you, but then you'd actually have to install an 
operating system on your poor deprived computer, which doubtless
is currently screwed out of having real tools.  This is yet
another case of not getting what you paid for.

--tom
-- 
 He who hasn't hacked assembly language as a youth has no
 heart. He who does so as an adult has no brain.


------------------------------

Date: Fri, 3 Sep 1999 09:04:10 -0300
From: George White <aa056@chebucto.ns.ca>
To: Wyzelli <wyzelli@yahoo.com>
Subject: Re: That Cargo Date Code ( was Re: Y2K)
Message-Id: <Pine.GSO.3.95.iB1.0.990903085254.21069A-100000@halifax.chebucto.ns.ca>

On Fri, 3 Sep 1999, Wyzelli wrote:

> Martien Verbruggen <mgjv@comdyn.com.au> wrote in message
> news:DXEz3.204$Of6.6005@nsw.nnrp.telstra.net...
> > Besides that, I have found that most of the well organised Open Source
> 
> Well organised is the key.  Open source certainly seems to be free of many
> of the political and marketing imperatives which plague commercial 'crap'.
> People doing what they like doing because they are good at it and like the
> result is better than people doing it for a 'career' or because you have to.
> 
> > projects produce much better code than any commercial product I've
> > ever seen. Believe me, I work with both here, and the only things
> 
> I have to say I pretty much agree with the rest of your comments.
> 
> Wyzelli
 
Now that "open source" has become fashionable, there is a risk that the
good stuff will become diluted in a sea of junk.  Many of the most
successful open source projects have been "clones" of existing designs,
presumably chosen in part a) because the underlying design was good and b) 
there were opportunities to make improvements or at least a different set
of tradeoffs in the implementation.  
 
I expect we will start to see greater reliance on peer review and
"publishers" like Red Hat to help filter out the junk, much as scientists
rely on peer reviewed publications.  

--
George White <aa056@chebucto.ns.ca> Halifax, Nova Scotia



------------------------------

Date: 3 Sep 1999 08:19:26 -0400
From: gabor@vmunix.com (Gabor)
Subject: Re: Where a subroutine gets called from?
Message-Id: <slrn7svf6e.sga.gabor@vnode.vmunix.com>

In comp.lang.perl.misc, Ala Qumsieh <aqumsieh@matrox.com> wrote :
# 
# moseley@best.com (Bill Moseley) writes:
# 
# > Denis Kotseba (kdl@softhome.net) seems to say...
# > > How can I find out which subrotine (a or b) called c without passing an
# > > extra parameter?
# > 
# > try perldoc -f caller and see if that returns what you want.
# 
# No. That will not work.

What are you smoking?


------------------------------

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu. 

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 V9 Issue 710
*************************************


home help back first fref pref prev next nref lref last post