[22232] in Perl-Users-Digest
Perl-Users Digest, Issue: 4453 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 23 11:06:16 2003
Date: Thu, 23 Jan 2003 08:05:10 -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, 23 Jan 2003 Volume: 10 Number: 4453
Today's topics:
[ANNOUNCE] OpenECG programming contest (Philip Lees)
Attempting to run a simple Win Perl script without the (Don)
Re: Attempting to run a simple Win Perl script without <jurgenex@hotmail.com>
Re: Can I store an array into a DataBase? <GPatnude@adelphia.net>
Re: Converting a string to a valid date.. <no_spam@fromyou.thanks-anyways.com>
Re: Cross-dependency of packages <richard@zync.co.uk>
Re: function overriding (Anno Siegel)
Re: function overriding <perl-dvd@darklaser.com>
Re: function overriding <perl-dvd@darklaser.com>
hash of arrays using variable array names (qanda)
hash of hashes of arrays <news@tvreclames.nl>
Max Value of Variable? <jan.raether@zmnh.uni-hamburg.de>
Re: Max Value of Variable? <GPatnude@adelphia.net>
Passing a glob reference doesn't work with 'strict' <mzawadzk@man.poznan.pl>
Re: Passing a glob reference doesn't work with 'strict' <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: Passing a glob reference doesn't work with 'strict' <mzawadzk@man.poznan.pl>
Re: Passing a glob reference doesn't work with 'strict' <nobull@mail.com>
Re: Passing a glob reference doesn't work with 'strict' <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: Passing a glob reference doesn't work with 'strict' (Anno Siegel)
Re: Passing a glob reference doesn't work with 'strict' <mzawadzk@man.poznan.pl>
Re: Passing a glob reference doesn't work with 'strict' (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 23 Jan 2003 11:25:03 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: [ANNOUNCE] OpenECG programming contest
Message-Id: <3e2fd10d.75859140@news.grnet.gr>
The OpenECG programming contest is now open to submissions. Prizes
total 10,000 Euros.
For more information, visit the OpenECG portal:
http://www.openecg.net
and click on Programming Contest. Questions may be addressed to
contest@openecg.net.
Please feel free to forward this message to other relevant forums.
--
--
OpenECG Programming contest
http://www.openecg.net
e-mail: contest@openecg.net
------------------------------
Date: 23 Jan 2003 07:25:32 -0800
From: dgnaismith@yahoo.com (Don)
Subject: Attempting to run a simple Win Perl script without the use of a window.
Message-Id: <e0f580c3.0301230725.1594645b@posting.google.com>
I've written a script to check for a few files and import a registry
entry if needed. Is it possible to run the script in a silent mode
where by the user does not see a window pop up? Essentially, we're
attempting to run the script behind the scenes silently.
Should I be using another dev language to accomplish this? I'm hoping
it can be done in perl.
------------------------------
Date: Thu, 23 Jan 2003 15:38:41 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Attempting to run a simple Win Perl script without the use of a window.
Message-Id: <50UX9.647$3J.253@nwrddc01.gnilink.net>
Don wrote:
> I've written a script to check for a few files and import a registry
> entry if needed. Is it possible to run the script in a silent mode
> where by the user does not see a window pop up? Essentially, we're
> attempting to run the script behind the scenes silently.
>
> Should I be using another dev language to accomplish this? I'm hoping
> it can be done in perl.
What did a google search turn up? This question should really be added to
the FAQ because it's asked about every week.
Just use wperl.exe instead of perl.exe (assuming you are running ActiveState
Perl on Windows which you neglected to tell us but as you mentioned
"registry".....)
jue
------------------------------
Date: Thu, 23 Jan 2003 15:06:34 GMT
From: "codeWarrior" <GPatnude@adelphia.net>
Subject: Re: Can I store an array into a DataBase?
Message-Id: <_xTX9.605$ni5.357218@news1.news.adelphia.net>
"Francesco Moi" <francescomoi@europe.com> wrote in message
news:5b829932.0301221420.2d28a58c@posting.google.com...
> Hello.
>
> I'm working with Perl and MySQL, and I would like to store an
> array (@my_array) into a DataBase, so that I can handle it.
>
> Is it possible?
>
> Thank you very much.
RTFM for mySQL -- Section 6.2.3.4....
You are looking to create a table with a field type of "SET" -- The mySQL
SET datatype will store arrays....
6.2.3.4 The SET Type
A SET is a string object that can have zero or more values, each of which
must be chosen from a list of allowed values specified when the table is
created. SET column values that consist of multiple set members are
specified with members separated by commas (`,'). A consequence of this is
that SET member values cannot themselves contain commas.
For example, a column specified as SET("one", "two") NOT NULL can have any
of these values:
""
"one"
"two"
"one,two"
A SET can have a maximum of 64 different members.
MySQL stores SET values numerically, with the low-order bit of the stored
value corresponding to the first set member. If you retrieve a SET value in
a numeric context, the value retrieved has bits set corresponding to the set
members that make up the column value. For example, you can retrieve numeric
values from a SET column like this:
mysql> SELECT set_col+0 FROM tbl_name;
If a number is stored into a SET column, the bits that are set in the binary
representation of the number determine the set members in the column value.
Suppose a column is specified as SET("a","b","c","d"). Then the members have
the following bit values:
SET member Decimal value Binary value
a 1 0001
b 2 0010
c 4 0100
d 8 1000
If you assign a value of 9 to this column, that is 1001 in binary, so the
first and fourth SET value members "a" and "d" are selected and the
resulting value is "a,d".
For a value containing more than one SET element, it does not matter what
order the elements are listed in when you insert the value. It also does not
matter how many times a given element is listed in the value. When the value
is retrieved later, each element in the value will appear once, with
elements listed according to the order in which they were specified at table
creation time. For example, if a column is specified as
SET("a","b","c","d"), then "a,d", "d,a", and "d,a,a,d,d" will all appear as
"a,d" when retrieved.
------------------------------
Date: Thu, 23 Jan 2003 15:38:17 GMT
From: "Bullet" <no_spam@fromyou.thanks-anyways.com>
Subject: Re: Converting a string to a valid date..
Message-Id: <J%TX9.11747$nb1.3101739152@newssvr10.news.prodigy.com>
> my %shortmonths;
> @shortmonths{ qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)} =
> 1 .. 12;
>
> Anno
Often I see code such as the chunk above.. and cant figure it out without
pulling out
the PERL book and working through it.. is it just me or in a lot of cases
wouldnt it just
be easier for anyone who has to maintain the code to leave it a bit more
simple?
For instance in the above snip.. Because I know what the orginal code did..
I know what
its supposed to do.. other than that I would be lost if I were to see that
in someone elses
code. .
Why does the Hash get declared as an array? and why in an Array context is
the array defined
using {} curlys instead of parentheses.. is that some kind of black magic? I
learned a long time
ago to stop dismissing things as typos.. whats actually goin on? Does this
example really mean
that PERL really treats all arrays as hashes with numeric keys? Hmmm.. ?
Also.. in the earlier submission.. was this snippet..
which I pretty much understand.. except for the last part..
whats the @de[2,0] about? Why wouldnt that simply be $de[0]
sub d_convert {
my @de = split /,?\s+/, $_[ 0 ];
return sprintf '%04d-%02d-%02d %s', $de[3], $shortmonths{$de[1]},
@de[2,0];
}
----------------------------------------------------------------------------
------------
Additionally .. I wanted to know if there was a valid argument for modifying
my original
code - as shown below in d_convert .. to be like the submitted version
d_convert2
This isnt exactly a perfect test .. but.. I ran this on a linux box which
doesnt have any
other users - so I know the load is pretty much steady on the box.. and its
negligble. .
Uptime shows -
3:24pm up 4 days, 9:47, 1 user, load average: 0.00, 0.00, 0.00
So I am pretty sure the results can be trusted..
but I got some surprising results. . my original code - is longer.. but
heres what I found..
Testing d_convert:
Started-1043352458
Finished-1043352464
Testing d_convert2:
Started-1043352464
Finished-1043352476
As you can see.. in 100,000 iterations.. my version took about 6 seconds ..
while
the other version (where the code is actually shorter) took 12 seconds.. or
approx
twice as long..
So is it just me - or wouldnt it just be easier to keep it simple - so the
code is more
easily understood by other developers and or people who also write code in
other
languages - rather than using more complex structures which detract from the
readablity / maintainability of the code?
Code Follows..
---------------------
my %shortmonths =
("Jan"=>'01',"Feb"=>'02',"Mar"=>'03',"Apr"=>'04',"May"=>'05',"Jun"=>'06',
"Jul"=>'07',"Aug"=>'08',"Sep"=>'09',"Oct"=>'10',"Nov"=>'11',"Dec"=>'12');
sub d_convert{
$conv_date = $_[0];
$conv_date =~ s/,//;
@de = split(/\s/,$conv_date);
if (length($de[2]) == 1) {
$de[2] = '0'.$de[2];
}
return "$de[3]:$shortmonths{$de[1]}:$de[2] $de[0]"
}
sub d_convert2 {
my @de = split /,?\s+/, $_[ 0 ];
return sprintf '%04d-%02d-%02d %s', $de[3], $shortmonths{$de[1]},
@de[2,0];
}
$date_in = "17:42:50 Jan 30, 2003 PST";
print "Testing d_convert:\n Started-";
print time;
print "\n";
foreach(1 .. 100000){
&d_convert($date_in);
}
print " Finished-";
print time;
print "\n";
print "Testing d_convert2:\n Started-";
print time;
print "\n";
foreach(1 .. 100000){
&d_convert2($date_in);
}
print " Finished-";
print time;
print "\n";
------------------------------
Date: Thu, 23 Jan 2003 12:57:58 +0000
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: Cross-dependency of packages
Message-Id: <20030123.125758.705178736.1732@richg.zync>
In article <b0mt7s$6hu$1@wisteria.csv.warwick.ac.uk>, "Ben Morrow"
<mauzo@mimosa.csv.warwick.ac.uk> wrote:
> "Richard Gration" <richard@zync.co.uk> wrote:
<SNIP>
>>I have read in the docs that Perl will only include a given file /
>>package once ... ?
> It will, however if you pass it Lib.pm as the file to execute that
> doesn't count, so it will load it once more.
> A better test for syntax of a module is something like perl -MLib -e42
> which loads the module and then does nothing. This should give no
> errors. Ben
I tried that, but it gives the same Subroutine redefined errors
unfortunately. I've seen the same thing happen with HTML::Mason, but that
could have been my dodgy code too.
Thanks for the input
R
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: 23 Jan 2003 11:07:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: function overriding
Message-Id: <b0oidl$9vo$3@mamenchi.zrz.TU-Berlin.DE>
David <perl-dvd@darklaser.com> wrote in comp.lang.perl.misc:
> I've got a nice test of this groups skills.
No, thanks. Trying to present a mundane question as a "challenge"
is not going to win you points.
Anno
------------------------------
Date: Thu, 23 Jan 2003 15:38:07 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: function overriding
Message-Id: <z%TX9.70$EZ2.31508@news-west.eli.net>
"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:b0oidl$9vo$3@mamenchi.zrz.TU-Berlin.DE...
> David <perl-dvd@darklaser.com> wrote in comp.lang.perl.misc:
>
> > I've got a nice test of this groups skills.
>
> No, thanks. Trying to present a mundane question as a "challenge"
> is not going to win you points.
If you can't say something helpful, please refrain from posting.
Jerk ... *plonk*.
------------------------------
Date: Thu, 23 Jan 2003 16:04:21 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: function overriding
Message-Id: <9oUX9.71$EZ2.31278@news-west.eli.net>
"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
message news:b0n5na$1bg$1@nets3.rz.RWTH-Aachen.DE...
> Also sprach David:
>
> > So, does anyone know of a CORE function I can override to
accomplish
> > this, or some other method? Perhaps a different approach with
> > Tie:Handle? Or even a signal to intercept? Any other ideas?
>
> There are indeed two special signals that Perl provides and for which
> you can install handlers:
>
> BEGIN {
> $SIG{ __WARN__ } = sub {
> my $msg = shift;
> ...
> };
>
> $SIG{ __DIE__ } = sub {
> my $msg = shift;
> ...
> };
> }
>
> By putting them into a BEGIN block on top of your script this should
> even catch compilation errors. This also works if you trigger one of
the
> two signals above yourself:
>
> open FILE, "file" or die $!;
>
> will also call the above handler. Same for warn().
>
Worked Perfectly, thanks a Ton.
David
------------------------------
Date: 23 Jan 2003 07:50:35 -0800
From: fumail@freeuk.com (qanda)
Subject: hash of arrays using variable array names
Message-Id: <62b4710f.0301230750.5573a7ab@posting.google.com>
Hi all, the following script appears to work (but only if I turn off
strict). I'm still learning, so can anyone tell me if anything is
particularly bad about this, could it be done more elegantly? The
objective is to pass a string into a function that can then be used to
load an array with certain records.
#!/usr/bin/perl
use warnings;
#use strict;
my $atype = "aa";
my $btype = "bb";
my %hoa= (
$atype,
$btype,
);
sub func1 {
while( <DATA> ) {
chomp;
my @flds = split( /,/, $_, -1 );
if( $flds[0] eq $atype ) {
$hoa{$atype}[ $#{ $hoa{$atype} }+1 ] = $_;
# print STDOUT "ass_a: $#{ $hoa{$atype} }:$hoa{$atype}[ $#{
$hoa{$atype} } ]\n";
}
elsif( $flds[0] eq $btype ) {
$hoa{$btype}[ $#{ $hoa{$btype} }+1 ] = $_;
# print STDOUT "ass_b: $#{ $hoa{$btype} }:$hoa{$btype}[ $#{
$hoa{$btype} } ]\n";
}
}
print STDOUT "aa_array: $hoa{$atype}[0]\n";
print STDOUT "aa_array: $hoa{$atype}[1]\n";
print STDOUT "bb_array: $hoa{$btype}[0]\n";
print STDOUT "bb_array: $hoa{$btype}[1]\n";
}
sub func2 {
my $type = shift @_;
print STDOUT "printing (arg)$type ...\n";
for my $i( 0 .. $#{ $hoa{$type} } ) {
print STDOUT " $hoa{$type}[$i]\n";
}
}
func1();
func2($atype);
func2($btype);
__DATA__
aa,f2,f3,f4,line1
bb,f2,f3,f4,line2
cc,f2,f3,f4,line3
dd,f2,f3,f4,line4
aa,f2,f3,f4,line5
bb,f2,f3,f4,line6
------------------------------
Date: Thu, 23 Jan 2003 15:58:23 +0100
From: "Bart van den Burg" <news@tvreclames.nl>
Subject: hash of hashes of arrays
Message-Id: <1043333904.130272@news.knoware.nl>
hi
I'm trying to create a hash of hashes of arrays, but I'm getting really
confused here
I'm creating it like this:
my %channels = ("#channel1" => {"ops" => [], "voice" => [], "normal" => []},
"#channel2" => {"ops" => [], "voice" => [], "normal" => []});
at first, I want to add some "ops" to the list, so I do:
unshift($channels}{"#channel1"}{"ops"}, "nickname");
in return, I get the error:
Type of arg 1 to unshift must be array (not hash element) at ./rb.pl line
114, near ""nickname")"
Then I tried to create arrays first, then throw them in the hash:
my (@ops);
unshift(@ops, "nickname");
$channels{$channel}{"ops"} = @ops;
print $channels{$channel}{"ops"}[0]."\n";
which gave me:
Can't use string ("1") as an ARRAY ref while "strict refs" in use at ./rb.pl
line 117.
Could anyone tell me how to do this correctly?
Thanks in advance
Bart
------------------------------
Date: Thu, 23 Jan 2003 14:30:35 +0100
From: =?iso-8859-1?q?Jan_R=E4ther?= <jan.raether@zmnh.uni-hamburg.de>
Subject: Max Value of Variable?
Message-Id: <pan.2003.01.23.14.30.33.985820.28869@zmnh.uni-hamburg.de>
Hi there,
I'm having a real weird problem here somebody of you might could help me
with. I'm using a perl script to poll SNMP data from severall Cisco
Switches. The Data is either polled from a 32 bit counter with the max
value of: 4294967296 or from a 64 Bit counter with the max value of:
1.84467e+19
The polled data is then stored into a MySQL database. When i poll the 32
Bit counter, the script runs just fine, without any error message. But
when i poll the 64 Bit Counter i get an error message like this:
Use of uninitialized value in concatenation (.) or string at
update.pl line 221.
Use of uninitialized value in concatenation (.) or string at
update.pl line 221.
DBD::mysql::st execute failed: You have an error in your SQL
syntax near ' , 0, 0, 200302314)' at line 1 at update.pl line 225.
Undefined subroutine &main::errstr called at update.pl line 225.
In line 221 the MySQL Query to insert the data into the db is prepared,
in line 225 it's executed.
The "funny" thing is that i have another script in which exactly the same
code segment runs just fine, without the above error message.
My first thought was that perl could not work with the large value the
counter can get. But if i assign a value greater than the max value of
the 64 Bit Counter to a normal variable "by hand" perl would work with it
just flawlessly.
Any ideas? Someone?
TIA, Jan
P.S. i can post the code segment if it's necessary, but it's rather large
--
Jan Räther
Universität Hamburg
Zentrum für Molekulare Neurobiologie
Service-Gruppe EDV
Falkenried 94
20251 Hamburg
Germany
Tel.: 040 - 428 - 03 - 6619
Fax.: 040 - 428 - 03 - 6621
- "There's a door"
- "Where does it go?"
- "It stays where it is, I think."
-- (Terry Pratchett, Eric)
------------------------------
Date: Thu, 23 Jan 2003 15:00:11 GMT
From: "codeWarrior" <GPatnude@adelphia.net>
Subject: Re: Max Value of Variable?
Message-Id: <%rTX9.603$ni5.355170@news1.news.adelphia.net>
"Jan Räther" <jan.raether@zmnh.uni-hamburg.de> wrote in message
news:pan.2003.01.23.14.30.33.985820.28869@zmnh.uni-hamburg.de...
> Hi there,
>
> I'm having a real weird problem here somebody of you might could help me
> with. I'm using a perl script to poll SNMP data from severall Cisco
> Switches. The Data is either polled from a 32 bit counter with the max
> value of: 4294967296 or from a 64 Bit counter with the max value of:
> 1.84467e+19
> The polled data is then stored into a MySQL database. When i poll the 32
> Bit counter, the script runs just fine, without any error message. But
> when i poll the 64 Bit Counter i get an error message like this:
>
> Use of uninitialized value in concatenation (.) or string at
> update.pl line 221.
> Use of uninitialized value in concatenation (.) or string at
> update.pl line 221.
> DBD::mysql::st execute failed: You have an error in your SQL
> syntax near ' , 0, 0, 200302314)' at line 1 at update.pl line 225.
> Undefined subroutine &main::errstr called at update.pl line 225.
>
> In line 221 the MySQL Query to insert the data into the db is prepared,
> in line 225 it's executed.
>
> The "funny" thing is that i have another script in which exactly the same
> code segment runs just fine, without the above error message.
>
> My first thought was that perl could not work with the large value the
> counter can get. But if i assign a value greater than the max value of
> the 64 Bit Counter to a normal variable "by hand" perl would work with it
> just flawlessly.
>
> Any ideas? Someone?
>
> TIA, Jan
>
> P.S. i can post the code segment if it's necessary, but it's rather large
>
>
> --
> Jan Räther
> Universität Hamburg
> Zentrum für Molekulare Neurobiologie
> Service-Gruppe EDV
> Falkenried 94
> 20251 Hamburg
> Germany
> Tel.: 040 - 428 - 03 - 6619
> Fax.: 040 - 428 - 03 - 6621
>
> - "There's a door"
> - "Where does it go?"
> - "It stays where it is, I think."
>
> -- (Terry Pratchett, Eric)
It's mySQL -- What is the data type definition for the field you want to
store the number in ?? If it's simply type integer -- it can store a number
up to 2,147, 483,647....
INT[(M)] [UNSIGNED] [ZEROFILL]
A normal-size integer. The signed range is -2147483648 to 2147483647. The
unsigned range is 0 to 4294967295.
INTEGER[(M)] [UNSIGNED] [ZEROFILL]
This is a synonym for INT.
BIGINT[(M)] [UNSIGNED] [ZEROFILL]
A large integer. The signed range is -9223372036854775808 to
9223372036854775807. The unsigned range is 0 to 18446744073709551615. Some
things you should be aware about BIGINT columns:
As all arithmetic is done using signed BIGINT or DOUBLE values, so you
shouldn't use unsigned big integers larger than 9223372036854775807 (63
bits) except with bit functions! If you do that, some of the last digits in
the result may be wrong because of rounding errors when converting the
BIGINT to a DOUBLE. You can always store an exact integer value in a BIGINT
column by storing it as a string, as there is in this case there will be no
intermediate double representation. `-', `+', and `*' will use BIGINT
arithmetic when both arguments are INTEGER values! This means that if you
multiply two big integers (or results from functions that return integers)
you may get unexpected results when the result is larger than
9223372036854775807.
------------------------------
Date: Thu, 23 Jan 2003 13:46:54 +0100
From: Marek Zawadzki <mzawadzk@man.poznan.pl>
Subject: Passing a glob reference doesn't work with 'strict'
Message-Id: <Pine.GSO.4.44.0301231340590.23891-100000@rose.man.poznan.pl>
Hello,
When using subroutine "Archive::Tar->create_archive", I'm trying to pass
*STDOUT to it so I can write my tar files to the stdout, not to disk.
However, the effect is I get a file called "\*main\:\:STDOUT" (with the
content I expect to be written to the standard output).
I suspect it has something to do with the fact I'm using 'strict'.
Anybody can help?
-marek
------------------------------
Date: Thu, 23 Jan 2003 14:03:02 +0100
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Passing a glob reference doesn't work with 'strict'
Message-Id: <vrpv2vckdc6feq6pe07meup0la1ijr78me@4ax.com>
On Thu, 23 Jan 2003 13:46:54 +0100, Marek Zawadzki
<mzawadzk@man.poznan.pl> wrote:
>Hello,
>
>When using subroutine "Archive::Tar->create_archive", I'm trying to pass
>*STDOUT to it so I can write my tar files to the stdout, not to disk.
>However, the effect is I get a file called "\*main\:\:STDOUT" (with the
>content I expect to be written to the standard output).
>I suspect it has something to do with the fact I'm using 'strict'.
I don't know what exactly is wrong since you haven't shown us how
you're calling create_archive(), but I can tell you that the problem
is certainly *not* with 'use strict'.
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Thu, 23 Jan 2003 14:16:24 +0100
From: Marek Zawadzki <mzawadzk@man.poznan.pl>
Subject: Re: Passing a glob reference doesn't work with 'strict'
Message-Id: <Pine.GSO.4.44.0301231412410.23891-100000@rose.man.poznan.pl>
On Thu, 23 Jan 2003, Bernard El-Hagin wrote:
> Marek Zawadzki <mzawadzk@man.poznan.pl> wrote:
> >When using subroutine "Archive::Tar->create_archive", I'm trying to pass
> >*STDOUT to it so I can write my tar files to the stdout, not to disk.
>
> I don't know what exactly is wrong since you haven't shown us how
> you're calling create_archive(), but I can tell you that the problem
> is certainly *not* with 'use strict'.
I call it like this:
Archive::Tar->create_archive (*STDOUT, $compress, @f);
This results in "\*main\:\:STDOUT" file instad of archive being printed to
the standard output.
The Archive::Tar manual says:
"The first argument can either be the name of the tar file to
create or a reference to an open file handle (e.g. a GLOB
reference)."
What do I do wrong?
-marek
------------------------------
Date: 23 Jan 2003 13:17:32 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Passing a glob reference doesn't work with 'strict'
Message-Id: <u98yxc3t03.fsf@wcl-l.bham.ac.uk>
Marek Zawadzki <mzawadzk@man.poznan.pl> writes:
> When using subroutine "Archive::Tar->create_archive", I'm trying to pass
> *STDOUT to it so I can write my tar files to the stdout, not to disk.
> However, the effect is I get a file called "\*main\:\:STDOUT" (with the
> content I expect to be written to the standard output).
> I suspect it has something to do with the fact I'm using 'strict'.
>
> Anybody can help?
perldoc Archive::Tar
Note what arguments it accepts. It doesn't take a bare-GLOB (well
technically a "fake GLOB"). It takes a GLOB reference like \*STDOUT.
Note "fake GLOBs" are hideous evil things that were used in Perl4 to
get arround the lack of references. Attempting to understand the
semantics of fake GLOBs will make your brain implode.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 23 Jan 2003 14:34:52 +0100
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Passing a glob reference doesn't work with 'strict'
Message-Id: <2krv2vo3hp4gpeqfa0mqhlnkeb7vkk8dhq@4ax.com>
On Thu, 23 Jan 2003 14:16:24 +0100, Marek Zawadzki
<mzawadzk@man.poznan.pl> wrote:
>On Thu, 23 Jan 2003, Bernard El-Hagin wrote:
>
>> Marek Zawadzki <mzawadzk@man.poznan.pl> wrote:
>> >When using subroutine "Archive::Tar->create_archive", I'm trying to pass
>> >*STDOUT to it so I can write my tar files to the stdout, not to disk.
>>
>> I don't know what exactly is wrong since you haven't shown us how
>> you're calling create_archive(), but I can tell you that the problem
>> is certainly *not* with 'use strict'.
>
>I call it like this:
>
>Archive::Tar->create_archive (*STDOUT, $compress, @f);
^^^^^^^
This is not a glob reference, but that's what is expected (among
others) by create_archive() according to the passage you quoted below.
[...]
> "The first argument can either be the name of the tar file to
> create or a reference to an open file handle (e.g. a GLOB
> reference)."
So try again with a reference like so:
\*STDOUT
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: 23 Jan 2003 13:38:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Passing a glob reference doesn't work with 'strict'
Message-Id: <b0or9d$lca$3@mamenchi.zrz.TU-Berlin.DE>
Marek Zawadzki <mzawadzk@man.poznan.pl> wrote in comp.lang.perl.misc:
> On Thu, 23 Jan 2003, Bernard El-Hagin wrote:
>
> > Marek Zawadzki <mzawadzk@man.poznan.pl> wrote:
> > >When using subroutine "Archive::Tar->create_archive", I'm trying to pass
> > >*STDOUT to it so I can write my tar files to the stdout, not to disk.
> >
> > I don't know what exactly is wrong since you haven't shown us how
> > you're calling create_archive(), but I can tell you that the problem
> > is certainly *not* with 'use strict'.
>
> I call it like this:
>
> Archive::Tar->create_archive (*STDOUT, $compress, @f);
>
> This results in "\*main\:\:STDOUT" file instad of archive being printed to
> the standard output.
> The Archive::Tar manual says:
>
> "The first argument can either be the name of the tar file to
> create or a reference to an open file handle (e.g. a GLOB
> reference)."
Not using a glob *reference*. "*STDOUT" is a glob. "\ *STDOUT" is
a glob reference. Try that.
Anno
------------------------------
Date: Thu, 23 Jan 2003 15:07:28 +0100
From: Marek Zawadzki <mzawadzk@man.poznan.pl>
Subject: Re: Passing a glob reference doesn't work with 'strict'
Message-Id: <Pine.GSO.4.44.0301231505240.23891-100000@rose.man.poznan.pl>
On 23 Jan 2003, Anno Siegel wrote:
> Marek Zawadzki <mzawadzk@man.poznan.pl> wrote in comp.lang.perl.misc:
> > On Thu, 23 Jan 2003, Bernard El-Hagin wrote:
> >
> > > Marek Zawadzki <mzawadzk@man.poznan.pl> wrote:
> > > >When using subroutine "Archive::Tar->create_archive", I'm trying to pass
> > > >*STDOUT to it so I can write my tar files to the stdout, not to disk.
/ ...
> Not using a glob *reference*. "*STDOUT" is a glob. "\ *STDOUT" is
> a glob reference. Try that.
No, it doesn't work. It doesn't print tar archive on standard output,
and also gives me this error message:
Can't call method "gzwrite" on unblessed reference at
/usr/lib/perl5/site_perl/5.8.0/Archive/Tar.pm line 521.
I'm using Perl 5.8.0
-marek
------------------------------
Date: 23 Jan 2003 15:05:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Passing a glob reference doesn't work with 'strict'
Message-Id: <b0p0bq$ra5$1@mamenchi.zrz.TU-Berlin.DE>
Marek Zawadzki <mzawadzk@man.poznan.pl> wrote in comp.lang.perl.misc:
> On 23 Jan 2003, Anno Siegel wrote:
>
> > Marek Zawadzki <mzawadzk@man.poznan.pl> wrote in comp.lang.perl.misc:
> > > On Thu, 23 Jan 2003, Bernard El-Hagin wrote:
> > >
> > > > Marek Zawadzki <mzawadzk@man.poznan.pl> wrote:
> > > > >When using subroutine "Archive::Tar->create_archive", I'm trying to pass
> > > > >*STDOUT to it so I can write my tar files to the stdout, not to disk.
> / ...
> > Not using a glob *reference*. "*STDOUT" is a glob. "\ *STDOUT" is
> > a glob reference. Try that.
>
> No, it doesn't work. It doesn't print tar archive on standard output,
> and also gives me this error message:
> Can't call method "gzwrite" on unblessed reference at
> /usr/lib/perl5/site_perl/5.8.0/Archive/Tar.pm line 521.
>
> I'm using Perl 5.8.0
There is a bug in Archive::Tar that bites when the output file
is a non-seekable file. This would be the case when your STDOUT
is the default terminal. I'd inform the author.
Anno
------------------------------
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 4453
***************************************