[25077] in Perl-Users-Digest
Perl-Users Digest, Issue: 7327 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 27 21:05:37 2004
Date: Wed, 27 Oct 2004 18: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, 27 Oct 2004 Volume: 10 Number: 7327
Today's topics:
Re: A file open and close that doesnt modify a timestam <jgibson@mail.arc.nasa.gov>
Re: Common file operations (Seymour J.)
Re: Common file operations (Seymour J.)
Re: Common file operations (Seymour J.)
Re: Common file operations (Seymour J.)
Re: Compress::Zlib vs. external gzip call <usenet_05_08_2004@stuartmoore.org.uk>
Re: Detecting a Process using Perl Win32 <tom.tingdale@sbcglobal.net>
Re: Detecting a Process using Perl Win32 <tom.tingdale@sbcglobal.net>
Re: How do I parse this Charactor? 2byte vs 1byte <see@sig.invalid>
How to get an image file and display it on the screen? <Allen.Windhorn@LSUSA.com>
Re: How to get an image file and display it on the scre <spamtrap@dot-app.org>
Re: How to get an image file and display it on the scre <ebohlman@omsdev.com>
Re: How to get an image file and display it on the scre <matthew.garrish@sympatico.ca>
Re: HOW TO replace ' but not ?' <abigail@abigail.nl>
Re: How to use relative path for a module (David Efflandt)
Re: How's my logic? <lawshouse.public@btconnect.com>
Re: How's my logic? <mritty@gmail.com>
Re: How's my logic? <lawshouse.public@btconnect.com>
Image data parsing (anatolym)
Re: Inter Program Communication ... <ebohlman@omsdev.com>
interpolation question: <c186282@yahoo.com>
Re: interpolation question: <ebohlman@omsdev.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 27 Oct 2004 17:00:43 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: A file open and close that doesnt modify a timestamp
Message-Id: <271020041700435107%jgibson@mail.arc.nasa.gov>
In article <878baabf.0410271214.698835e7@posting.google.com>, gumby
<georgeziv@hotmail.com> wrote:
> I need to be able to open a file, read a file, then close a file with
> out perl rewriting the TimeStamp on the file. I was able to do this
> in C++ but not perl, and currently we are rewriting our old C code to
> perl.
>
What operating system and version of Perl are you using? On my system
(Mac OS 10.3, perl 5.8.5), opening and reading a file changes none of
the file times atime, mtime, nor ctime.
------------------------------
Date: Wed, 27 Oct 2004 18:35:02 -0300
From: "Shmuel (Seymour J.) Metz" <spamtrap@library.lspace.org.invalid>
Subject: Re: Common file operations
Message-Id: <41802296$11$fuzhry+tra$mr2ice@news.patriot.net>
In <9b6452-rl4.ln1@osiris.mauzo.dyndns.org>, on 10/27/2004
at 10:28 AM, Ben Morrow <usenet@morrow.me.uk> said:
>I happen to know that the Win32 modules allow you to retreive te
>current drive and current dir separately;
Looking through the source code for several modules I found
Cwd::abs_path; what are the tradeoffs between that and
File::Spec->rel2abs?
>Which File::Spec does for you.
I will add a few lines to my test code to verify that it does what I
expect.
>In that case you want to use glob *after* rel2abs:
OK.
>You may also be interested in File::DosGlob,
It doesn't work with strict.
Thanks.
Whoops: rel2abs has a bug, so I'll use abs_path:
rel2abs(g:tsm\x)=H:/comm/tsm/x
--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>
Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to spamtrap@library.lspace.org
------------------------------
Date: Wed, 27 Oct 2004 18:33:53 -0300
From: "Shmuel (Seymour J.) Metz" <spamtrap@library.lspace.org.invalid>
Subject: Re: Common file operations
Message-Id: <41802251$10$fuzhry+tra$mr2ice@news.patriot.net>
In <Xns958FEF32BFCasu1cornelledu@132.236.56.8>, on 10/27/2004
at 04:05 AM, "A. Sinan Unur" <usa1@llenroc.ude.invalid> said:
>Please don't do this. Perl already has a well defined notion of true
>and false. Don't invent new things.
I thought that it was clearer that way, but if it's considered to be
bad style then I won't do it.
Thanks.
--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>
Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to spamtrap@library.lspace.org
------------------------------
Date: Wed, 27 Oct 2004 18:33:27 -0300
From: "Shmuel (Seymour J.) Metz" <spamtrap@library.lspace.org.invalid>
Subject: Re: Common file operations
Message-Id: <41802237$9$fuzhry+tra$mr2ice@news.patriot.net>
In <slrncnuaev.ovl.tadmc@magna.augustmail.com>, on 10/26/2004
at 11:53 PM, Tad McClellan <tadmc@augustmail.com> said:
>(you have a broken perl installation)
That's quite possible. I'll look into it, but I normally use
documentation in a different format.
>You must live a sheltered life.
No. I just distinguish between "e" and "p" ;-)
>How do you know what glob() can and can't do if you cannot access
>the docs for glob()?
That question presupposes an assumption contrary to fact. I read the
documentation for glob prior to writing the test code.
>Because there are hundreds of other people here besides the two of
>you,
And, indeed, I posted the code in response to a different article.
>s/her/his/;
Will do.
--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>
Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to spamtrap@library.lspace.org
------------------------------
Date: Wed, 27 Oct 2004 18:32:28 -0300
From: "Shmuel (Seymour J.) Metz" <spamtrap@library.lspace.org.invalid>
Subject: Re: Common file operations
Message-Id: <418021fc$8$fuzhry+tra$mr2ice@news.patriot.net>
In <Xns958F1A83B87asu1cornelledu@132.236.56.8>, on 10/27/2004
at 04:00 AM, "A. Sinan Unur" <usa1@llenroc.ude.invalid> said:
>He does not trust the assertions you make without providing test
>cases that exhibit the problems you mention.
If he doesn't believe me, then why would he believe that the test
output came from my computer? He didn't simply say that she wanted to
see the test code and output, she called me a liar.
>As it turns out, he was right not to trust you:
No. Nor were you.
>Found in C:\Perl\lib\pod\perlfaq5.pod
Which doesn't alter the fact that I got the output I reported.
>You can also consult perldoc -f glob and perldoc perlop.
I did, with the output I reported.
>You haven't described what you want.
Yes I did.
>Then you shoud read
>perldoc perlre
>perldoc perlretut
What would they tell me that isn't already available elsewhere, in
more convenient form? They certainly don't discuss anything called an
"regexen". Perhaps you should read more carefully.
>Then you must have messed up your installation.
That is always a possibility.
>Programming without documentation is not a good idea.
That's nice, but I wasn't doing that.
--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>
Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to spamtrap@library.lspace.org
------------------------------
Date: Thu, 28 Oct 2004 00:16:33 +0100
From: Stuart Moore <usenet_05_08_2004@stuartmoore.org.uk>
Subject: Re: Compress::Zlib vs. external gzip call
Message-Id: <clpa84$fg9$1@gemini.csx.cam.ac.uk>
odigity wrote:
> I'm writing a script that needs to run in as fast a time as possible.
> Every minute counts. The script crawls a tree of gzipped files
> totalling about 30gb. Originally I was calling open() with "gzip
> $file |", but I hate making external calls - it requires a fork, and
> you have very limited communication with the process for catching
> errors and such. I always like using perl functions and modules when
> possible over external calls. However, I wanted to make sure I
> wouldn't take a performance hit before switching to Compress::Zlib.
>
Just thinking out loud here:
- Would the time measured by "Benchmark" include the time to start gzip?
Does it measure total time, or just time when the perl process is using
the CPU? Do the times mentioned match what you'd get with a stopwatch?
- Might it be worth looking at some of the smaller files as well,
possibly the time taken to open gzip is less significant on the large
ones than the small ones?
- Is there any way you can keep the gzip process open and only call it
once to decompress multiple files? One fork is better than many
------------------------------
Date: Wed, 27 Oct 2004 22:24:46 GMT
From: Tom Tingdale <tom.tingdale@sbcglobal.net>
Subject: Re: Detecting a Process using Perl Win32
Message-Id: <ev70o0pmi2va75376tapv8ql78kfk1lo9u@4ax.com>
Thank you Bryan. I appreciate it!
Tom
On 25 Oct 2004 22:51:45 -0700, bitbucketz2002@yahoo.com (Bryan
Williams) wrote:
>Tom Tingdale <tom.tingdale@sbcglobal.net> wrote in message news:<cntqn0ljli76jgit7sel1hjk9om7e6co4m@4ax.com>...
>> I have a perl program that launchs every minutes using a Windows Task
>> Scheduler to process some files. If the Perl program is still running,
>> I don't want to run it again until the previous Perl application has
>> finished. It is possible to detect whether or not my Perl application
>> is already running?
>
>sub runUpdate{
> my $pi = Win32::Process::Info->new();
> my $Updates = 0;
>
> foreach $proc ($pi->GetProcInfo())
> {
> foreach ($proc)
> {
> if ($proc->{Name} eq "update.exe")
> {
> #Count the number of running instances
> $Updates++
> }
> }
> }
> # if no running update.exe found start it otherwise exit
> if ($Updates <= 1)
> {
> doit();
> }
> else
> {
> warn "An instance of the Updater is running, exiting now.";
> exit;
> }
>}
------------------------------
Date: Wed, 27 Oct 2004 23:07:26 GMT
From: Tom Tingdale <tom.tingdale@sbcglobal.net>
Subject: Re: Detecting a Process using Perl Win32
Message-Id: <9490o05u4sbrhij27m7sf3atus1v54du3u@4ax.com>
Thank you Bryan. I appreciate it!
Tom
On 25 Oct 2004 22:51:45 -0700, bitbucketz2002@yahoo.com (Bryan
Williams) wrote:
>Tom Tingdale <tom.tingdale@sbcglobal.net> wrote in message news:<cntqn0ljli76jgit7sel1hjk9om7e6co4m@4ax.com>...
>> I have a perl program that launchs every minutes using a Windows Task
>> Scheduler to process some files. If the Perl program is still running,
>> I don't want to run it again until the previous Perl application has
>> finished. It is possible to detect whether or not my Perl application
>> is already running?
>
>sub runUpdate{
> my $pi = Win32::Process::Info->new();
> my $Updates = 0;
>
> foreach $proc ($pi->GetProcInfo())
> {
> foreach ($proc)
> {
> if ($proc->{Name} eq "update.exe")
> {
> #Count the number of running instances
> $Updates++
> }
> }
> }
> # if no running update.exe found start it otherwise exit
> if ($Updates <= 1)
> {
> doit();
> }
> else
> {
> warn "An instance of the Updater is running, exiting now.";
> exit;
> }
>}
------------------------------
Date: Wed, 27 Oct 2004 20:23:40 -0400
From: Bob Walton <see@sig.invalid>
Subject: Re: How do I parse this Charactor? 2byte vs 1byte
Message-Id: <418039dd$1_4@127.0.0.1>
nntp wrote:
...
> I only need English charactors. Is that possible using s///gs to remove
> those suckers? It is totally messed up my program. When I parse, I got
> Chinese, French, Spanish, everything, but I only need English.
Well, in order to process it with regexen, you would need to know what
encoding it is, and some detail about the encoding in order to properly
trash the correct number of bytes associated with each character. If
the encoding is, for example, UTF-8, it could be that some characters
may take three bytes, or even more. You would have to parse out the
encoding to know how many characters to discard. It would be a *lot*
easier to just do the right thing and let Perl automatically handle it.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: 27 Oct 2004 17:12:00 -0500
From: Allen Windhorn <Allen.Windhorn@LSUSA.com>
Subject: How to get an image file and display it on the screen?
Message-Id: <uvfcv95fz.fsf@LSUSA.com>
This may turn out not to be a Perl question; if so I apologise and
will be grateful for any hints on where to go.
I want to retrieve an image file
(e.g. http://132.206.154.224/fullsize.jpg), and display it in a
particular spot on the screen (Windows at the moment, Linux maybe
later) in its own window which is just large enough to fit it. I
don't want to invoke the browser or an imaging program to display it.
(Later I might want to do some image processing, and I'll want to
update it every 5-10 seconds).
I've looked in CPAN under Imaging and HTML, but didn't find anything
that looked suitable for displaying the image. Any suggestions?
Thanks in advance.
Regards,
Allen
--
Allen Windhorn (507) 345-2782 FAX (507) 345-2805
Kato Engineering (Though I do not speak for Kato)
P.O. Box 8447, N. Mankato, MN 56002
Allen.Windhorn@LSUSA.com
------------------------------
Date: Wed, 27 Oct 2004 18:23:20 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: How to get an image file and display it on the screen?
Message-Id: <YOSdna1-HKFEgh3cRVn-pg@adelphia.com>
Allen Windhorn wrote:
> I want to retrieve an image file
> (e.g. http://132.206.154.224/fullsize.jpg)
Have a look at the LWP module on CPAN.
> , and display it in a
> particular spot on the screen (Windows at the moment, Linux maybe
> later) in its own window which is just large enough to fit it. I
> don't want to invoke the browser or an imaging program to display it.
> (Later I might want to do some image processing, and I'll want to
> update it every 5-10 seconds).
Have a look at the Tk module on CPAN. I *think* it's been ported to
Windows, but I wouldn't swear by it.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 27 Oct 2004 22:41:53 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: How to get an image file and display it on the screen?
Message-Id: <Xns958FB50ACA8F2ebohlmanomsdevcom@130.133.1.4>
Sherm Pendley <spamtrap@dot-app.org> wrote in news:YOSdna1-HKFEgh3cRVn-
pg@adelphia.com:
> Allen Windhorn wrote:
>
>> I want to retrieve an image file
>> (e.g. http://132.206.154.224/fullsize.jpg)
>
> Have a look at the LWP module on CPAN.
>
>> , and display it in a
>> particular spot on the screen (Windows at the moment, Linux maybe
>> later) in its own window which is just large enough to fit it. I
>> don't want to invoke the browser or an imaging program to display it.
>> (Later I might want to do some image processing, and I'll want to
>> update it every 5-10 seconds).
>
> Have a look at the Tk module on CPAN. I *think* it's been ported to
> Windows, but I wouldn't swear by it.
It has. What Allen wants to do can definitely be done (quite easily) with
a combination of Tk (to display the image) and LWP (to fetch the image).
Note that the current version of Tk (which requires Perl 5.8.x) includes
both Tk::JPEG and Tk::PNG which used to be outside the "core" distribution.
If, though, you have a requirement for 5.6.x, older versions of Tk will
still work; you'll just have to install the two modules separately.
------------------------------
Date: Wed, 27 Oct 2004 18:55:07 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: How to get an image file and display it on the screen?
Message-Id: <eHVfd.13019$Qs6.1241846@news20.bellglobal.com>
"Allen Windhorn" <Allen.Windhorn@LSUSA.com> wrote in message
news:uvfcv95fz.fsf@LSUSA.com...
> This may turn out not to be a Perl question; if so I apologise and
> will be grateful for any hints on where to go.
>
> I want to retrieve an image file
> (e.g. http://132.206.154.224/fullsize.jpg), and display it in a
> particular spot on the screen (Windows at the moment, Linux maybe
> later) in its own window which is just large enough to fit it. I
> don't want to invoke the browser or an imaging program to display it.
> (Later I might want to do some image processing, and I'll want to
> update it every 5-10 seconds).
>
Sounds like you're looking for Win32::GUI or the Tk extensions. Both would
allow you to create a new window, position it anywhere on the screen and
display a picture in it. If you are going to port the program later,
however, you're better off using the Tk module.
Matt
------------------------------
Date: 27 Oct 2004 22:14:28 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: HOW TO replace ' but not ?'
Message-Id: <slrnco07e4.3ac.abigail@alexandra.abigail.nl>
Whitey Johnson (whitey@newmail.net) wrote on MMMMLXXV September MCMXCIII
in <URL:news:pan.2004.10.27.17.34.09.442818@newmail.net>:
:} On Wed, 27 Oct 2004 11:39:41 -0500, Whitey Johnson muttered incoherently:
:}
:} <snip snip>
:} >>
:} >> my $line = "AAA+Tim?'s'BBB+123'";
:} >> $line =~ s#[^?]'#'\n#;
:} >
:} > Damn, make that: $line =~ s#[^?]'#'\n#g;
:}
:} One more try: $line =~ s#([^?])'#$1'\n#g;
:}
:} I read Tad's post and was wondering if there was a case where this
:} wouldn't work?
Yes. It won't work, or won't work correctly, in the following cases:
* Strings that start with a quote - it will fail to put a newline
after the leading quote.
* Strings that have two or more quotes in a row - it will only put
a newline after the first, third, fifth, ..., quote.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
Date: Wed, 27 Oct 2004 23:37:00 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: How to use relative path for a module
Message-Id: <slrnco0c8s.e50.efflandt@typhoon.xnet.com>
On 27 Oct 2004 13:46:10 -0700, dn_perl@hotmail.com <dn_perl@hotmail.com> wrote:
> Is it (possible / advisable) to use relative path for a module?
>
> I install 3 directories under a location specified by my client.
> The client may specify /apps/home or /home/usr/myproduct or whatever
> as the location where I should install my 3 directories.
>
> My directories are : myapp, mylib, myhelp.
> Let us say they are installed under /apps/home. One env variable
> which the user is required to set is $MYAPP_HOME="/apps/home/myapp" .
> The dir /apps/home/mylib contains a module : dir_list.pm .
> I want the perl script /apps/home/myhelp/option01 to use dir_list.pm .
> How can I do so using 'use dir_list' construct?
> "use ../mylib/dir_list" gives syntax error.
You could do it realive to the current working directory "./":
use lib "./mylib"; # puts this 1st in @INC
use "dir_list";
However, you have to make sure the current working dir is what you think
it is. For example, in CGI called as SSI, the working dir is the dir of
the SSI page, not the CGI script.
------------------------------
Date: Wed, 27 Oct 2004 23:08:01 +0100
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Re: How's my logic?
Message-Id: <3q60o01hvah8lhmh5hdmhh6s6jon98kbn8@4ax.com>
On Wed, 27 Oct 2004 22:55:50 +0100, Henry Law
<lawshouse.public@btconnect.com> wrote:
>On Wed, 27 Oct 2004 15:55:00 -0400, wana <ioneabu@yahoo.com> wrote:
>
>>if ($user and $pass)
>>{
>> $ftp->login($user, $pass)
>> and print "successfully logged on to $server as $user\n"
>> or print "problem logging on to $server as $user\n";
>>}
>
>Can you post a complete program?
OK so I thought I'd perservere as a learning exercise. Here's a test
program which you might have written (Activestate Perl, BTW)
# -------------------------------------------
#! /usr/bin/perl
use strict;
use warnings;
open (INFILE,"file.exists")
and print "File opened OK\n"
or print "File not there\n";
my $rec = <INFILE>; # Breaks when file not there but
# suppresses perl warning
# -------------------------------------------
Here's the console output
F:\$WIP>type file.exists
adfqsfsd
F:\$WIP>tryout.pl
File opened OK
F:\$WIP>erase file.exists
F:\$WIP>tryout.pl
File not there
readline() on closed filehandle INFILE at F:\$WIP\tryout.pl line 10.
F:\$WIP>
So conclusions: (1) Your logic looks OK, assuming that the FTP thing
you're doing returns TRUE only when it works; (2) My knowledge has
improved because I didn't know you could do that "...and...or.."
thing. Thanks!
Henry Law <>< Manchester, England
------------------------------
Date: Wed, 27 Oct 2004 18:05:05 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: How's my logic?
Message-Id: <clp62k$orq$1@misc-cct.server.rpi.edu>
wana wrote:
> Here is a piece of code from a simple program I wrote to do some FTPing. I
> was wondering if the form of my statement is acceptable with respect to the
> use of 'and' and 'or'. I did it, hoping for the best, and it seems to
> work. I am always shaky on rules of precedence and usually use lots of
> ()'s to make sure I get it right, but I am trying to wean myself off of
> them.
>
> if ($user and $pass)
> {
> $ftp->login($user, $pass)
> and print "successfully logged on to $server as $user\n"
> or print "problem logging on to $server as $user\n";
> }
>
perldoc perlop has the precedence table, and will tell you that and has
a slightly higher precedence than or. Therefore, this statement is
equivalent to:
($ftp->login($user, $pass) and print "Success...") or print "problem...";
Note that this probably isn't exactly what you want to do. The failure
message will be printed if *either* the FTP login fails or the success
message fails to print. Now, granted it's rather unusual for a print
statement to fail, but this is generally not a good pattern to get into
the habbit of using.
Much prefered (IMHO, of course) would be to abandon the use of and/or as
control-flow operators in this case, and use the normal if/else syntax:
if ($ftp->login($user, $pass){
print "Success...";
} else {
print "Problem...";
}
Paul Lalli
------------------------------
Date: Wed, 27 Oct 2004 23:18:47 +0100
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Re: How's my logic?
Message-Id: <lf70o0dslp8jkg2bprlg7i3dpo2fnfruuk@4ax.com>
On Wed, 27 Oct 2004 18:05:05 -0400, Paul Lalli <mritty@gmail.com>
wrote:
>> $ftp->login($user, $pass)
>> and print "successfully logged on to $server as $user\n"
>> or print "problem logging on to $server as $user\n";
>Note that this probably isn't exactly what you want to do. The failure
>message will be printed if *either* the FTP login fails or the success
>message fails to print.
Sheesh. That's why I'm a Perl floor-sweeper and Paul's a Transcendent
Master.
Well, I stand by my comments about posting an executable program at
any rate; and by my thanks.
Henry Law <>< Manchester, England
------------------------------
Date: 27 Oct 2004 14:36:59 -0700
From: anatolym@cox.net (anatolym)
Subject: Image data parsing
Message-Id: <acc08fcc.0410271336.1bbe3a7c@posting.google.com>
Hello All,
I have a problem here and I tried a few things, but non worked.
Any help would be greatly appreciated!
I'm parsing an XML file, trying to get the image part out and save
it as an image file. File format (gif, png, jpeg, bmp) is unknown.
The following is a fragment of the XML:
<picture width="2550" height="675" baseline="674">
<pict-header>
<width>170</width>
<height>45</height>
<bits-per-pixel>8</bits-per-pixel>
<palette>
<palette-entry>#000000</palette-entry>
<palette-entry>#010101</palette-entry>
<palette-entry>#020202</palette-entry>
<palette-entry>#030303</palette-entry>
<palette-entry>#040404</palette-entry>
<palette-entry>#050505</palette-entry>
<palette-entry>#0d0d0d</palette-entry>
-- snip: lots of palette entries here --
<palette-entry>#f5f5f5</palette-entry>
<palette-entry>#f6f6f6</palette-entry>
<palette-entry>#fdfdfd</palette-entry>
<palette-entry>#fefefe</palette-entry>
<palette-entry>#ffffff</palette-entry>
</palette>
</pict-header>
<pict-data>
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////8AAP////8AAAD/
/wAAAP8AAAD//wAA/wD/AAAA//8AAAD/////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////AAD///8A////AP//AP///wD/
/wD//wAAAP8A/////wD/////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
-- snip: more picture data ---
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////AAD/////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////wAA
</pict-data>
</picture>
I tried to use Imager module to read this in and write to a file:
$type = "jpeg"; # gif, png, bmp, etc.
$filename = "fig_$iname.$type";
use Imager;
$img = Imager->new(xsize=>$pHw, ysize=>$pHh, bits=>$pBits,
type=>'paletted');
my @colors;
while($pPlt =~ m|<palette-entry>(#[\dabcdf]+)</palette-entry>|ig) {
push @colors, Imager::Color->new($1);
}
$img->addcolors(colors=>\@colors);
$img->read(data=>$pData, type=>$type) or die "Cannot read: ",
$img->errstr;
$img->write(file=>"$dir/$filename", type=>$type) or die "Cannot
write:", img->errstr;
I tryed all of the above types, but it bombs out with "Cannot read:"
every time.
Is it possible at all to parse this kind of data into a file?
If possible - what am I doing wrong?
Thanks a lot for your help!
AnatolyM
------------------------------
Date: 28 Oct 2004 00:04:57 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: Inter Program Communication ...
Message-Id: <Xns958FC320024Bebohlmanomsdevcom@130.133.1.4>
Stoill Barzakov <stoill@unixsol.org> wrote in
news:2u93etF26k0ssU1@uni-berlin.de:
> I've already been through most of the *simple* docs . What I need is
> to get Exactly what the current user is Konquering and IF it is
> Invoice screen (I've got some marks that will define this) to grab the
> page from It and process It . Bitmap will not do . I need pure text
> or pure html .
One possibility would be to set your program up to as a "local proxy
server". You'd tell Konqueror (or any other browser) to connect to it
(locally) as a proxy, and it would simply transparently pass on any
requests to the real server and serve the response to the browser. But it
would also examine the response and, if appropriate (e.g. the response has
a content-type of "text/html"), store it.
Look in the "HTTP" section of CPAN for modules with "proxy" in their names.
For that matter, you could probably cobble up something from LWP::UserAgent
and HTTP::Daemon pretty quickly (since HTTP::Daemon will get HTTP::Request
objects, which you can pass on directly to LWP::UserAgent, from the browser
and can send HTTP::Response objects obtained from LWP::UserAgent to the
browser).
------------------------------
Date: Thu, 28 Oct 2004 00:13:33 GMT
From: c186282 <c186282@yahoo.com>
Subject: interpolation question:
Message-Id: <pan.2004.10.28.00.13.32.830671@yahoo.com>
I'm reading in a file line by line. Some of the lines have variables
that I would like to replace with the current values. For example the
contents of a line that I read in may look like this:
Hi there $$info{user} what are you going to do today?
I have this line in some variable say $line. How do I replace the text
$$info{user} with the actual value of $$info{user}? Of cores $info is a
reference to a hash in the running program.
Let me explain the motivation of the problem. Maybe someone will have
a better way to attack the problem. The script that I'm writing
collects information from a database then writes an input text file for
some other program. This text file has a lot of comments and additional
fluff along with lots of key value tags. I would like to have a template
text file that my scripts reads in and just adds the current relevant
information. Also I want a clean solution I do not want to have a
large case structure of replacements.
Thank you for your help.
------------------------------
Date: 28 Oct 2004 00:24:00 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: interpolation question:
Message-Id: <Xns958FC65A4ED8Cebohlmanomsdevcom@130.133.1.4>
c186282 <c186282@yahoo.com> wrote in
news:pan.2004.10.28.00.13.32.830671@yahoo.com:
> I'm reading in a file line by line. Some of the lines have variables
> that I would like to replace with the current values. For example the
> contents of a line that I read in may look like this:
>
> Hi there $$info{user} what are you going to do today?
>
> I have this line in some variable say $line. How do I replace the text
> $$info{user} with the actual value of $$info{user}? Of cores $info is a
> reference to a hash in the running program.
See the first result returned from perldoc -q variable
> Let me explain the motivation of the problem. Maybe someone will have
> a better way to attack the problem. The script that I'm writing
> collects information from a database then writes an input text file for
> some other program. This text file has a lot of comments and additional
> fluff along with lots of key value tags. I would like to have a template
^^^^^^^^
> text file that my scripts reads in and just adds the current relevant
> information. Also I want a clean solution I do not want to have a
> large case structure of replacements.
There are an ungodly number of templating modules out there on CPAN.
Perhaps adapting one of them would make more sense in the long run than
trying to roll your own system (you'd probably get a bunch of extra
functionality for free).
------------------------------
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 7327
***************************************