[22999] in Perl-Users-Digest
Perl-Users Digest, Issue: 5219 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 13 00:07:32 2003
Date: Sat, 12 Jul 2003 21:05:05 -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 Sat, 12 Jul 2003 Volume: 10 Number: 5219
Today's topics:
Re: Big hash question (Tad McClellan)
Re: Big hash question (Tad McClellan)
Re: Check fileage with -M when path contains a point? <usenet@expires082003.tinita.de>
Re: Check fileage with -M when path contains a point? (Tad McClellan)
duplicate removal john62@electronmail.com
Re: duplicate removal (Tad McClellan)
Re: duplicate removal <bwalton@rochester.rr.com>
Re: flock() and W95 <grazz@pobox.com>
Re: html table tag indent script? (Jay Tilton)
Re: p book <newsfilter@bigbold.com>
Re: p book <kona1611@yahoo.com>
Re: p book <nobody@dev.null>
Re: Problem uploading file of large size in Perl/Apache <grazz@pobox.com>
Re: Reading JPEG file <zvone.zagar@siol.net>
Re: Reading JPEG file <zvone.zagar@siol.net>
Re: Standalone Perlscript <usenet@expires082003.tinita.de>
Re: Standalone Perlscript <nobody@dev.null>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 12 Jul 2003 11:57:41 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Big hash question
Message-Id: <slrnbh0fg5.anm.tadmc@magna.augustmail.com>
S. Heiling <newsreadermail@charter.net> wrote:
> "Tie your hash to a file, or use a database rather than a hash."
Who said that?
Please provide an attribution when you quote someone.
Please mark quoted text following Usenet convention, so you don't
confuse people's newsreaders.
> Well this is a rather odd experiment I'm tring.
> And I'm trying to work it from a single script.
You can tie to a file or use a database from a single script.
So what is your _real_ objection to doing one of those things?
> you should show us the code that loads the hash,
> I'm not loading it.
Yes you are.
> It's just there.
What you describe is impossible.
You must be missing some important concept...
> #####################################
> %hash = (
>
> key0 => "very long value.......",
> key1 => "valy long value.......",
>
> );
See? There you are, loading the hash!
> This is quite unconventional, I know,
Why do you think that unconventionalness is required?
What is it that you really want to accomplish?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 12 Jul 2003 12:11:37 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Big hash question
Message-Id: <slrnbh0ga9.anm.tadmc@magna.augustmail.com>
S. Heiling <newsreadermail@charter.net> wrote:
> And I'm trying to work it from a single script.
Perhaps you could just put the data in a __DATA__ section.
> "Don't load the whole hash at startup."
>
> How can I do that?
The post you quoted had code that does that.
I do not see that you even need a hash at all...
> %hash = (
>
> key0 => "very long value.......",
> key1 => "valy long value.......",
>
> );
Remove that code that loads the hash, put the data in __DATA__ instead.
> while ( ($key, $value) = each %hash) {
>
> # The keys are file names or directory paths.
> # The values are the file data unpacked into hex.."H"
>
> }
> I've tried putting the hash after the while statement but still, a long
> wait.
Perl compiles your entire program, so where it is located in the
source code will not matter.
> is there a way?
--------------------------------------
# untested
while ( <DATA> ) {
chomp;
my($key, $value) = split / => /;
# do stuff with only 1 pair at a time in memory
}
__DATA__
key0 => very long value.......
key1 => valy long value.......
--------------------------------------
See the "Scalar value constructors" section in perldata.pod
for info on the DATA filehandle and the __DATA__ token.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Jul 2003 15:39:44 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: Check fileage with -M when path contains a point?
Message-Id: <bepa40$7njkn$2@ID-24002.news.uni-berlin.de>
Math55 wrote:
> hi, i have this program. why cant i check the age of a file with -M?
> ---
> use File::Basename;
> $path="/home/raid/golchert/.cxoffice/dotwine/filelist.dat";
> #$path="/home/raid/golchert/Downloads/CD Control QE 1.0.1.12.exe";
add here:
print -M $path;
> chdir (dirname($path));
why do you do a chdir() if you only want to check the age?
but see my answer in d.c.l.p.m.
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/ \ \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -
------------------------------
Date: Sat, 12 Jul 2003 11:47:32 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Check fileage with -M when path contains a point?
Message-Id: <slrnbh0et4.anm.tadmc@magna.augustmail.com>
Math55 <magelord@t-online.de> wrote:
> why cant i check the age of a file with -M?
Because the file is not where you think it is.
It is someplace else.
> ---
> use File::Basename;
> $path="/home/raid/golchert/.cxoffice/dotwine/filelist.dat";
> #$path="/home/raid/golchert/Downloads/CD Control QE 1.0.1.12.exe";
>
> chdir (dirname($path));
What if that fails?
You should check to see if you actually got what you asked for:
chdir(dirname $path) or die "could not chdir() $!";
> $relFile= (fileparse($path));
> $rf.="/".$relFile;
/filelist.dat
and
/home/raid/golchert/.cxoffice/dotwine/filelist.dat
are (probably) not the same file.
The 1st one likely does not exist (and that is the one you are looking at).
> print "\n age of $path = ".(-M $rf). "\n" if (-M $rf <=100 && !(-d
> $rf));
>
> ---
>
> maybe you have to change to a pth that contains a point at your
> system.
Huh?
You cannot "change to a path". What did you mean there?
Did you mean "change to a directory" instead?
You are not required to do anything to your cwd in order to do
a filetest such as -M, so why are you (attempting to) change
your cwd?
> i tried with absolute and relative path,
Show us what you have tried.
The code you've shown does not attempt to use a relative path, and
the absolute path that it tries is not the correct absolute path.
> both did not
> work:-(...
Then fix them.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Jul 2003 19:59:50 -0500
From: john62@electronmail.com
Subject: duplicate removal
Message-Id: <3f10af06_2@127.0.0.1>
ok, this is probably another easy question. does anyone
know how to remove duplicates in a list of strings?
basically, i have a list of newsgroup message subjects.
sometimes people accidentally post twice, so i need to
remove the dups.
thx
--------------------------------------------------------------------
For free web access to newsgroups, please visit
http://www.coldmail.us/. Thanks
--------------------------------------------------------------------
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
------------------------------
Date: Sat, 12 Jul 2003 20:40:34 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: duplicate removal
Message-Id: <slrnbh1e4i.cqq.tadmc@magna.augustmail.com>
john62@electronmail.com <john62@electronmail.com> wrote:
> ok, this is probably another easy question.
Common questions are grouped together, along with answers, in
a document called a FAQ (Frequently Asked Questions).
It is considered good manners to check the FAQ *before* posting
to the newsgroup.
> does anyone
> know how to remove duplicates in a list of strings?
perldoc -q duplicate
"How can I remove duplicate elements from a list or array?"
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 13 Jul 2003 01:46:23 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: duplicate removal
Message-Id: <3F10B9ED.5030307@rochester.rr.com>
john62@electronmail.com wrote:
> ok, this is probably another easy question. does anyone
> know how to remove duplicates in a list of strings?
This is a FAQ:
perldoc -q dupicate
--
Bob Walton
------------------------------
Date: Sat, 12 Jul 2003 21:55:06 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: flock() and W95
Message-Id: <_s%Pa.4365$Y92.4264@nwrdny01.gnilink.net>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Steve Grazzini wrote:
> >>Also sprach Gunnar Hjalmarsson:
> >>>For this to work, it seems as if you need to pass the filehandles
> >>>with typeglobs:
> >>>
> >>> flock *FH, LOCK_EX;
> >
> > The "*" prototype is pretty lame -- it lets you use the bareword,
> > but it doesn't convert it into a glob reference. In order to mimic
> > the builtin "*" prototype I think you'd need something like this:
>
> So it is possible. :) Thanks, I'll consider it. Or maybe that would
> be to overdo it; needing to use the typeglobe in the filehandle
> argument isn't that inconvenient.
If you're not trying to imitate the built-in flock() maybe you should
call your function safe_flock() or something unambiguous... and if you
are trying to imitate it then you need to handle bareword-filehandles.
Anyway, I noticed this cleaner alternative in perlsub (and I think you
were reinventing 'use subs' as well :-) so -->
use Symbol qw(qualify_to_ref);
use subs qw(flock);
sub flock (*$) {
my $fh = qualify_to_ref(shift, caller);
my $ret = eval { CORE::flock($fh, shift) };
if ($@) {
require Carp;
Carp::carp($@);
}
return $ret;
}
--
Steve
------------------------------
Date: Sun, 13 Jul 2003 01:51:40 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: html table tag indent script?
Message-Id: <3f10bb07.93458568@news.erols.com>
"Andrew" <tech7890@yahoo.com> wrote:
: Does anyone know of a perl script I may download or have a perl script of
: your own that lines up html table tags through indentation?
The code in Synopsis section of the HTML::PrettyPrinter pod is a
pretty good foundation. Season to taste with the set_nl_before() and
set_nl_after() methods, and voila.
Here's the one I've been using for some time now. Not bulletproof,
but it whips most HTML samples into reasonable shape.
#!perl
use warnings;
use strict;
use HTML::TreeBuilder;
use HTML::PrettyPrinter;
use File::Slurp qw(write_file);
die "Usage: $0 file1 [file2 file3 ...]\n"
unless @ARGV;
for(@ARGV) {
print "$_ : reading...";
my $html = pretty( tree($_) );
# Backup original file. No check on whether file exists
# already or if rename succeeds. Use at your own risk.
rename $_, "$_.bak";
print "writing...";
write_file( $_, $html );
print "done.\n";
}
sub tree {
my($filename) = @_;
my $tree = HTML::TreeBuilder->new(
store_comments => 1,
warn => 1,
);
$tree->parse_file($filename);
return $tree;
}
sub pretty {
# tags that get newlines before & after
my @nl_before_after = qw(
h1 h2 h3 h4 h5
dl dd dt
table td th tr
ul li ol
body html p div style img map
);
# tags that get newline before
my @nl_before = qw( a head link meta title script br );
# tags that get newline after
my @nl_after = qw( );
my($tree) = @_;
my $hpp = HTML::PrettyPrinter->new(
tabify => 0,
linelength => 1e6,
quote_attr => 1,
allow_forced_nl => 1,
);
# Screw any defaults. I want it my way.
$hpp->set_nl_before(0, 'all!');
$hpp->set_nl_after(0, 'all!');
$hpp->set_force_nl(1, qw / br /);
$hpp->set_nl_before(1, @nl_before_after, @nl_before);
$hpp->set_nl_after(1, @nl_before_after, @nl_after);
local $" = '';
return "@{ $hpp->format($tree) }";
}
------------------------------
Date: Sat, 12 Jul 2003 19:25:52 +0100
From: "Peter C Cooper" <newsfilter@bigbold.com>
Subject: Re: p book
Message-Id: <bepjsq$7uans$1@ID-194358.news.uni-berlin.de>
> ok, i am going to get a perl book, but i don't know which
> one is good. i've been dabbling in perl a bit, but i'm
> still pretty bad at it. any recommendations for a
> beginner book?
"Perl 5 Interactive Course" from Waite is a good choice, as it goes through
in a tutorial/step-by-step way. It also runs to about 1000 pages, and serves
as a good reference book too. It's particularly good for learning about
regular expressions, as unlike regular Perl documentation, it goes through
each modifier and each nuance step by step with examples, rather than
dumping you with 101 options and no examples.
That all said, my copy was published in 1996, when I started to learn Perl,
and may not even be published anymore <g>
Pete
------------------------------
Date: Sat, 12 Jul 2003 21:07:21 GMT
From: "Charles Evans" <kona1611@yahoo.com>
Subject: Re: p book
Message-Id: <dM_Pa.81556$X43.27793@clmboh1-nws5.columbus.rr.com>
I have had this book for several years and am finally going through it.
Unfortunately I have never
seen a book with more typos than this one? I'm having as much fun catching
them all as the book
itself. Although it is dead wrong in the first few chapters speaking of
"array context".. which there
is no such thing, rather "list context", figures misnumbered, all kinda
stuff!
I wish there was an errata page somewhere. And to think the author, Orwant,
is a co-author of the
Camel. I guess perl has changed quite a bit since then. Pete.. if you want,
I can send you the
errata I have found..
Charles Evans
kona1611@yahoo.com
"Peter C Cooper" <newsfilter@bigbold.com> wrote in message
news:bepjsq$7uans$1@ID-194358.news.uni-berlin.de...
> > ok, i am going to get a perl book, but i don't know which
> > one is good. i've been dabbling in perl a bit, but i'm
> > still pretty bad at it. any recommendations for a
> > beginner book?
>
> "Perl 5 Interactive Course" from Waite is a good choice, as it goes
through
> in a tutorial/step-by-step way. It also runs to about 1000 pages, and
serves
> as a good reference book too. It's particularly good for learning about
> regular expressions, as unlike regular Perl documentation, it goes through
> each modifier and each nuance step by step with examples, rather than
> dumping you with 101 options and no examples.
>
> That all said, my copy was published in 1996, when I started to learn
Perl,
> and may not even be published anymore <g>
>
> Pete
>
>
------------------------------
Date: Sun, 13 Jul 2003 00:52:06 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: p book
Message-Id: <3F10AC96.5050901@dev.null>
john62@electronmail.com wrote:
> ok, i am going to get a perl book, but i don't know which
> one is good. i've been dabbling in perl a bit, but i'm
> still pretty bad at it. any recommendations for a
> beginner book?
After getting a rudimentary introduction to Perl, I have found the Perl
Cookbook to be immensly useful because it is problem-oriented. Again and
again I found myself having a problem and then finding it, or something
similar, listed, solved and discussed in the Cookbook.
One drawback is that it doesn't give you a coherent background in how
Perl works, so I find myself opening Programming Perl more and more
often in order to look up the details on some aspect of the language.
------------------------------
Date: Sat, 12 Jul 2003 15:55:30 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Problem uploading file of large size in Perl/Apache/Linux
Message-Id: <SbWPa.7500$Kw1.5802@nwrdny02.gnilink.net>
Paresh Shah <pareshrshah@yahoo.com> wrote:
> I have one perl script which upload file to server, using
> Apache as http server & Redhat Linux as OS.
> Till 11th july, 2003 everything was working fine & suddenly
> from 12th july i.e. today it started giveing problems. I can
> upload file with size < 100K, but other files > 100K are not
> being uploaded. It timeouts.....
Look up "$CGI::POST_MAX" in the CGI manpage:
% perldoc CGI
This might not be what's happened, but it seems as likely as
anything. (And consider that if you unset that variable you
could be risking the wrath of whichever admin has recently
turned it on.)
--
Steve
------------------------------
Date: Sun, 13 Jul 2003 00:31:06 +0200
From: Zvone Zagar <zvone.zagar@siol.net>
Subject: Re: Reading JPEG file
Message-Id: <Y%%Pa.214$2B6.42364@news.siol.net>
--nextPart23003661.096oN6nZQv
Content-Type: text/plain; charset=iso-8859-2
Content-Transfer-Encoding: 8Bit
A. Sinan Unur wrote:
> Zvone Zagar <zvone.zagar@siol.net> wrote in
> news:HnIOa.101$2B6.20527@news.siol.net:
>
>> Hello!
>> I made very rudimentary perl script which produces postcript file.
>> Temporary link is http://freeweb.siol.net/an511zvo
>> It not quite what I imagined,but it works. At least for JPEG files.
>> It may encourage somebody to make a better one.
>
> A few comments:
>
> * I had not realized that ImageMagick also had a text format. IMHO, it is
> not the output format you want because it creates a lot of extra work for
> you.
>
> * I am still not clear on the output format you want. I looked at the
> sample PS image (raptor2.ps) but it does not have the contents of the
> $dcp, $dci, and $dc variables.
>
> * Speaking of those, you should probably output those using "here docs"
> rather than defining multiline strings.
>
> * Using raptor2.ps as a guide, I put together a short script that might
> be helpful. However, I have not been able to test it because I haven't
> been able to install PerlMagick on my XP or FreeBSD boxes. Also, I am not
> sure what the third value (8) in
>
> %!
> 250 80 8 matrix {
>
> at the top of raptor2.ps file.
>
> That said, here is my attempt at the script:
>
> #! /usr/bin/perl
> # WARNING: Completely untested
>
> use strict;
> use warnings;
>
> use Image::Magick;
>
> my $chunk_size = 33;
>
> foreach my $img_file (@ARGV) {
> my $rgb_file = "$img_file.rgb";
> my $image = Image::Magick->new;
> $image->Read($img_file);
> $image->Write($rgb_file);
>
> my $ps_file = "$img_file.ps";
> open(PS, "> $ps_file") || die "Cannot open $ps_file: $!\n";
>
> my $width = $image->Get('columns');
> my $height = $image->Get('rows');
> print PS "%!\n$width $height 8 matrix {<\n";
>
> undef $image;
>
> open(RGB, "< $rgb_file") || die "Cannot open $rgb_file: $!\n";
> binmode RGB;
>
> my $chunk;
> while(read(RGB, $chunk, $chunk_size)) {
> foreach my $octet (split //, $chunk) {
> printf(PS "%2.2X", ord($octet));
> }
> print(PS "\n");
> }
>
> print PS ">\n} false 3 colorimage\nshowpage\n";
> close(PS);
> close(RGB);
> }
>
> HTH.
>
> Sinan.
Hello!
First, thanks for your script. It works. But I must change the postscript
code. There seems to be much I don't understand yet. I started with the
sample PostScript output Tk::Canvas creates. It is close to that what is
described in PostScript Blue Book (Tutorial and Cookbook). If you are
interested in, there is a link:
http://www.geocities.com/SilliconValley/5682/postscript.html (mind caps in
SilliconValley).
Then I looked in PostScript Language Reference Manual (Red Book). Online
version can be viewed at the same URL, mentioned above. So I changed the ps
syntax to match the one in Red Book. If you compare the ps code in sample
'raptor2.ps' and the code in ps file 'raptor.jpg.ps' I will post at
http://freeweb.siol.net/an511zvo you will see the differences.
The first thing that makes me confused is the height value. In raptor2.ps is
80, but ImageMagick says it is 170. I compared the value with the output of
Image::Info module. It gives also 170. As I speak of values, the 8 in ps
code represents bits per sample (1,2,4,8 or 12).
If I summarize, we have a working example with different PostScript syntax.
Maybe someday I will discover how code in sample raptor2.ps works.
With the altered perl script I can achieve my purpose. PostScript code must
also be altered to display non color images.
Ok, enough talking, here is your script with changed PostScript code:
#!/usr/bin/perl
use Image::Magick;
my($str,$temp);
my($bps,$ps,$font);
#---Postscript ----
$ps = <<EOF;
{ currentfile
picstr readhexstring pop
} false 3 colorimage
EOF
$font = <<FONT;
/Helvetica findfont 40 scalefont setfont
FONT
#----------
my $chunk_size = 33; #??
foreach my $img_file (@ARGV) {
$temp = "";
my $rgb_file = "$img_file.rgb";
my $image = Image::Magick->new;
$image->Read($img_file);
$image->Write($rgb_file);
my $ps_file = "$img_file.ps";
open(PS, "> $ps_file") || die "Cannot open $ps_file: $!\n";
my $width = $image->Get('columns');
my $height = $image->Get('rows');
$bps = 8; #bits per sample -
$str = "%!\n";
undef $image;
open(RGB, "< $rgb_file") || die "Cannot open $rgb_file: $!\n";
binmode RGB;
my $chunk;
while(read(RGB, $chunk, $chunk_size)) {
foreach my $octet (split //, $chunk) {
$temp .= sprintf("%2.2X", ord($octet));
}
$temp .= "\n";
}
# - Postscript code -
my $len = $width * 3;
$str .= "/picstr $len string def\n";
my $pos = $height + 30;
$str .= "$font" . "0 $pos moveto\n" . "($img_file) show\n";
$str .= "$width $height scale \n";
$str .= "$width $height $bps ";
$str .= "[ $width 0 0 -$height 0 $height ]\n" . $ps . $temp;
$str .= "\nshowpage\n";
print PS $str;
close(PS);
close(RGB);
}
exit;
At the end I would like to thank You had enough patience with me.
Zvone Z.
--nextPart23003661.096oN6nZQv
Content-Type: application/x-perl; name="cnv3.pl"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="cnv3.pl"
IyEvdXNyL2Jpbi9wZXJsCgp1c2UgSW1hZ2U6Ok1hZ2ljazsKCm15KCRzdHIsJHRlbXApOwpteSgk
YnBzLCRwcywkZm9udCk7CgoKIy0tLVBvc3RzY3JpcHQgLS0tLQokcHMgPSA8PEVPRjsgCnsgY3Vy
cmVudGZpbGUgCiAgcGljc3RyIHJlYWRoZXhzdHJpbmcgcG9wCn0gZmFsc2UgMyBjb2xvcmltYWdl
CkVPRgoKJGZvbnQgPSA8PEZPTlQ7Ci9IZWx2ZXRpY2EgZmluZGZvbnQgNDAgc2NhbGVmb250IHNl
dGZvbnQKRk9OVAojLS0tLS0tLS0tLQoKbXkgJGNodW5rX3NpemUgPSAzMzsJCSM/PwoKZm9yZWFj
aCBteSAkaW1nX2ZpbGUgKEBBUkdWKSB7CgkkdGVtcCA9ICIiOwogICAgICAgIG15ICRyZ2JfZmls
ZSA9ICIkaW1nX2ZpbGUucmdiIjsKICAgICAgICBteSAkaW1hZ2UgPSBJbWFnZTo6TWFnaWNrLT5u
ZXc7CiAgICAgICAgJGltYWdlLT5SZWFkKCRpbWdfZmlsZSk7CiAgICAgICAgJGltYWdlLT5Xcml0
ZSgkcmdiX2ZpbGUpOwoKICAgICAgICBteSAkcHNfZmlsZSA9ICIkaW1nX2ZpbGUucHMiOwogICAg
ICAgIG9wZW4oUFMsICI+ICRwc19maWxlIikgfHwgZGllICJDYW5ub3Qgb3BlbiAkcHNfZmlsZTog
JCFcbiI7CgogICAgICAgIG15ICR3aWR0aCA9ICRpbWFnZS0+R2V0KCdjb2x1bW5zJyk7CiAgICAg
ICAgbXkgJGhlaWdodCA9ICRpbWFnZS0+R2V0KCdyb3dzJyk7CgkkYnBzID0gODsJCSNiaXRzIHBl
ciBzYW1wbGUgLSAKCSRzdHIgPSAiJSFcbiI7CQkKICAgICAgICB1bmRlZiAkaW1hZ2U7CgogICAg
ICAgIG9wZW4oUkdCLCAiPCAkcmdiX2ZpbGUiKSB8fCBkaWUgIkNhbm5vdCBvcGVuICRyZ2JfZmls
ZTogJCFcbiI7CiAgICAgICAgYmlubW9kZSBSR0I7CgogICAgICAgIG15ICRjaHVuazsKICAgICAg
ICB3aGlsZShyZWFkKFJHQiwgJGNodW5rLCAkY2h1bmtfc2l6ZSkpIHsKICAgICAgICAgICAgICAg
IGZvcmVhY2ggbXkgJG9jdGV0IChzcGxpdCAvLywgJGNodW5rKSB7CiAgICAgICAgICAgICAgICAg
ICAgICAkdGVtcCAuPSAgc3ByaW50ZigiJTIuMlgiLCBvcmQoJG9jdGV0KSk7CiAgICAgICAgICAg
ICAgICB9CiAgICAgICAgICAgICAgICAkdGVtcCAuPSAiXG4iOwkJCQkgICAgICAgCiAgICAgICAg
fQoJIyAtIFBvc3RzY3JpcHQgY29kZSAtCiAgICAgICAgbXkgJGxlbiA9ICR3aWR0aCAqIDM7CiAg
ICAgICAgJHN0ciAuPSAiL3BpY3N0ciAkbGVuIHN0cmluZyBkZWZcbiI7CglteSAkcG9zID0gJGhl
aWdodCArIDMwOwoJJHN0ciAuPSAiJGZvbnQiIC4gIjAgJHBvcyBtb3ZldG9cbiIgLiAiKCRpbWdf
ZmlsZSkgc2hvd1xuIjsKCSRzdHIgLj0gIiR3aWR0aCAkaGVpZ2h0IHNjYWxlIFxuIjsKCSRzdHIg
Lj0gIiR3aWR0aCAkaGVpZ2h0ICRicHMgIjsKCSRzdHIgLj0gIlsgJHdpZHRoIDAgMCAtJGhlaWdo
dCAwICRoZWlnaHQgXVxuIiAuICRwcyAuICR0ZW1wOwoJJHN0ciAuPSAiXG5zaG93cGFnZVxuIjsK
ICAgICAgICBwcmludCBQUyAkc3RyOwogICAgICAgIGNsb3NlKFBTKTsKICAgICAgICBjbG9zZShS
R0IpOwp9CgpleGl0OwoK
--nextPart23003661.096oN6nZQv--
------------------------------
Date: Sun, 13 Jul 2003 00:48:22 +0200
From: Zvone Zagar <zvone.zagar@siol.net>
Subject: Re: Reading JPEG file
Message-Id: <8g0Qa.216$2B6.42604@news.siol.net>
A. Sinan Unur wrote:
> Zvone Zagar <zvone.zagar@siol.net> wrote in
> news:HnIOa.101$2B6.20527@news.siol.net:
>
>> Hello!
>> I made very rudimentary perl script which produces postcript file.
>> Temporary link is http://freeweb.siol.net/an511zvo
>> It not quite what I imagined,but it works. At least for JPEG files.
>> It may encourage somebody to make a better one.
>
> A few comments:
>
> * I had not realized that ImageMagick also had a text format. IMHO, it is
> not the output format you want because it creates a lot of extra work for
> you.
>
> * I am still not clear on the output format you want. I looked at the
> sample PS image (raptor2.ps) but it does not have the contents of the
> $dcp, $dci, and $dc variables.
>
> * Speaking of those, you should probably output those using "here docs"
> rather than defining multiline strings.
>
> * Using raptor2.ps as a guide, I put together a short script that might
> be helpful. However, I have not been able to test it because I haven't
> been able to install PerlMagick on my XP or FreeBSD boxes. Also, I am not
> sure what the third value (8) in
>
> %!
> 250 80 8 matrix {
>
> at the top of raptor2.ps file.
>
> That said, here is my attempt at the script:
>
> #! /usr/bin/perl
> # WARNING: Completely untested
>
> use strict;
> use warnings;
>
> use Image::Magick;
>
> my $chunk_size = 33;
>
> foreach my $img_file (@ARGV) {
> my $rgb_file = "$img_file.rgb";
> my $image = Image::Magick->new;
> $image->Read($img_file);
> $image->Write($rgb_file);
>
> my $ps_file = "$img_file.ps";
> open(PS, "> $ps_file") || die "Cannot open $ps_file: $!\n";
>
> my $width = $image->Get('columns');
> my $height = $image->Get('rows');
> print PS "%!\n$width $height 8 matrix {<\n";
>
> undef $image;
>
> open(RGB, "< $rgb_file") || die "Cannot open $rgb_file: $!\n";
> binmode RGB;
>
> my $chunk;
> while(read(RGB, $chunk, $chunk_size)) {
> foreach my $octet (split //, $chunk) {
> printf(PS "%2.2X", ord($octet));
> }
> print(PS "\n");
> }
>
> print PS ">\n} false 3 colorimage\nshowpage\n";
> close(PS);
> close(RGB);
> }
>
> HTH.
>
> Sinan.
Sorry, the link does not always work.
Try these:
Red book PDF
http://www.adobe.com/print/postscript/pdfs/PLRM.pdf
PS updates
http://partners.adobe.com/asn/developer/technotes.html
Green Book
http://www-cdf.fnal.gov/offline/PostScript/GREENBK.PDF
Blue Book and Sample Code
http://www-cdf.fnal.gov/offline/PostScript/BLUEBOOK.PDF
Thinking in PostScript
http://www.rightbrain.com/download/books/ThinkingInPostScript.pdf
Reference for Ghostscript operators (webpage)
http://www.colorado.edu/ITS/docs/scientific/gs/GSO.html
------------------------------
Date: 12 Jul 2003 15:33:57 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: Standalone Perlscript
Message-Id: <bep9p5$7njkn$1@ID-24002.news.uni-berlin.de>
William Hymen wrote:
> I have a perl script which I would like
> to run 'standalone'.
you might want to have a look at the PAR-module and the
pp-script:
http://search.cpan.org/author/AUTRIJUS/PAR-0.69/
hth, tina
(i actually like the orange cpan...)
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/ \ \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -
------------------------------
Date: Sun, 13 Jul 2003 00:44:57 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Standalone Perlscript
Message-Id: <3F10AAEA.3070409@dev.null>
William Hymen wrote:
> I have a perl script which I would like
> to run 'standalone'. In other words, I ONLY want
> to have gnu perl.exe available, and nothing more.
> I am not permitted to install perl in a production
> environment on NT or W2K here at work.
>
Consider finding another job :-)
------------------------------
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 5219
***************************************