[22344] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4565 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 13 18:11:18 2003

Date: Thu, 13 Feb 2003 15:10:13 -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           Thu, 13 Feb 2003     Volume: 10 Number: 4565

Today's topics:
    Re: problem with "piping" data from STDOUT into the Per <goldbb2@earthlink.net>
        Problems with embedding Perl in C++ (Ryan McAvoy)
    Re: Problems with embedding Perl in C++ <goldbb2@earthlink.net>
    Re: Re Installing modules from CPAN (Anno Siegel)
    Re: RegEx Questions <tore@aursand.no>
    Re: Socket command <Peter.Dintelmann@dresdner-bank.com>
    Re: Socket command <nobull@mail.com>
    Re: Socket command <goldbb2@earthlink.net>
    Re: Socket command <bkennedy@hmsonline.com>
        split and join (Drew Myers)
    Re: split and join <pinyaj@rpi.edu>
    Re: split and join (Anno Siegel)
    Re: strict and warnings <abigail@abigail.nl>
    Re: strict and warnings <tassilo.parseval@post.rwth-aachen.de>
    Re: strict and warnings <goldbb2@earthlink.net>
    Re: strict and warnings <abigail@abigail.nl>
    Re: strict and warnings <abigail@abigail.nl>
    Re: Using Archive::Tar for in-memory tarfiles <eric.schwartz@hp.com>
    Re: Using Archive::Tar for in-memory tarfiles <goldbb2@earthlink.net>
    Re: Using Archive::Tar for in-memory tarfiles <eric.schwartz@hp.com>
    Re: Using Archive::Tar for in-memory tarfiles <eric.schwartz@hp.com>
    Re: Using Archive::Tar for in-memory tarfiles <goldbb2@earthlink.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 13 Feb 2003 14:44:31 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: problem with "piping" data from STDOUT into the PerlTK's Text widget  - blocking pipe
Message-Id: <3E4BF59F.4BE511EB@earthlink.net>

[posted and mailed]
"Proutski,V. (Vitali)" wrote:
> 
> Dear Benjamin,
> Thank you very much for your explanation. I guessed that the problem
> was with the pipe capacity and the fact that I only use one process
> and of course when it blocks on writing in cannot unblock itself by
> reading. I however thought that it was possible to make filenandles
> work in a nonblocking mode, is it?

Sure, but all this means is that when you *try* to write, nothing will
get written if the pipe happens to be full.  Your excess data will get
lost.

> On the other hand if you are saying that the easies way to do what I
> want is by tieing a glob - then could you give a hint at how exactly I
> can collect data from the filehandle and insert then in the Text
> widget.

It's not a matter of "collecting" the data -- it's a matter of making it
so that as soon as you try to 'print' to the handle, it magically gets
sent straight to the widget.  It never gets stored anywhere, as it would
with a pipe.

Try this code [you might want to rename 'MyTieClass' to something more
descriptive]

tie *STDOUT, "MyTieClass", $w->Subwidget("TextField");

BEGIN {
   require Tie::Handle;
   @MyTieClass::ISA = qw(Tie::Handle);
}
sub MyTieClass::TIEHANDLE {
   my ($class, $TextField) = @_;
   bless \$TextField, $class
}
sub MyTieClass::WRITE {
   my $TextField = ${ $_[0] };
   $TextField->insert( 'end', substr $_[1], $_[3], $_[2] );
   $TextField->yview( 'end' );
}
__END__
[untested]

> I do not understand how can I write and read from the same filehandle

You generally can't (sockets and socketpairs are the execeptions).  But
I'm not suggesting that, so it doesn't matter.

> (I tried to use pipe exactly to be able to print in STDOUT pipe
> from it into INPUTHANDLE and sysread from it). To be honest I am not
> familiar with "tieing" variables.

Read perldoc perltie, and perldoc Tie::Handle

> I am reading the chapter on tied variables now,

The best documentation for perl is the documentation which *comes* with
perl.  I've got some perl books collecting dust on my shelf -- I never
use them -- I'm fine using just the perldoc command.

> but still not quite clear about what I need to do.
> I am sorry I'm trying to pick your brain but you are the only one so
> far who have responded.

Don't assume that I'm the *only* person who knows the solution to your
problems -- I just happened to be the first person who read your post
and chose to respond; doubtless there are many others who understood
your problem and knew of a solution, but most likely, they saw my
response and thought it sufficient, and thus chose not to add anything.

Further, just because I was the only one who responded is no reason to
send me direct mail.

Now, if you needed more help, and that required that you give me more
information about your project, and you needed that information kept
confidential, and didn't want it on usenet, *then* it would make sense
to send direct email.  Or, if you were offering a job, then, too, it
would be something for direct email.

But an ordinary followup, asking for clarification, is best done via
usenet, so that other usenet readers can get the benefit of any
expertise in the response(s) to the followup.

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: 13 Feb 2003 08:20:16 -0800
From: ted017@yahoo.com (Ryan McAvoy)
Subject: Problems with embedding Perl in C++
Message-Id: <d72bd836.0302130820.5efea156@posting.google.com>

Hello:

I'm having some problems with embedding PERL into my C++ code, a
functional problem and a memory problem.

1. I parse a file into my perl interpreter as follows:


   PerlInterpreter *my_perl;
   my_perl = perl_alloc();
   perl_construct( my_perl );

   ...

   perl_parse( my_perl, NULL, 2, perlArgs, (char**) NULL ) );

I then proceed to make calls on the subroutines found in the file
using call_pv.  As the program runs, new files are parsed.  I would
like the subroutines from all parsed files to be available.  I find,
however, that only the subroutines from the last parsed file are
available.

Is there a way when parsing a new file to maintain all previously
parsed code in the interpreter?

2. My second problem is as follows.  To work around the first problem,
I keep track of which files have been parsed.  When a new file needs
to be parsed, I create a temporary file containing the contents of all
files.  I then parse this file, giving me access to all subroutines.

The problem I have is that this approach causes the memory usage of my
task to continually grow.

I have tried deleting the perl interpreter and reconstructing between
parse's of files.  This does not improve memory usage at all.  I tried
deleting the perl interpreter as follows:

    PL_perl_destruct_level = 1;
    perl_destruct(my_perl);
    perl_free(my_perl);
    delete my_perl;

I am running on Redhat Linux 7.2, perl revision 5.0 version 8
subversion 0.

I would appreciate any assistance that anyone can provide.

Thanks,
Ryan McAvoy


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

Date: Thu, 13 Feb 2003 13:46:10 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Problems with embedding Perl in C++
Message-Id: <3E4BE7F2.5A69F8E9@earthlink.net>

Ryan McAvoy wrote:
> 
> Hello:
> 
> I'm having some problems with embedding PERL into my C++ code, a
> functional problem and a memory problem.
> 
> 1. I parse a file into my perl interpreter as follows:
> 
>    PerlInterpreter *my_perl;
>    my_perl = perl_alloc();
>    perl_construct( my_perl );
> 
>    ...
> 
>    perl_parse( my_perl, NULL, 2, perlArgs, (char**) NULL ) );
> 
> I then proceed to make calls on the subroutines found in the file
> using call_pv.  As the program runs, new files are parsed.

Err, parsed how?  By calling perl_parse again?

> I would like the subroutines from all parsed files to be available.
> I find, however, that only the subroutines from the last parsed file
> are available.

Hmm, definitely sounds like you're calling perl_parse again.  Don't do
that.  Instead, use require_pv.

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: 13 Feb 2003 17:39:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Re Installing modules from CPAN
Message-Id: <b2gl7m$l01$1@mamenchi.zrz.TU-Berlin.DE>

Brian Smart <brian.smart@blueyonder.co.uk> wrote in comp.lang.perl.misc:
> Hello Randy,
> I did the 'o conf init' option and accepted all the defaults except for the
> selection of the CPAN Mirrors, but I keep getting the same fault. I do have
> a directory under cgi-bin, 'n/sources'. This contains a document
> 'MIRRORED.BY' which I assume details the sites I selected during the 'o conf
> init' opreration.

Ah, it thinks .../cgi-bin/n is your .cpan file.  You will have to set that
right.  I don't think you can configure that through "o conf init", but the
first-time setup asks for it.  You'll have to get CPAN to run that.

Anno


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

Date: Thu, 13 Feb 2003 20:44:41 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: RegEx Questions
Message-Id: <pan.2003.02.11.21.13.23.394274@aursand.no>

On Tue, 11 Feb 2003 09:54:07 -0700, ColdCathoids wrote:
>> s/^(.*)\s+on\s+(.*)\s+(\d+\.\d+)\s+(\d+\.\d+)\s+(.*)$/$1,$2,$3,$4,$5/;

> Now ... any chance you could explain what that line actually does? =)

Nah.  That would take too long. :)  Read a book on regular expressions
(Master Regular Expressions from O'Reilly, for example).

The regular expression does, in short, substitute the data you already got
with the matches you want in the preferred format.

--
Tore Aursand - tore@aursand.no - http://www.aursand.no/


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

Date: Thu, 13 Feb 2003 17:15:10 +0100
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: Socket command
Message-Id: <b2gf5q$6vn5@news-1.bank.dresdner.net>

    Hi,

"Catharsis" <tribe_founder@hotmail.com> schrieb im Newsbeitrag
news:e1060275.0302130601.3eb6492a@posting.google.com...

    [snip]

> I thought if I did from the client
>
> print SOCKET "hello" || die "argh I couldnt say hello";

    now "hello" is probably in the buffer and has not
    reached the server yet. Use $| to unbuffer your handle,
    see perldoc -q flush

    HTH,

        Peter






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

Date: 13 Feb 2003 17:42:07 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Socket command
Message-Id: <u93cmsulg0.fsf@wcl-l.bham.ac.uk>

tribe_founder@hotmail.com (Catharsis) writes:

> read Client, $command, -s Client;

What do you expect -s to do on a socket?

Where did you get this expectation?

> The code is pretty much as the IPC example.

Where is this example that uses -s on a socket?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 13 Feb 2003 13:39:05 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Socket command
Message-Id: <3E4BE649.4D1AB19F@earthlink.net>

Catharsis wrote:
> 
> Hi.
> 
> Im pretty stumped, been looking through and reading the perlipc on how
> to make a client and server and using the examples i have bothe up and
> running.  Now the bit which Im having trouble with is that I send
> information from the Client to the server socket but I cant seam to
> capture that information that the client sends.
> 
> I thought if I did from the client
> 
> print SOCKET "hello" || die "argh I couldnt say hello";
> 
> and in the server I would need to do
> 
> read Client, $command, -s Client;
> logmsg "command = $command";
> 
> But this does not seam to want to work, 
> can anyone provide any usefull info? 

This is because -s Client returns zero, until there's data to be read
from the client (or, depending on the system, *always* returns 0). 
Additionally, your code doesn't bother to do anything to wait until
there is data to be read from the client.

Try this:
my ($command, $wvec, $timeout) = ("", "", undef);
vec( $wvec, fileno(Client), 1 ) = 1;
while( 1 ) {
   select( undef, $wvec, undef, $timeout ) > 0 or last;
   my $len = -s Client;
   $len = 8192 if !$len or $len < 8192;
   sysread( Client, $command, $len, length $command )
      or last;
   $timeout = 0;
}
logmsg "command = $command";

This blocks until at least some data is available, then keeps reading
(without blocking) until all the data that's available has been read.

> The code is pretty much as the IPC example.

Really?  I see *no* place where '-s' is used on a socket, or where
read() is used on a socket.

(Note that read() and readline() (aka <>) are both incompatible with
4-arg-select, and will eventually produce a deadlock.  Well, they will
unless you have a *very* thorough understanding of how and why this type
of deadlock will occur, and carefully take steps to avoid it.)

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: Thu, 13 Feb 2003 15:37:45 -0500
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Socket command
Message-Id: <DdGdnfMZucsun9GjXTWcoQ@giganews.com>


"Catharsis" <tribe_founder@hotmail.com> wrote in message
news:e1060275.0302130601.3eb6492a@posting.google.com...
>
> print SOCKET "hello" || die "argh I couldnt say hello";
>
> and in the server I would need to do
>
> read Client, $command, -s Client;
> logmsg "command = $command";
>

I suggest you reboot your attempt at learning sockets and look at the
IO::Socket module - this is covered in perldoc perlipc (which should
probably be rearranged to place the IO::Socket section first IMO).  Also try
plugging "IO::Socket Tutorial" into google

--Ben Kennedy





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

Date: 13 Feb 2003 09:21:41 -0800
From: bh_ent@hotmail.com (Drew Myers)
Subject: split and join
Message-Id: <d1b6a249.0302130921.5ed71108@posting.google.com>

Hi,

I have a couple of questions in reference to the code below.

__infile__
474683    524288         3       13       0.9 226 2      98.3     
98.2     98.2
      98.1
474683    524288         6        0       1.0 284 2      94.7     
98.2     96.7
      98.2
474683    524288         4        0       1.0 276 4      99.6     
99.2     98.2
      98.9
__END__

__Script__
#!/usr/bin/perl -w
use strict;

my $infile = "infile";

open (INFILE,"$infile") or die "Can't open $infile: $!\n";
while (my $line = <INFILE>) {
    print join(',',(split' ',$line));
    print "\n";
}
close (INFILE) or die "Can't close $infile: $!\n";
__End of Script__


I find myself using the join-split idiom quite often, but I'm curious
what other ways there are to accomplish the same thing.

Thanks for your insight.


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

Date: Thu, 13 Feb 2003 12:35:52 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Drew Myers <bh_ent@hotmail.com>
Subject: Re: split and join
Message-Id: <Pine.SGI.3.96.1030213122955.81097C-100000@vcmr-64.server.rpi.edu>

On 13 Feb 2003, Drew Myers wrote:

>    print join(',',(split' ',$line));
>    print "\n";

>I find myself using the join-split idiom quite often, but I'm curious
>what other ways there are to accomplish the same thing.

Well, I think join(X, split Y) is the simplest way to accomplish it --
it's self-documenting, for one thing.  split(' ') is magical, since it
ignores leading whitespace, so if you wanted to do some s/.../.../g thing,
you'd need to first do

  s/^\s+//;

After ignoring leading whitespace, split(' ') behaves like split(/\s+/),
and you've not requested split return empty trailing fields[1], you'd need
to remove TRAILING whitespace:

  s/\s+$//;  # slightly inefficient[2]

Then you'd be all set to do

  s/\s+/,/g;

Why go through all that trouble, though?


[1] split(' ', " a b c ")     => ('a', 'b', 'c')
    split(' ', " a b c ", -1) => ('a', 'b', 'c', '')

[2] s/X+$// doesn't start at the end of the string and look backward for
X's, but rather looks at every group of X's in the string to see if
they're followed by the end of the string.  From a crazy optimization
point of view (which I've been known to have from time to time), you can
use the sexeger approach:

  ($_ = reverse) =~ s/^\s+//; $_ = reverse;
  # instead of:  s/\s+$//  

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: 13 Feb 2003 18:00:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: split and join
Message-Id: <b2gmg3$m5h$1@mamenchi.zrz.TU-Berlin.DE>

Drew Myers <bh_ent@hotmail.com> wrote in comp.lang.perl.misc:

[snippage]

>     print join(',',(split' ',$line));

> I find myself using the join-split idiom quite often, but I'm curious
> what other ways there are to accomplish the same thing.

For a rough equivalent, use "tr/ /,/s".  It ought to be super-fast, if
that is a concern.  However, see Jeff Pinyan's detailed article about,
umm, boundary conditions.

Anno


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

Date: 13 Feb 2003 21:39:54 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: strict and warnings
Message-Id: <slrnb4o45a.hts.abigail@alexandra.abigail.nl>

Helgi Briem (helgi@decode.is) wrote on MMMCDLIII September MCMXCIII in
<URL:news:3e4b70da.512876537@news.cis.dfn.de>:
,,  On Wed, 12 Feb 2003 20:14:56 -0500, Benjamin Goldberg
,, <goldbb2@earthlink.net> wrote:
,,  
,, >>Abigails .sig:
,,  
,, >>rand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]

     ^^^^  There's something missing here.

,, >>for(reverse+1..(@[=split//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));
,, >>print+(map{$_^q^"^}@[),"\n"
,,  
,, >PS: Your .sig produces: "o JutPrerclrHtek naahe s" on AS Perl 5.6.1.
,,  
,,  Not at all, it produces:
,,  
,,  araknsrt ehuJH oe rPeltc
,,  
,,  Then again it produces:
,,  
,,  tueea olrJckPHer ra htsn
,,  
,,  Oh, no! I'm getting:
,,  
,,  rentrJ etaehkPcslu Hra o
,,  
,,  I think the 'rand' bits may be a clue.


If you are not getting consistent results, either your version of Perl,
or your OS is broken. But that assumes you're using 'srand' as the
first word, not 'rand'.

The quoted JAPH will give the expected output on at least one OS/Perl
version combo.


Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: 13 Feb 2003 21:59:27 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: strict and warnings
Message-Id: <b2h4fv$8ft$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Abigail:

[ srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
  //=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"// ]
  
> If you are not getting consistent results, either your version of Perl,
> or your OS is broken. But that assumes you're using 'srand' as the
> first word, not 'rand'.

I consistently get "eresal nPhkuHrJ  cteatro" on 5.6.1 and 5.8.1.
5.005_03 results in "rel rehcnPtHes tkua oarJ". This is on Debian.

Mac OS X (5.6.0) produces "r nlkerJtherPct aeHa suo", hmmh.

> The quoted JAPH will give the expected output on at least one OS/Perl
> version combo.

On FreeBSD and Solaris (with 5.005_03 both) they work fine.

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: Thu, 13 Feb 2003 17:14:22 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: strict and warnings
Message-Id: <3E4C18BE.F3BCED65@earthlink.net>

Abigail wrote:
> 
> Helgi Briem wrote:
> ,,  Benjamin Goldberg wrote:
[snip]
> ,, >PS: Your .sig produces: "o JutPrerclrHtek naahe s" on AS Perl
> ,, >5.6.1.
[snip]
> If you are not getting consistent results, either your version of
> Perl, or your OS is broken. But that assumes you're using 'srand' as
> the first word, not 'rand'.

Well, I am consistantly getting "o JutPrerclrHtek naahe s", no matter
how often I run it (yes, I used 'srand', not 'rand' as the first word).

> The quoted JAPH will give the expected output on at least one OS/Perl
> version combo.
> 
> Abigail
> --
> perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
>              "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
>              "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'

Of course, these quotes don't work with command.com, and even if they
did, `echo "Just another Perl Hacker" > /dev/tty` wouldn't dwym.

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: 13 Feb 2003 22:27:55 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: strict and warnings
Message-Id: <slrnb4o6vb.hv0.abigail@alexandra.abigail.nl>

Benjamin Goldberg (goldbb2@earthlink.net) wrote on MMMCDLIII September
MCMXCIII in <URL:news:3E4C18BE.F3BCED65@earthlink.net>:
``  Abigail wrote:
`` > 
`` > Helgi Briem wrote:
`` > ,,  Benjamin Goldberg wrote:
``  [snip]
`` > ,, >PS: Your .sig produces: "o JutPrerclrHtek naahe s" on AS Perl
`` > ,, >5.6.1.
``  [snip]
`` > If you are not getting consistent results, either your version of
`` > Perl, or your OS is broken. But that assumes you're using 'srand' as
`` > the first word, not 'rand'.
``  
``  Well, I am consistantly getting "o JutPrerclrHtek naahe s", no matter
``  how often I run it (yes, I used 'srand', not 'rand' as the first word).


Then neither your OS, nor your Perl is broken when it comes to srand()
functionality.


`` > The quoted JAPH will give the expected output on at least one OS/Perl
`` > version combo.
`` > 
`` > Abigail
`` > --
`` > perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164"
`` >              "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162"
`` >              "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
``  
``  Of course, these quotes don't work with command.com, and even if they
``  did, `echo "Just another Perl Hacker" > /dev/tty` wouldn't dwym.


I made JAPHs for my own fun and entertainment. I generally don't care
at all whether my code will run on Window systems, and especially not
for JAPHs.


Abigail
-- 
@;=split//=>"Joel, Preach sartre knuth\n";$;=chr 65;%;=map{$;++=>$_}
0,22,13,16,5,14,21,1,23,11,2,7,12,6,8,15,3,19,24,14,10,20,18,17,4,25
;print@;[@;{A..Z}];


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

Date: 13 Feb 2003 22:28:43 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: strict and warnings
Message-Id: <slrnb4o70r.hv0.abigail@alexandra.abigail.nl>

Tassilo v. Parseval (tassilo.parseval@post.rwth-aachen.de) wrote on
MMMCDLIII September MCMXCIII in <URL:news:b2h4fv$8ft$1@nets3.rz.RWTH-Aachen.DE>:
__  Also sprach Abigail:
__  
__  [ srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
__    //=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"// ]
__    
__ > If you are not getting consistent results, either your version of Perl,
__ > or your OS is broken. But that assumes you're using 'srand' as the
__ > first word, not 'rand'.
__  
__  I consistently get "eresal nPhkuHrJ  cteatro" on 5.6.1 and 5.8.1.
__  5.005_03 results in "rel rehcnPtHes tkua oarJ". This is on Debian.
__  
__  Mac OS X (5.6.0) produces "r nlkerJtherPct aeHa suo", hmmh.
__  
__ > The quoted JAPH will give the expected output on at least one OS/Perl
__ > version combo.
__  
__  On FreeBSD and Solaris (with 5.005_03 both) they work fine.


Ah, well, Solaris is a real OS. ;-)


Abigail
-- 
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_;
sub   _   {push         @_ => /::(.*)/s and goto &{ shift}}
sub shift {print shift; @_              and goto &{+shift}}
Hack ("Just", "Perl ", " ano", "er\n", "ther "); # 20030213


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

Date: 13 Feb 2003 10:17:11 -0700
From: Eric Schwartz <eric.schwartz@hp.com>
Subject: Re: Using Archive::Tar for in-memory tarfiles
Message-Id: <etowuk4f6co.fsf@wormtongue.emschwar>

Chris Lowth <dont@want.spam> writes:
> From the MAN page..
> 
>   write ($file, $compressed)

<snip>

>            If no arguments are given, "write" returns the entire
>            formatted archive as a string, which could be useful
>            if you\'d like to stuff the archive into a socket or a
>            pipe to gzip or something.  This functionality may be
>            deprecated later, however, as you can also do this
>            using a GLOB reference for the first argument.
> 
> This suggests that you are using a technique that may be dropped from some 
> future version of the module (which version are you using, by the way?). 
> Why not try the "GLOB" route?

Well, I can't remember how to do that without opening a file on the
disk, which I already said I'm trying not to do.  I could get fancy
and open a pipe, and fork a subprocess to write the tarfile to
its filehandle, but that's getting a bit silly.

The real problem seems to be that when you add a file with
Archive::Tar::add_files, it doesn't actually read the file's contents
until you do a _write_tar(); add_files() just sets the "data" field of
the entry to undef.  When you call write() without arguments, it calls
_format_tar_file(), which, alas, doesn't read in the file's data if
it's not already there.

I guess I could just use add_data(), which loses some information
about the file, but probably nothing I'm terribly concerned about.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Thu, 13 Feb 2003 13:21:36 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Using Archive::Tar for in-memory tarfiles
Message-Id: <3E4BE230.A53548BB@earthlink.net>

Eric Schwartz wrote:
> 
> Chris Lowth <dont@want.spam> writes:
[use a GLOB to write to a string]
> 
> Well, I can't remember how to do that without opening a file on the
> disk,

Download IO::Stringy from CPAN.

Or, if you have perl5.8.0, then you can do:

   open(my ($fh), ">", \$scalar);
   $tar->write($fh);
   print $scalar;

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: 13 Feb 2003 11:28:39 -0700
From: Eric Schwartz <eric.schwartz@hp.com>
Subject: Re: Using Archive::Tar for in-memory tarfiles
Message-Id: <etoof5gf31k.fsf@wormtongue.emschwar>

Benjamin Goldberg <goldbb2@earthlink.net> writes:
> Or, if you have perl5.8.0, then you can do:
> 
>    open(my ($fh), ">", \$scalar);
>    $tar->write($fh);
>    print $scalar;

Did you try that?  I ask only because I am running 5.8.0, and the
$tar->write() call doesn't seem to be filling my $scalar.

$ perl --version
 
This is perl, v5.8.0 built for i386-linux-thread-multi

$ cat -n testtar
     1  #!/usr/bin/perl
     2  use warnings;
     3  use strict;
     4  use Archive::Tar;
     5
     6  my $tar = Archive::Tar->new();
     7  $tar->add_files(@ARGV);
     8  my $buf;
     9  open(my ($fh), '>', \$buf) or die "couldn't open mem ref: $!";
    10  $tar->write($fh, 1);
    11  open(TAR, '>/tmp/tarfile.tar.gz') or die "couldn't open tarfile: $!";
    12  binmode(TAR);
    13  print TAR $buf;
    14  close(TAR);

$ ./testtar data
Use of uninitialized value in print at ./testtar line 13.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: 13 Feb 2003 11:42:20 -0700
From: Eric Schwartz <eric.schwartz@hp.com>
Subject: Re: Using Archive::Tar for in-memory tarfiles
Message-Id: <etok7g4f2er.fsf@wormtongue.emschwar>

Benjamin Goldberg <goldbb2@earthlink.net> writes:
> Download IO::Stringy from CPAN.

Doesn't work:

Can't locate object method "FILENO" via package "IO::Scalar" at /usr/share/perl5/Archive/Tar.pm line 747.

The line causing the error is:

    open $handle, ref ($file) ? ">&". fileno ($file) : ">" . $file
        and binmode ($handle)
            or goto &_drat;

IO::String doesn't raise an error, but the associated scalar is empty
after the call to $tar->write().

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Thu, 13 Feb 2003 16:23:32 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Using Archive::Tar for in-memory tarfiles
Message-Id: <3E4C0CD4.794FCC85@earthlink.net>

Eric Schwartz wrote:
> 
> Benjamin Goldberg <goldbb2@earthlink.net> writes:
> > Download IO::Stringy from CPAN.
> 
> Doesn't work:
> 
> Can't locate object method "FILENO" via package "IO::Scalar" at
> /usr/share/perl5/Archive/Tar.pm line 747.
> 
> The line causing the error is:
> 
>     open $handle, ref ($file) ? ">&". fileno ($file) : ">" . $file
>         and binmode ($handle)
>             or goto &_drat;
> 
> IO::String doesn't raise an error, but the associated scalar is empty
> after the call to $tar->write().

Hmm.... Ok, that does seem to pose a bit of a problem.

   local *HANDLE;
   my $scalar;
   open( HANDLE, ">", \$scalar ) or die horribly;
   $tar->write( "&" . __PACKAGE__ . "::HANDLE", 1 );
   close HANDLE;

[still untested]

You can replace the open() with:
   use IO::Scalar; # from the IO-stringy CPAN dist
   tie *HANDLE, "IO::Scalar", \$scalar;
but if you do, replace the close() with untie().

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

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 4565
***************************************


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