[22403] in Perl-Users-Digest
Perl-Users Digest, Issue: 4624 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 25 21:06:18 2003
Date: Tue, 25 Feb 2003 18:05:07 -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 Tue, 25 Feb 2003 Volume: 10 Number: 4624
Today's topics:
Re: "Schweineseiten" <goldbb2@earthlink.net>
Re: "Schweineseiten" <tassilo.parseval@post.rwth-aachen.de>
Re: "Schweineseiten" <steven.smolinski@sympatico.ca>
Re: "Schweineseiten" (Tony L. Svanstrom)
Re: Array Access Error - Help! <goldbb2@earthlink.net>
Can't set or access array element in struct (Carlton Brown)
Re: Can't set or access array element in struct (Tad McClellan)
file tests with for user inputted file <doug@dougy.mail>
Re: file tests with for user inputted file <abigail@abigail.nl>
Re: file tests with for user inputted file <s_grazzini@hotmail.com>
Re: Getting answers with perldocs (Tad McClellan)
Re: locate 1, 1 wont work properly, perhaps it's only m <tyrannous@o-space.com>
Re: locate 1, 1 wont work properly, perhaps it's only m <eric.schwartz@hp.com>
Re: locate 1, 1 wont work properly, perhaps it's only m (Jay Tilton)
Need Help: fork / kill / kill 0 <pwo@Infineon.COM>
newbie regexp question <mike@luusac.co.uk>
Re: newbie regexp question (Tad McClellan)
Re: newbie regexp question <mike@luusac.co.uk>
Re: require subs and global parameters (Tad McClellan)
Re: require subs and global parameters <s_grazzini@hotmail.com>
Re: Silencing Default Error Output of getopts (Alan Barclay)
Re: Splice problem (Tad McClellan)
Re: translate ( tr ) question (Tad McClellan)
Re: wanted: BZIP2 module for Win32 and Linux <goldbb2@earthlink.net>
Re: wanted: BZIP2 module for Win32 and Linux <goldbb2@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 25 Feb 2003 18:30:10 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: "Schweineseiten"
Message-Id: <3E5BFC82.FF533C22@earthlink.net>
Ingo Wichmann wrote:
>
> Oh, sorry!
>
> I sent this posting by mistake, its not related to perl at all.
Not to mention, if *were* ... it's in German (I think).
You sent it to comp.lang.perl.misc, when you probably should have sent
it to de.comp.lang.perl.misc.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: 25 Feb 2003 23:24:14 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: "Schweineseiten"
Message-Id: <b3gtuu$hmv$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Benjamin Goldberg:
> Ingo Wichmann wrote:
>>
>> Oh, sorry!
>>
>> I sent this posting by mistake, its not related to perl at all.
>
> Not to mention, if *were* ... it's in German (I think).
>
> You sent it to comp.lang.perl.misc, when you probably should have sent
> it to de.comp.lang.perl.misc.
Err, no. It's not even a usenet posting but rather an email to someone
about an article in a German computer magazine about something
considerably unperlish.
I guess the OP is quite happy that only few people could decipher 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: Wed, 26 Feb 2003 00:23:28 GMT
From: Steven Smolinski <steven.smolinski@sympatico.ca>
Subject: Re: "Schweineseiten"
Message-Id: <4OT6a.3743$kf7.527475@news20.bellglobal.com>
Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:
>
> I guess the OP is quite happy that only few people could decipher it.
> :-)
Anyone can decipher it, kind of. What's interesting is that Babelfish
translated the poor chap's name as "Ingo yielding man." :-)
Steve
--
Steven Smolinski => http://arbiter.ca/
GnuPG Public Key => http://arbiter.ca/steves_public_key.txt
=> or email me with 'auto-key' in the subject.
Key Fingerprint => 08C8 6481 3A7B 2A1C 7C26 A5FC 1A1B 66AB F637 495D
------------------------------
Date: Wed, 26 Feb 2003 00:52:54 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: "Schweineseiten"
Message-Id: <1fqyt2x.1yzq18vx4nwqmN%tony@svanstrom.com>
Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:
> Also sprach Benjamin Goldberg:
>
> > Ingo Wichmann wrote:
> >>
> >> Oh, sorry!
> >>
> >> I sent this posting by mistake, its not related to perl at all.
> >
> > Not to mention, if *were* ... it's in German (I think).
> >
> > You sent it to comp.lang.perl.misc, when you probably should have sent
> > it to de.comp.lang.perl.misc.
>
> Err, no. It's not even a usenet posting but rather an email to someone
> about an article in a German computer magazine about something
> considerably unperlish.
>
> I guess the OP is quite happy that only few people could decipher it.
If you understand enough german to understand the Subject you can't
help but have the posting translated by google... =D
--
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #
perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'
------------------------------
Date: Tue, 25 Feb 2003 18:24:25 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Array Access Error - Help!
Message-Id: <3E5BFB29.EEE2BDDD@earthlink.net>
Colin Thomas wrote:
[snip]
> $first = (($i/$num_rows)-(($i % $num_rows)/$num_rows));
Try changing that to:
$first = ( $i - ($i % $num_rows) ) / $num_rows;
Or:
use integer;
$first = $i / $num_rows;
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: 25 Feb 2003 16:26:45 -0800
From: carltonbrown@hotmail.com (Carlton Brown)
Subject: Can't set or access array element in struct
Message-Id: <aa611a32.0302251626.6beabb85@posting.google.com>
I'm trying to prove to myself that Class::Struct works by creating the
simplest possible working program using sample code directly from Page
336 of the Camel book.
I have researched several hours and it makes no sense why this example
from the Camel book doesn't work. I assume they would not publish
broken code so I must be misunderstanding something, but I just don't
see it. Any insights would be most appreciated.
The output of the script is:
Gandalf is of the race Istar.
Can't locate object method "aliases" via package "mage" (perhaps you
forgot to load "mage"?) at ./person.pl line 8.
Perl version is: v5.6.1 built for sun4-solaris
Here is the module: (saved as Person.pm)
package Person;
use Class::Struct;
struct Person => {
name => '$',
race => '$',
aliases => '@',
};
1;
Here is the script: (saved as person.pl)
#!/usr/bin/perl
use Person;
my $mage = Person->new;
$mage->name("Gandalf");
$mage->race("Istar");
$mage->aliases( ["Mithrandir","Olorin","Incanus"] );
printf "%s is of the race of %s.\n", $mage->name, $mage->race;
print "His aliases are: ", join(", ", @{mage->aliases}), ".\n";
Please post reply to newsgroups. I could not find anything on this
specific topic and it might be helpful to somebody else later.
------------------------------
Date: Tue, 25 Feb 2003 19:02:34 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Can't set or access array element in struct
Message-Id: <slrnb5o4ha.2tt.tadmc@magna.augustmail.com>
Carlton Brown <carltonbrown@hotmail.com> wrote:
> I'm trying to prove to myself that Class::Struct works by creating the
> simplest possible working program using sample code directly from Page
> 336 of the Camel book.
> The output of the script is:
> Gandalf is of the race Istar.
> Can't locate object method "aliases" via package "mage" (perhaps you
> forgot to load "mage"?) at ./person.pl line 8.
> use Person;
> my $mage = Person->new;
> print "His aliases are: ", join(", ", @{mage->aliases}), ".\n";
^^
^^
Where is the dollar sign for the $mage variable?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 25 Feb 2003 15:37:21 -0800
From: Doug <doug@dougy.mail>
Subject: file tests with for user inputted file
Message-Id: <3E5BFE31.6050504@dougy.mail>
Just a quick question, why doesn't the following work?
print STDOUT "Enter file name to look for: \n";
my $fileName = <STDIN>;
print STDOUT "Looking for filename: $fileName \n";
if(-e chomp()){
print "File $fileName exists \n";
}
else{
print "File $fileName doesn't exist \n";
}
It works if I assign directly in the code to the $fileName variable!
But why?
------------------------------
Date: 26 Feb 2003 00:22:28 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: file tests with for user inputted file
Message-Id: <slrnb5o264.bnn.abigail@alexandra.abigail.nl>
Doug (doug@dougy.mail) wrote on MMMCDLXV September MCMXCIII in
<URL:news:3E5BFE31.6050504@dougy.mail>:
"" Just a quick question, why doesn't the following work?
""
"" print STDOUT "Enter file name to look for: \n";
"" my $fileName = <STDIN>;
"" print STDOUT "Looking for filename: $fileName \n";
""
"" if(-e chomp()){
"" print "File $fileName exists \n";
"" }
"" else{
"" print "File $fileName doesn't exist \n";
"" }
""
"" It works if I assign directly in the code to the $fileName variable!
Well, you don't explain what you mean by "it doesn't work".
Perhaps it doesn't work because you forgot the tell the sheep
were to find the purple crows.
What are you trying to do? What did you get, and what did you
expect to get?
As for the code, the 'if (-e chomp ())' looks very odd to me.
But then, I've no idea what you are trying to do, Perhaps
this is what you intend to do.
Abigail
--
perl -Mstrict -we '$_ = "goto _.print chop;\n=rekcaH lreP rehtona tsuJ";_1:eval'
------------------------------
Date: Wed, 26 Feb 2003 00:21:01 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: file tests with for user inputted file
Message-Id: <NLT6a.43459$ma2.13194626@twister.nyc.rr.com>
Doug <doug@dougy.mail> writes:
> Just a quick question, why doesn't the following work?
>
> print STDOUT "Enter file name to look for: \n";
> my $fileName = <STDIN>;
> print STDOUT "Looking for filename: $fileName \n";
>
> if(-e chomp()){
$ perldoc -f chomp
Check what chomp() returns and what it chomps if
you don't pass it an argument.
--
Steve
------------------------------
Date: Tue, 25 Feb 2003 17:56:43 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Getting answers with perldocs
Message-Id: <slrnb5o0lr.2in.tadmc@magna.augustmail.com>
Dick Penny <penny1482@attbi.com> wrote:
>
>> How would I find answers to these questions....
>> I need perldoc tips that perldoc perldoc isn't helping me with.
> I've settled on google because I know of NO OTHER way to search on key
> words, at least in Windoze world.
Problems with Windows are not problems with Perl.
If Windows does not provide a useful way of searching for a
keyword in many files, then that is not a problem with Perl
nor with Perl's docs, that is a problem with Windows.
>IMHO Perldocs are next to useless.
It is not the docs that are useless, it is the facilities offered
by your choice of "operating system".
Since the tools you need are not provided, you just have
to figure out how to get the tools you need.
Writing them in Perl might be a good idea.
I grep() the *.pod files directly on my useful OS, you could do
something similar on Redmondware:
perl -ne "print if /remove/ and /space/" *.pod
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 25 Feb 2003 23:16:32 -0000
From: <tyrannous@o-space.com>
Subject: Re: locate 1, 1 wont work properly, perhaps it's only meant for linux
Message-Id: <b3gtgj$ff1$1@news8.svr.pol.co.uk>
You must excuse me gentlemen, I am new the Internet and "top posted" by
mistake. I will try to stop it from happening again.
As for the locate problem.
use Term::ANSIScreen qw/:color :cursor :screen :keyboard/;
locate 1, 1;
This short script, results in the following output (not necessarily an error
output).
<[1;1H
------------------------------
Date: 25 Feb 2003 16:48:19 -0700
From: Eric Schwartz <eric.schwartz@hp.com>
Subject: Re: locate 1, 1 wont work properly, perhaps it's only meant for linux
Message-Id: <eton0kj3osc.fsf@wormtongue.emschwar>
<tyrannous@o-space.com> writes:
> use Term::ANSIScreen qw/:color :cursor :screen :keyboard/;
>
> locate 1, 1;
>
>
> This short script, results in the following output (not necessarily an error
> output).
>
>
> <[1;1H
Which is the ANSI escape sequence to move the cursor to location 1,1.
You must be running this script in a non-ANSI terminal. That's
unfortunate, but you can't really blame the module for doing what it's
supposed to. :)
(BTW, it works for me.)
-=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: Tue, 25 Feb 2003 23:58:27 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: locate 1, 1 wont work properly, perhaps it's only meant for linux
Message-Id: <3e5c0078.57517113@news.erols.com>
<tyrannous@o-space.com> wrote:
: You must excuse me gentlemen, I am new the Internet and "top posted" by
: mistake. I will try to stop it from happening again.
Very much appreciated.
: As for the locate problem.
:
: use Term::ANSIScreen qw/:color :cursor :screen :keyboard/;
: locate 1, 1;
:
: This short script, results in the following output (not necessarily an error
: output).
:
: <[1;1H
That is excellent information.
Your program is functioning exactly as it's supposed to, but your
output device (terminal, DOS prompt, whatever) is not recognizing ANSI
escape sequences.
IOW, it's not a Perl problem, but an OS one.
Ask in a newsgroup related to your OS (Windows ME, as I recall) how to
enable ANSI terminal emulation on the console. It may be as easy as
adding "device=ANSI.SYS" to the config.sys file, but I have no idea if
that applies to WinME.
------------------------------
Date: Tue, 25 Feb 2003 17:06:33 -0800
From: "Peter W. Osel" <pwo@Infineon.COM>
Subject: Need Help: fork / kill / kill 0
Message-Id: <b3h3uq$jgq$1@newssrv.hl.siemens.de>
I have a script which starts a child (via open("$commad |)"); Then I try
to kill the child with signal TERM, if this did not kill the child, I
want to kill the child using INT, etc. The following code does not seem
to work (what am I missing?). It looks as if kill 0 $pid does not
detect that the child was killed?
The main script:
---
#!/opt/perl_5.6.1/bin/perl -w
#
$child = "./_test-kill-child.pl";
unless ($pid = open(CHILD, "$child |")) {
print STDERR "${0}: FATAL: Can't open $child : $!";
exit(1);
}
sleep 2;
for my $sig (qw(TERM INT HUP KILL)) {
print STDERR "${0}: DBG: kill child $pid (via $sig) ...\n";
kill($sig, $pid);
sleep 2;
#last unless kill(0, $pid);
if (kill(0, $pid)) {
print STDERR "${0}: DBG: child $pid survived $sig ...\n";
}
}
---
The child script
---
#!/opt/perl_5.6.1/bin/perl
$SIG{CHLD} = 'IGNORE';
$SIG{TERM} = 'IGNORE';
#$SIG{INT} = 'IGNORE';
$SIG{HUP} = 'IGNORE';
$SIG{KILL} = 'IGNORE';
while (1) {
print "hello\n";
sleep 1;
}
---
------------------------------
Date: Wed, 26 Feb 2003 00:11:50 -0000
From: "Mike" <mike@luusac.co.uk>
Subject: newbie regexp question
Message-Id: <GCT6a.4744$EN3.37896@newsfep4-glfd.server.ntli.net>
Hi,
can someone tell me how to combine regexps (perl 5.6), ie
$var =~ s/<\/nwl>/\n/g;
$var =~ s/<lwr>(.*?)<\/lwr>/\U$1/gs;
$var =~ s/<.*?>//g;
can these be combined into one regexp line ? If so how, can someone point
me at an eacy source for beginners ?
thanks
Mike
------------------------------
Date: Tue, 25 Feb 2003 18:55:45 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie regexp question
Message-Id: <slrnb5o44h.2tt.tadmc@magna.augustmail.com>
Mike <mike@luusac.co.uk> wrote:
> $var =~ s/<\/nwl>/\n/g;
> $var =~ s/<lwr>(.*?)<\/lwr>/\U$1/gs;
> $var =~ s/<.*?>//g;
^^^^^^^
^^^^^^^ that is very fragile...
perldoc -q HTML
How do I remove HTML from a string?
What will your code do with this?
<img src="cool.jpg" alt=">>Cool pic!<<">
or
<p>You are poor if income < expenses</p>
> can these be combined into one regexp line ?
Why do you want to combine them into one regex line?
What are you hoping that that would do for you?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 26 Feb 2003 01:29:25 -0000
From: "Mike" <mike@luusac.co.uk>
Subject: Re: newbie regexp question
Message-Id: <oLU6a.4797$EN3.38206@newsfep4-glfd.server.ntli.net>
Hi
> > $var =~ s/<.*?>//g;
> ^^^^^^^
> ^^^^^^^ that is very fragile...
>
> perldoc -q HTML
I will have a look
> How do I remove HTML from a string?
> What will your code do with this?
> <img src="cool.jpg" alt=">>Cool pic!<<">
> <p>You are poor if income < expenses</p>
I see your point .....
> > can these be combined into one regexp line ?
> Why do you want to combine them into one regex line?
> What are you hoping that that would do for you?
curiosity, whether it could be done, reducing code etc - more an experiment
than the production of anything that anyone other than me will ever use etc.
thanks
Mike
------------------------------
Date: Tue, 25 Feb 2003 18:02:18 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: require subs and global parameters
Message-Id: <slrnb5o10a.2in.tadmc@magna.augustmail.com>
kydongau <kydongau@yahoo.com.au> wrote:
> Is it possible to require a perl file that contains sub routines
> my ($cmd);
> where lib1 and lib2.pl contains the same sub NAME but doing different
> things and having access to the global variables $cmd from the main
> script ??
Yes.
> My script failed when it tries to use $cmd.
Because it is the wrong kind of variable (lexical).
Make it the right kind of variable (package) instead:
our ($cmd);
See also:
"Coping with Scoping":
http://perl.plover.com/FAQs/Namespaces.html
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 26 Feb 2003 00:05:05 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: require subs and global parameters
Message-Id: <RwT6a.34174$Mh3.14115825@twister.nyc.rr.com>
kydongau <kydongau@yahoo.com.au> writes:
>
> Is it possible to require a perl file that contains
> sub routines as such:
>
> #main script
>
> my ($cmd);
>
> while .... {
> if bla {
> require "lib1.pl";
> } elsif blaaa {
> require "lib2.pl";
> }
> }
>
> where lib1 and lib2.pl contains the same sub NAME
> but doing different things and having access to
> the global variables $cmd from the main script ??
Yes.
But not with 'my $cmd'. That is _not_ a global.
Variables declared with 'my' are private; you
can only use them in the scope (the block, file
or eval) where they were declared.
Thread on the same issue last week.
You can declare global variables with 'our'.
You can pass $cmd as an argument.
>
> If the if block is inside a while loop, can the
> sub NAME be replaced?
>
Yes.
Named subroutines _are_ global. Lexical scopes like
the body of your while loop don't enter into it.
http://perl.plover.com/FAQs/Namespaces.html
--
Steve
------------------------------
Date: 25 Feb 2003 22:41:08 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: Silencing Default Error Output of getopts
Message-Id: <1046212868.34878@elaine.furryape.com>
In article <b3fl3o$42a$1@wisteria.csv.warwick.ac.uk>,
Spero <spero126NOSPAM@yahoo.com> wrote:
>Hi,
>
>I've googled and googled, read man pages and web pages and can't find the
>answer to this.
>
>How do I silence the default output of getopts?
Set a WARN handler:
#!/usr/bin/perl
$SIG{'__WARN__'} = sub {
print "My error\n";
};
use Getopt::Std;
getopts('hf:');
------------------------------
Date: Tue, 25 Feb 2003 17:59:55 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Splice problem
Message-Id: <slrnb5o0rr.2in.tadmc@magna.augustmail.com>
David K. Wall <usenet@dwall.fastmail.fm> wrote:
> It's also interesting that using a lexical variable in
> the foreach loop speeds it up.
It makes sense to me that lexicals are faster than package variables.
The scratch pad is likely to be a lot smaller than the
"main" symbol table for one.
Lexicals are not only safer, they are faster too!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 25 Feb 2003 17:45:26 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: translate ( tr ) question
Message-Id: <slrnb5o00m.2in.tadmc@magna.augustmail.com>
Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> On Mon, 24 Feb 2003 23:48:10 -0600,
> Tad McClellan <tadmc@augustmail.com> wrote:
>> Taber <taber@gonetstat.com> wrote:
>>> I need to know how to translate letters higher than
>>> J to a number i.e. a=1..z=27
>>
>>
>> s/([j-z])/ ord($1) - ord('a') + 1/ge;
>
> Just an additional note; This only works for ASCII and derived
> character sets. Admittedly that's most of the machine out there, but
> it isn't a completely general solution.
But Taber's char set is not ASCII anyway, given the character
range he's shown. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 25 Feb 2003 18:46:22 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: wanted: BZIP2 module for Win32 and Linux
Message-Id: <3E5C004E.5D3AB916@earthlink.net>
Joe Smith wrote:
>
> In article <bYJ4a.1260487$TJ.177153@post-02.news.easynews.com>,
> Edward Wildgoose <Ed+nospam@ewildgoose.demon.co.uk@> wrote:
> >Apologies if this is the wrong place. I have a need for a BZIP2
> >module in the style of the current zlib library
> >
> >Anyway, this would be contributed back to CPAN for all to use, but
> >...
>
> What is wrong with the Bzip2 modules already on CPAN?
>
> http://search.cpan.org/search?query=bzip2&mode=module
>
> >particularly have a need for the stream compression functions with
> >"partial flush", etc, ie so I can use it for compressing a real time
> data stream.
>
> Like IO::Filter::bzip2, perhaps?
That module inherits from IO::Filter::External ... this means that it
starts an external process to perform the (de)compression.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Tue, 25 Feb 2003 19:34:40 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: wanted: BZIP2 module for Win32 and Linux
Message-Id: <3E5C0BA0.41F796C8@earthlink.net>
Edward Wildgoose wrote:
>
> Apologies if this is the wrong place. I have a need for a BZIP2
> module in the style of the current zlib library - in fact since the
> interface is so similar I wonder if it wouldn't be possible to broadly
> lift the zlib code and slot in bzip..?
I am afraid that there doesn't yet exist such a thing as you want.
If you're writing such a module, though, I have some advice:
The bz_stream structure allows you to assign your own memory allocator
and freeing functions, and to keep an opaque data structure in the
struct (which will be passed to the allocator/freeer).
This is useful, since depending on perl's configuration, perl may define
it's own memory management functions, and, what's more, there may be a
seperate memory arena for each interpreter/thread.
So, you might want to do:
memzero( mystream, sizeof(struct bz_stream) );
#if defined(MULTIPLICITY)
mystream->opaque = aTHX;
mystream->bzalloc = Perl_calloc;
mystream->bzfree = Perl_mfree;
#endif
Before doing BZ2_bzCompressInit.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
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 4624
***************************************