[25936] in Perl-Users-Digest
Perl-Users Digest, Issue: 8156 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 8 14:05:36 2005
Date: Wed, 8 Jun 2005 11:05:09 -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 Wed, 8 Jun 2005 Volume: 10 Number: 8156
Today's topics:
Binary compatibility 5.8.0 -> 5.8.7 <trondham+spam@ulrik.uio.no>
Re: FAQ 8.43 How do I open a file without blocking? xhoster@gmail.com
Re: Fibonacci string <usenet@vyznev.invalid>
Re: Fibonacci string (Anno Siegel)
Re: iterating over a hashref of hashrefs <nobull@mail.com>
Re: iterating over a hashref of hashrefs <nobull@mail.com>
Re: Net::FTP: cwd(' ') <josef.moellers@fujitsu-siemens.com>
Re: Net::FTP: cwd(' ') <sisyphus1@nomail.afraid.org>
Re: perl one liner to display the third line from the e (Anno Siegel)
Re: perl one liner to display the third line from the e <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: perl one liner to display the third line from the e (Anno Siegel)
Re: perl one liner to display the third line from the e <djames@thehub.com.au>
Re: perl one liner to display the third line from the e <xx087@freenet.carleton.ca>
Re: perl one liner to display the third line from the e <nobull@mail.com>
Re: Photo does not recognize format of Archive::Zip con (Anno Siegel)
Re: Photo does not recognize format of Archive::Zip con <rtrahan@optonline.net>
Re: Photo does not recognize format of Archive::Zip con <1usa@llenroc.ude.invalid>
Re: Photo does not recognize format of Archive::Zip con (Anno Siegel)
Re: Photo does not recognize format of Archive::Zip con <rtrahan@optonline.net>
Re: summarize bytes <jurgenex@hotmail.com>
Re: summarize bytes <bastardx@S-P-A-Mop.pl>
Re: summarize bytes <1usa@llenroc.ude.invalid>
Re: summarize bytes <bastardx@S-P-A-Mop.pl>
Re: symbol table question <nobull@mail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 08 Jun 2005 17:40:20 +0200
From: Trond Hasle Amundsen <trondham+spam@ulrik.uio.no>
Subject: Binary compatibility 5.8.0 -> 5.8.7
Message-Id: <15ty89keu1n.fsf@tux.uio.no>
Hi,
I'm having trouble making a perl 5.8.7 which is binary compatible with
our pre-installed modules for 5.8.0. I've included the libpath for the
old modules in @INC, so pure perl modules aren't a problem. However,
with binary modules (that is, they contain C code and have a .so file)
doesn't work. I get the famous error message:
Can't load '/local/lib/perl5/site_perl/5.8.0/auto/PDL/Core/Core.so' for module PDL::Core: /local/lib/perl5/site_perl/5.8.0/auto/PDL/Core/Core.so: undefined symbol: PL_sv_undef at /local/lib/perl5/5.8.7/DynaLoader.pm line 230.
at (eval 1) line 6
Compilation failed in require at (eval 1) line 6.
BEGIN failed--compilation aborted at (eval 1) line 6.
BEGIN failed--compilation aborted at -e line 1.
Problem is, the previous perl version is single-threaded and static
(i.e. is has a libperl.a instead of libperl.so), while I want to
compile the new version with threading support and with a shared lib.
I don't know if this is an issue at all, but here you have it.
Any suggestions? I'm stuck.
Cheers,
--
Trond
------------------------------
Date: 08 Jun 2005 16:21:12 GMT
From: xhoster@gmail.com
Subject: Re: FAQ 8.43 How do I open a file without blocking?
Message-Id: <20050608122112.649$WX@newsreader.com>
PerlFAQ Server <comdog@panix.com> wrote:
> This message is one of several periodic postings to comp.lang.perl.misc
> intended to make it easier for perl programmers to find answers to
> common questions. The core of this message represents an excerpt
> from the documentation provided with Perl.
>
> --------------------------------------------------------------------
>
> 8.43: How do I open a file without blocking?
>
> If you're lucky enough to be using a system that supports
> non-blocking reads (most Unixish systems do), you need only to use
> the O_NDELAY or O_NONBLOCK flag from the Fcntl module in conjunction
> with sysopen():
>
> use Fcntl;
> sysopen(FH, "/foo/somefile", O_WRONLY|O_NDELAY|O_CREAT, 0644)
> or die "can't open /foo/somefile: $!":
>
> --------------------------------------------------------------------
I'm not sure I even understand what this is supposed to accomplish, but
wouldn't a better title be "How do I open a file for non-blocking reads?"?
As it stands, it sounds like it is the "open" (or "sysopen") itself that is
supposed to not block.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Wed, 08 Jun 2005 17:32:44 +0300
From: Ilmari Karonen <usenet@vyznev.invalid>
Subject: Re: Fibonacci string
Message-Id: <slrndae0cc.38e.usenet@boojum.home.vyznev.net>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> kirjoitti 26.05.2005:
>
> Avoiding s/// altogether gains another factor of 50 or so:
>
> my $v = 1;
> for ( 1 .. 20 ) {
> printf "%10d %10d\n", $v =~ y/0//, $v =~ y/1//;
> $_ .= length > 1 ? substr( $_, 0, tr/1/1/) : 0 for $v;
> }
If we're allowed to change the algorithm as long as the same strings
are produced, I think I can do even better:
my $v = 1; my $v2 = 0;
for ( 1 .. 20 ) {
printf "%10d %10d\n", $v =~ y/0//, $v =~ y/1//;
my $t = $v; $v .= $v2; $v2 = $t;
}
Benchmark:
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark qw 'cmpthese';
our ($j, $a, $b, $c);
our $max = 10;
cmpthese -3 => {
john => '$j = 1; for (1 .. $max) {$j =~ s/./$& ? "10" : "1"/eg}',
abigail => '$a = 1; for (1 .. $max) {$a =~ s/1/12/g; $a =~ y/02/10/}',
anno => '$b = 1; for (1 .. $max) {$_ .= length() > 1 ? substr( $_, 0, y/1/1/) : 0 for $b}',
ilmari => '$c = 1; my $c2 = 0; for (1 .. $max) {my $t = $c; $c .= $c2; $c2 = $t}',
};
die unless $a eq $j and $b eq $j and $c eq $j;
__END__
--
Ilmari Karonen
To reply by e-mail, please replace ".invalid" with ".net" in address.
------------------------------
Date: 8 Jun 2005 16:25:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Fibonacci string
Message-Id: <d8765p$6hn$2@mamenchi.zrz.TU-Berlin.DE>
Ilmari Karonen <usenet@vyznev.invalid> wrote in comp.lang.perl.misc:
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> kirjoitti 26.05.2005:
> >
> > Avoiding s/// altogether gains another factor of 50 or so:
> >
> > my $v = 1;
> > for ( 1 .. 20 ) {
> > printf "%10d %10d\n", $v =~ y/0//, $v =~ y/1//;
> > $_ .= length > 1 ? substr( $_, 0, tr/1/1/) : 0 for $v;
> > }
>
> If we're allowed to change the algorithm as long as the same strings
> are produced, I think I can do even better:
I think we should *always* consider a change in algorithm when playing
optimization games. It is the most promising approach, if applicable.
This thread has shown it again.
> my $v = 1; my $v2 = 0;
> for ( 1 .. 20 ) {
> printf "%10d %10d\n", $v =~ y/0//, $v =~ y/1//;
> my $t = $v; $v .= $v2; $v2 = $t;
> }
Ah, an append-only solution. Yes, it beats my fastest version
use constant PHI => ( 1 + sqrt(5))/2;
my $c = 1;
for (1 .. 20) {
$c .= length( $c) > 1 ? substr( $c, 0, int 0.5 + length( $c)/PHI) : 0;
}
slightly.
Anno
------------------------------
Date: Wed, 08 Jun 2005 18:32:33 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: iterating over a hashref of hashrefs
Message-Id: <d87a42$k6h$1@redhat2.bham.ac.uk>
Sam wrote:
> I have a data structure that looks like this:
> $self->{'foo'}->{'bar'}->{'dog'} = "fred";
> $self->{'foo'}->{'bar'}->{'blue'}->{'cat'} = "barney";
>
>
> $self->{'foo'}->{'ban'}->{'dog'} = "wilma";
> $self->{'foo'}->{'ban'}->{'cat'} = "betty";
>
>
> $self->{'foo'}->{'bas'}->{'dog'}= "bambam";
> $self->{'foo'}->{'bas'}->{'cat'} = "dino";
>
> Where I want all entries which have a key = "cat". The trick is that the
> depth of the hashref tree is not constant. (line2) otherwise I'd just use a
> bunch of nested foreach statements.
I'd go for a queue and an iterative approach...
my @hashes = $self;
my @found;
while ( my $hash = shift @hashes ) {
# push @hashes => map { eval { \%$_ } } values %$hash;
push @hashes => grep { ref eq 'HASH' } values %$hash;
push @found => $hash->{cat} if exists $hash->{cat};
}
Note the commented-out eval{} based alternate line allows you to cope
with blessed hashes and object that emmulate hashes via overloading. If
you are only interested in plain hashes then stick with the uncommented
code.
Note if 'cat' appears as a non-terminal subscript in the tree then
@found will contain whole subtrees (i.e. it will contain hashrefs). I'm
assuming this is what you want.
------------------------------
Date: Wed, 08 Jun 2005 18:35:45 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: iterating over a hashref of hashrefs
Message-Id: <d87aa3$k6h$2@redhat2.bham.ac.uk>
Brian McCauley wrote:
> while ( my $hash = shift @hashes ) {
> push @hashes => grep { ref eq 'HASH' } values %$hash;
> }
Actually it's probably more more memory efficient to make @hashes a
stack rather then a queue. Change shift to pop (or change push to unshift).
------------------------------
Date: Wed, 08 Jun 2005 12:57:42 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Net::FTP: cwd(' ')
Message-Id: <d86ioe$r4o$1@nntp.fujitsu-siemens.com>
Damian James wrote:
> On Wed, 08 Jun 2005 10:36:23 +0200, Josef Moellers said:
>=20
>>I'd like to access a directory named ' ' (a single blank) on an ftp ser=
ver.
>>I can connect all right, but the $ftp->cwd(' '), while succeeding, only=
>>moves me to /, rather than into the directory.
>>I've also tried '" "' and '\ ' to no avail.
>>
>=20
>=20
> Hmmm
>=20
> puli% mkdir foo
> puli% mkdir foo/\=20
> puli% touch foo/\ /bar
> puli% perl -le 'system "ls $_" for glob "test/*"'
>=20
> puli% perl -le 's/[ ]/\\$&/, system "ls $_" for glob "foo/*"'
> bar
>=20
>=20
> Remember that to put a literal backslash in a string, even in single
> quotes, you need to escape it. So that should be '\\ '.
Thanks for the hint, but it seems to be a special case of Net::FTP:
$dir =3D "/" unless defined($dir) && $dir =3D~ /\S/;
If I remove the check for a non-blank character, I get
"Invalid number of arguments." as the result of $ftp->message.
None of '\ ', '\\ ', '" "' work.
Sigh,
Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Wed, 8 Jun 2005 22:53:42 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Net::FTP: cwd(' ')
Message-Id: <42a6ea69$0$10698$afc38c87@news.optusnet.com.au>
"Josef Moellers" <josef.moellers@fujitsu-siemens.com> wrote in message
news:d86agm$7s6$1@nntp.fujitsu-siemens.com...
Hi,
I have this problem:
I'd like to access a directory named ' ' (a single blank) on an ftp server.
--------------------
Heh ... I guess it *is* a problem for you .... but the person with the
*real* problem is the braindead halfsmart that gave it that name :-)
G'luck.
Cheers,
Rob
------------------------------
Date: 8 Jun 2005 11:10:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl one liner to display the third line from the end of a file
Message-Id: <d86jnp$na2$3@mamenchi.zrz.TU-Berlin.DE>
Oxnard <shankeypNO_SPAM@comcast.net> wrote in comp.lang.perl.misc:
> perl v5.8.0
>
> Assuming the file is a random length text file.
> I know I can do this in a Perl script, however I would like to add the one
> liner to an shell script.
perl -ne 'print if $. eq 3' file
If the file is big:
perl -ne '$. eq 3 and print and last' file
Anno
------------------------------
Date: Wed, 8 Jun 2005 13:33:24 +0200
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: perl one liner to display the third line from the end of a file
Message-Id: <Xns966F89E81D979elhber1lidotechnet@62.89.127.66>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> Oxnard <shankeypNO_SPAM@comcast.net> wrote in comp.lang.perl.misc:
>> perl v5.8.0
>>
>> Assuming the file is a random length text file.
>> I know I can do this in a Perl script, however I would like to
>> add the one liner to an shell script.
>
> perl -ne 'print if $. eq 3' file
Subject: Re: perl one liner to display the third line from the end of a
^^^^^^^^^^^^
file
--
Cheers,
Bernard
------------------------------
Date: 8 Jun 2005 12:01:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl one liner to display the third line from the end of a file
Message-Id: <d86mm8$pg9$1@mamenchi.zrz.TU-Berlin.DE>
Bernard El-Hagin <bernard.el-haginDODGE_THIS@lido-tech.net> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>
> > Oxnard <shankeypNO_SPAM@comcast.net> wrote in comp.lang.perl.misc:
> >> perl v5.8.0
> >>
> >> Assuming the file is a random length text file.
> >> I know I can do this in a Perl script, however I would like to
> >> add the one liner to an shell script.
> >
> > perl -ne 'print if $. eq 3' file
>
>
> Subject: Re: perl one liner to display the third line from the end of a
> file
Right. Goes to show it's a bad idea to put the question only in the
subject.
perl -ne 'shift @x if @x > 2; push @x, $_; END{ print @x[ 0]}' file
Anno
------------------------------
Date: Wed, 08 Jun 2005 13:26:03 GMT
From: Damian James <djames@thehub.com.au>
Subject: Re: perl one liner to display the third line from the end of a file
Message-Id: <slrndadsbu.bbb.djames@puli.home>
On Tue, 7 Jun 2005 14:27:10 -0500, Oxnard said:
> Assuming the file is a random length text file.
> I know I can do this in a Perl script, however I would like to add the one
> liner to an shell script.
> Anyone have idea ideas on how to do this?
perl -ne 'BEGIN{$#x=2}push@x,$_;shift@x}{print $x[0]' file
is pleasantly obscure.
Though as another poster suggested, tail -3 | head -1 is the
way to go if obscurity is not on the wish list.
--damian
--
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker,
------------------------------
Date: 8 Jun 2005 17:01:15 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: perl one liner to display the third line from the end of a file
Message-Id: <slrndae92s.2el.xx087@smeagol.ncf.ca>
At 2005-06-07 03:27PM, Oxnard <shankeypNO_SPAM@comcast.net> wrote:
> perl v5.8.0
>
> Assuming the file is a random length text file.
> I know I can do this in a Perl script, however I would like to add the one
> liner to an shell script.
> Anyone have idea ideas on how to do this?
Not a high golf score, but you don't have to read every line in the
file. It assumes that the final 3 lines can be contained in the last
1024 bytes of the file though.
perl -e '
open $fid, "<", shift;
$buf = 1024;
seek $fid, -$buf, 2;
$bytes = read $fid, $data, $buf;
@lines = split /\n/, $data, -1; # preserve trailing blank lines
pop @lines; # but ignore the trailing newline that ends the file
print $lines[-3], "\n"
' file
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: Wed, 08 Jun 2005 18:48:28 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: perl one liner to display the third line from the end of a file
Message-Id: <d87b1i$rq4$1@redhat2.bham.ac.uk>
Damian James wrote:
> On Tue, 7 Jun 2005 14:27:10 -0500, Oxnard said:
>
>>Assuming the file is a random length text file.
>>I know I can do this in a Perl script, however I would like to add the one
>>liner to an shell script.
>
> perl -ne 'BEGIN{$#x=2}push@x,$_;shift@x}{print $x[0]' file
>
> is pleasantly obscure.
>
> Though as another poster suggested, tail -3 | head -1 is the
> way to go if obscurity is not on the wish list.
If obscurity is not on the list but Perl is, then Damian's solution is
more clearly written as:
perl -ne 'BEGIN{ $#x=2 } push @x,$_; shift @x; END{ print $x[0] }' file
------------------------------
Date: 8 Jun 2005 11:05:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Photo does not recognize format of Archive::Zip contents
Message-Id: <d86jdq$na2$2@mamenchi.zrz.TU-Berlin.DE>
Richard Trahan <rtrahan@optonline.net> wrote in comp.lang.perl.misc:
> Consider the following sub. On entry, $tl is a Toplevel, $rmn is an
A toplevel what? Please name the modules you are using. Leaving it
up to the reader to guess from one or two function names is impolite.
> index into an array of Archive::Zip object member names; comments
> explain the others.
Is the fact that the images come from a zip archive essential? I
doubt it.
> sub display_image
> {
> my ($tl,$rmn) = @_; # Toplevel, requested member number
> my $mnref = $tl->{'member_names'}; # ref to member names array
> my $zip = $tl->{'zip'}; # Archive::Zip object
>
> my $membername = $mnref->[$rmn];
> my $member = $zip->memberNamed($membername);
> $tl->{'current_member_number'} = $rmn; # reset current member
> my $fh;
> my $fn = "C:/windows/temp/temp.jpg";
> open $fh,">",$fn;
> $member->extractToFileHandle($fh); # this works ok
> close $fh;
> # my $contents = $zip->contents($member); # (binary) jpeg data
> # open $fh,">","C:/temp/temp2.jpg";
> # binmode $fh;
> # print $fh $contents; # this works ok
> # close $fh;
> my $image = $tl->Photo(
> '-format' => 'jpeg',
> # -data => $contents, # this doesn't work
> -file => $fn, # this works ok
> );
> my $button = $tl->{'button'}; # button where image is displayed
> $button->configure(-image => $image); # set image
> $tl->configure(-title => $tl->{'file_name'} .
> ":" . $tl->{'sequence'} . " - $membername");
> }
>
> Commented sections show that I can successfully extract the "contents"
> of a Zip::Archive member (all of which are jpeg files), and write it to
> a file (it displays perfectly in a browser, PhotoEditor, etc.). I can
> also "extract" that member to another file and specify that file name to
> the Photo object, whereupon it displays just fine. But when I take the
> "contents", which is supposed to be pure jpeg binary data, and feed it
> to the Photo object, the system complains that it doesn't recognize the
> file format.
Read "perldoc Tk::Photo". Under the heading "IMAGE FORMATS" you'll
find:
The photo image code is structured to allow handlers for
additional image file formats to be added easily. The
photo image code maintains a list of these handlers.
Handlers are added to the list by registering them with a
call to Tk_CreatePhotoImageFormat. The standard Tk
distribution comes with handlers for PPM/PGM and GIF
formats, which are automatically registered on
initialization.
Looks like you may have to find a way to add a jpeg handler. I don't
know why it works with file input, nor why a jpeg handler *is* mentioned
elsewhere in the documentation (except that documentation isn't perfect).
At least this looks like something to explore.
Anno
------------------------------
Date: Wed, 08 Jun 2005 09:29:19 -0400
From: Richard Trahan <rtrahan@optonline.net>
Subject: Re: Photo does not recognize format of Archive::Zip contents
Message-Id: <2oCpe.3444$S62.1656@fe11.lga>
Thank you for your reply.
There are no errors in my sample; $contents is not used later unless all
lines containing $contents are uncommented.
Yes, it is essential that the files come from a zip archive.
Yes, I have read Tk::Photo; JPEG is listed in the Description as a
supported format. The fact that I can read a jpeg file with the "-file"
option illustrates that. It is when "-file" is replaced by "-data =>
contents_from_zip_archive" that it breaks.
A Toplevel would be immediately familiar to anyone conversant with Tk.
Since you opted to point me to Tk::Photo, I assume you are a Tk person,
and you should have known what Toplevel is.
Yes, I do know about comp.lang.perl.tk. I chose to post here, because
the members are more knowledgeable, for the most part.
It is impolite to criticize when you don't know what you're talking about.
------------------------------
Date: Wed, 08 Jun 2005 14:23:21 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Photo does not recognize format of Archive::Zip contents
Message-Id: <Xns966F6971B4D02asu1cornelledu@127.0.0.1>
Richard Trahan <rtrahan@optonline.net> wrote in
news:2oCpe.3444$S62.1656@fe11.lga:
> Thank you for your reply.
[ Thank whom for what reply? Please quote some context when you reply. ]
> It is impolite to criticize when you don't know what you're talking
> about.
A verdict more applicable to you than to Anno, for sure.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 8 Jun 2005 16:23:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Photo does not recognize format of Archive::Zip contents
Message-Id: <d8761s$6hn$1@mamenchi.zrz.TU-Berlin.DE>
Richard Trahan <rtrahan@optonline.net> wrote in comp.lang.perl.misc:
>
> Thank you for your reply.
Whose reply? Please quote some context when you reply.
> There are no errors in my sample; $contents is not used later unless all
> lines containing $contents are uncommented.
Yes. I noticed too late that you chose to give example code that doesn't
demonstrate the error. I corrected that part of my posting, but you seem
to have replied to the uncorrected version. See how quoting *the post that
you saw* can make a difference?
> Yes, it is essential that the files come from a zip archive.
Essential for the error? Are you saying, if you read the string from
a .jpeg file instead of a zip archive you don't have the problem?
That would be an interesting hint, but neither your code nor your
comments indicate that.
> Yes, I have read Tk::Photo; JPEG is listed in the Description as a
> supported format.
It is listed in one place, but not in the section "IMAGE FORMATS"
(in the version I checked). Since you reported a problem with
one of the missing image formats I thought I'd point out the fact.
> The fact that I can read a jpeg file with the "-file"
> option illustrates that. It is when "-file" is replaced by "-data =>
> contents_from_zip_archive" that it breaks.
Yes, I understand that. Does it also break when you read the data from
a file and not a zip archive? I'd expect it does, but your insistence
that Archive::Zip is somehow involved makes me ask.
> A Toplevel would be immediately familiar to anyone conversant with Tk.
Oh. No other module can use the identifier "Toplevel"?
> Since you opted to point me to Tk::Photo, I assume you are a Tk person,
> and you should have known what Toplevel is.
I'm not a "Tk person". I have used the module occasionally and have
it around. I decided to take a look at the relevant documentation,
found a discrepancy and pointed it out.
> Yes, I do know about comp.lang.perl.tk. I chose to post here, because
> the members are more knowledgeable, for the most part.
Don't mix posters up. I didn't point you to c.l.p.tk.
Since you chose to post here it would have been polite to word your
posting for the general audience you can expect here and not for people
who live in a Tk world.
Anno
------------------------------
Date: Wed, 08 Jun 2005 12:50:50 -0400
From: Richard Trahan <rtrahan@optonline.net>
Subject: Re: Photo does not recognize format of Archive::Zip contents
Message-Id: <YkFpe.13616$So7.5049@fe10.lga>
Thank you for your reply.
>
> [ Thank whom for what reply? Please quote some context when you reply. ]
No, I won't. The thanks apply to the parent posting, which you can see
if you group your postings by thread.
------------------------------
Date: Wed, 08 Jun 2005 10:29:17 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: summarize bytes
Message-Id: <1Mzpe.10324$KQ2.5813@trnddc08>
bastardx wrote:
Someone else wrote:
>> [Program that uses <DATA> file handle]
>
> works great
> this exacly what i want
> how to read this data from file?
Oh pleeeaaasssee: "perldoc -f open"
jue
------------------------------
Date: Wed, 8 Jun 2005 15:03:33 +0200
From: "bastardx" <bastardx@S-P-A-Mop.pl>
Subject: Re: summarize bytes
Message-Id: <d86qko$em7$1@nemesis.news.tpi.pl>
Użytkownik "Jürgen Exner" <jurgenex@hotmail.com> napisał w wiadomości
news:1Mzpe.10324$KQ2.5813@trnddc08...
> bastardx wrote:
> Someone else wrote:
>>> [Program that uses <DATA> file handle]
>>
>> works great
>> this exacly what i want
>> how to read this data from file?
>
> Oh pleeeaaasssee: "perldoc -f open"
>
yes I know :)
I am not a programmer I just want to create some statistc for my dsl router
Open a file is quite easy but then I have to read line by line, get values
separated by space etc etc
If you know any of programming languages it is easy but I dont
This is my first contact with such a problem.
Sorry for any problem.
------------------------------
Date: Wed, 08 Jun 2005 16:38:03 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: summarize bytes
Message-Id: <Xns966F8047F5660asu1cornelledu@127.0.0.1>
"bastardx" <bastardx@S-P-A-Mop.pl> wrote in
news:d86qko$em7$1@nemesis.news.tpi.pl:
> Użytkownik "Jürgen Exner" <jurgenex@hotmail.com> napisał w wiadomości
> news:1Mzpe.10324$KQ2.5813@trnddc08...
>> bastardx wrote:
>> Someone else wrote:
>>>> [Program that uses <DATA> file handle]
>>>
>>> works great
>>> this exacly what i want
>>> how to read this data from file?
>>
>> Oh pleeeaaasssee: "perldoc -f open"
>>
> yes I know :)
> I am not a programmer I just want to create some statistc for my dsl
> router
Who cares what you are and what you want to do?
> Open a file is quite easy but then I have to read line by line,
> get values separated by space etc etc
All of which were done for you by Joe Smith. All you had to do was to
replace the DATA handle with a handle you got from open. And you are
still unwilling to look that one simple thing up, and want someone else
to do it.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Wed, 8 Jun 2005 19:44:59 +0200
From: "bastardx" <bastardx@S-P-A-Mop.pl>
Subject: Re: summarize bytes
Message-Id: <d87b4h$rsv$1@nemesis.news.tpi.pl>
>> yes I know :)
>> I am not a programmer I just want to create some statistc for my dsl
>> router
>
> Who cares what you are and what you want to do?
You :)
ps
Thanks for Leo who send me a correct code.
------------------------------
Date: Wed, 08 Jun 2005 18:16:12 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: symbol table question
Message-Id: <d8795e$c3o$1@redhat2.bham.ac.uk>
Richard Trahan wrote:
> Brian McCauley wrote:
>
>>
>> What are you trying to achive? This smells distictly X-Y.
>>
> Thank you for your response. I hadn't thought of equating the references.
>
> I am expanding the Track program in Damian Conway's book, chapter on
> Ties. The procedure, for scalars, is to call a tracking class which ties
> the tracked variable after setting up a hash object and some stuff in
> the STORE and FETCH methods which record caller() info. The proc is
> limited in that it does not print the variable names,
Not all variables have names you know.
> and it's
> cumbersome to look at source code to match caller() info to debug
> output in order to determine what variable is being dumped.
Then extend the API to allow you to pass a descriptive string along with
the variable.
> Another limitation is that the Track class, as shown in Conway's
> book, relies on sub aliasing of @_ to variables, provided they're
> scalars. For example, the setup for tracking a scalar is:
> Track->scalar($myvariable)
> In Track::scalar(), $_[0] is the class name ("Track") and $_[1] is
> aliased to $myvariable (I've never been quite sure what an alias
> is under the hood, although I know it refers to the same memory
> location).
> But if you try to do something like:
> Track->hash(%myhash)
> it doesn't work, since Perl flattens %myhash into a list, rather than
> putting an alias into $_[1]. If you try something like
> Track->hash(\%myhash), you get a reference in hash(), and I don't know
> how to tie a variable if you only have a reference to it. (I think
> dereferencing it produces a copy of the hash, not an alias.)
I suggest you stop thinking that because it is wrong. Once you stop
thinking it your other problem goes away.
> Instead, the program setting up the tracking must call
> tie(%hash,"Track",@arglist); tie() seems to be a magic syntax that
> doesn't flatten %hash. (This is not explained anywhere, AFAIK.)
Perl's builtin functions are able have magic syntax that a user-defined
Perl function could not emulate. Some may even have syntax that not
even a user defined XS function could emulate. tie() one of these. You
can tell this because prototype('CORE::tie') is undef.
You can go some way towards the magic syntax using a prototype.
Prototypes are explained in perlsub. But because prototypes are
implemented as compile-time syntactic sugar and method calls are
resolved at runtime, a subroutine called as a method ignores its prototype.
> I don't like symbol tables either, thank you, but I think they're
> necessary when developing debuggers and IDEs.
There are two types of symbol table in Perl the first are internally
called stashes and externally know as packages or namespaces. The other
type of symbol table is known as a pad. If one says unqualified "symbol
table" one is assumed to mean stash.
In a typical (well written) Perl program the vast majority of variables
are lexically scoped and reside in pads. The next most prevelant
variables are anonymous ones that have no entry in either a stash or a
pad. And finally a tiny minority of variables exist in stashes.
I'm ignoring here special variables as documented in perlvar - these too
reside in stashes but you are unlikely to want to Track them and quite
often they can't be tied.
If you are writing debugging tools then you can manipulate pads using
PadWalker but in this case I would not recommend it - just pass the name
as another argument.
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 8156
***************************************