[17318] in Perl-Users-Digest
Perl-Users Digest, Issue: 4740 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 27 06:05:31 2000
Date: Fri, 27 Oct 2000 03:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972641111-v9-i4740@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 27 Oct 2000 Volume: 9 Number: 4740
Today's topics:
Re: #perl on EFnet (Randal L. Schwartz)
Re: another perl syntax question. <gellyfish@gellyfish.com>
array and condition too strange problem <mexlhr@yahoo.com>
Re: Clean POST strings <gellyfish@gellyfish.com>
comment on my bandwidth throttling code <elijah@workspot.net>
Re: emulating flock (Mark-Jason Dominus)
First steps <fraser.chalmers@ncl.ac.uk>
Re: First steps (Bernard El-Hagin)
Re: First steps <xerxes_2k@my-deja.com>
Re: How can I word wrap on STDOUT? (Chris Fedde)
Re: How can I word wrap on STDOUT? <gellyfish@gellyfish.com>
Re: How to output to printer <ra_jones@my-deja.com>
Re: How to output to printer <gellyfish@gellyfish.com>
Re: How to output to printer <josef.moellers@fujitsu-siemens.com>
Re: in an eval, redirect STDOUT to a variable <ianb@ot.com.au>
Re: jpeg image manipulation (Mark-Jason Dominus)
Re: jpeg image manipulation (Martien Verbruggen)
Re: jpeg image manipulation (Mark-Jason Dominus)
Re: jpeg image manipulation (Martien Verbruggen)
Re: jpeg image manipulation <gellyfish@gellyfish.com>
Re: Legal email addresses... (Sean McAfee)
Linked lists (Mark-Jason Dominus)
Re: Linked lists (Bernard El-Hagin)
Re: log in on a UNIX machine <gellyfish@gellyfish.com>
Matching and removing multiline block in perl 1-liner <jak@framfab.dk>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 Oct 2000 00:24:11 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: #perl on EFnet
Message-Id: <m1zojqiw6c.fsf@halfdome.holdit.com>
>>>>> "Mike" == Mike Wescott <wescott@conterra.com> writes:
Mike> It seems that #perl on EFnet has become "invite only". Why is that?
Mike> Not that I was a very frequent lurker, but on occasion it could
Mike> be instructive.
With the instability of EFNet has come many oppportunities for the
sk1rpt k1ddi3s to take over the channel, and they take great pride in
doing so. No takeover has lasted longer than 48 hours that I recall,
and as I type this, #perl has been retaken by the normal dudes.
But this will probably happen again... no need to trouble CLPM about
#perl... different realms anyway. :)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 27 Oct 2000 07:47:57 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: another perl syntax question.
Message-Id: <8tb8et$jli$1@orpheus.gellyfish.com>
In comp.lang.perl.misc Hugo Bouckaert <hugo@fractalgraphics.com.au> wrote:
> Hi All
>
> What does .= refer to? I have lines in a perl script like:
>
> $query .= "\t$lead $field = $emailid\n";
>
> where I think $query is a query to a mysql database.
>
> The most important thing I would like to know is what ".=" stands for.
> None of my reference books list it as an operator or as anything else.
>
I would get a better reference book if this really isnt to be found.
The description of 'Assignment Operators', for this is one of they, can
be found in the perlop manpage. In essence it boils down to some operator
with an '=' after it performs the operation with the LHS value as one
operand and the RHS value as the other and then stores it in the left one.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Fri, 27 Oct 2000 06:11:43 GMT
From: rob loz <mexlhr@yahoo.com>
Subject: array and condition too strange problem
Message-Id: <8tb6at$uce$1@nnrp1.deja.com>
Ok given the following code: I'm trying to validate that the values set
on cookies still exist on the database
sub come_galletas { #read cookies using CGI.pm
my $cid = $q->cookie('cid');
my $pid = $q->cookie('pais_id');
my @cook = ($cid,$pid);
return @cook;
}
----------------------------
my @galletas = &come_galletas;
my $qsector = $galletas[0];
my $qpais = $galletas[1];
$ambos=0;
-------------------------
if ( $qpais && $qsector ) { #cookies exist
print qq{$qpais:I:$qsector<br>}; #debug output
$sth = $db->exec_sql(<<EOF);
select zona_id from zonas where zona_id = $galletas[1]
union
select categoria_id from
categorias where categoria_id = $galletas[0]
EOF
return '' unless $sth;
}
while ($row = $sth->fetch) {
($qp,$qcid) = @$row;
if ($qp == $galletas[1] and $qcid == $galletas[0]) { #doesn't get
into the if I don't know why!
$ambos=1;
last;
}
print qq{qp=$galletas[1]:X:qcid=$galletas[0]<br>}; #I actually get
to print the correct values but the if is not working, what am I
doing wrong? Can someone clarify me on this?
}
if ($ambos == 1) {
print qq{$qpais:A:$qsector};
exit;
}
else {
print qq|$qpais:E:$qsector|;
my $zonas = &print_zonas(); #I always end up here on the else :(
}
thanks rob
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 27 Oct 2000 06:57:13 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Clean POST strings
Message-Id: <8tb5fp$jh9$1@orpheus.gellyfish.com>
On Thu, 26 Oct 2000 22:58:02 +0800 Fraser wrote:
> Hi
> Trying to tidy up a Query_string from a POST method in a HTML page. Doe
> any one know how to do this. To remove all the escape characters that
> are added to the posted string, to do operations on.
>
If I understand you correctly I think you simply want to use the
module CGI which comes with the standard perl distribution.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: 25 Oct 2000 20:42:29 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: comment on my bandwidth throttling code
Message-Id: <eli$0010251618@qz.little-neck.ny.us>
Looking for 'throttle' at search.cpan.org doesn't turn up much,
just some Apache stuff and I don't care about throttling web
traffic.
I've got at socket cat program, scat, a little like netcat but
simpler in that it does not try to do two connections. For a
while now I've wanted to put some bandwidth throughput restrictions
on it, sort of like a 'nice' for my network.
scat has two modes: cat from a socket and cat to a socket.
Here's the code for each direction.
------CUT HERE-----
if ($dir == IN) {
# If rate is defined, we are in throttle mode
if ($rate) {
$starttime = &Time::HiRes::time;
$secmoved = 0;
}
while(sysread(Client, $_, 1024)) {
$moved += length($_);
if ($rate) {
$secmoved += length($_);
$difftime = &Time::HiRes::time - $starttime;
if ($secmoved >= $rate) {
$sleep = 1 - $difftime;
if ($sleep > 0) {
&Time::HiRes::sleep($sleep);
}
$starttime = &Time::HiRes::time;
$secmoved = 0;
}
}
print;
}
} else {
if (!@ARGV) {
unshift(@ARGV, '-');
}
# If rate is defined, we are in throttle mode
if ($rate) {
$starttime = &Time::HiRes::time;
$secmoved = 0;
}
for $file (@ARGV) {
if ($file eq '-') {
if (!open(IN,'< -')) {
warn "Can't open stdin: $!\n";
next;
}
} else {
if (!sysopen(IN,$file,O_RDONLY)) {
warn "Can't open $file: $!\n";
next;
}
}
while(sysread(IN, $_, 1024)) {
my $len = length($_);
my $rc = syswrite(Client, $_, $len);
if ($rate) {
$secmoved += $rc;
$difftime = &Time::HiRes::time - $starttime;
if ($secmoved >= $rate) {
$sleep = 1 - $difftime;
if ($sleep > 0) {
&Time::HiRes::sleep($sleep);
}
$starttime = &Time::HiRes::time;
$secmoved = 0;
}
}
if ($rc != $len) {
my $connect;
if (defined($host)) {
$connect = "$host:$port";
} else {
$connect = $port;
}
warn "write to $connect was short ($rc != $len)\n";
$moved += $rc;
} else {
$moved += $len;
}
} # while IN
close IN;
} # for $file
} # if/else for $dir
------CUT HERE-----
Does this seem a reasonable way to implement throttling? I notice
that if I throttle the receiving side but not the sending, stuff
still gets sent very fast and buffering somewhere holds it untill
the reader gets to it. Where is that buffering occuring? The
kernel, perl, ??? (Platform is linux, connections are to localhost.)
Elijah
------
is there interest in scat being uploaded to the CPAN scripts section?
------------------------------
Date: Fri, 27 Oct 2000 04:27:03 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: emulating flock
Message-Id: <39f90416.11c5$2ca@news.op.net>
Keywords: Fuji, Po, roundabout, schooner
In article <m1itqfms5j.fsf@halfdome.holdit.com>,
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>It has to be an operating system primitive that says "this is an
>atomic test-and-set operation". There are durn few of those. :)
'unlink' works under some conditions:
# lock(number of tries, sleep time, lockfile name);
# returns true on success, false on failure
sub lock {
my ($tries, $zzzz, $LOCKFILE) = @_;
while ($tries--) {
return 1 if unlink $LOCKFILE;
if ($! !~ /no such file/i) {
die "Couldn't lock $LOCKFILE: $!";
}
sleep $zzzz;
}
return 0;
}
sub unlock {
my ($LOCKFILE) = @_;
' local *DUMMY;
open DUMMY, "> $LOCKFILE"
or die "Couldn't unlock $LOCKFILE: $!";
return 1;
}
I think this works on windows sytems when the $LOCKFILE is on a local
filesystem, and I know it works on Unix systems ditto. However, it
does not always work under NFS, and it may not work on other
distributed filesystems.
------------------------------
Date: Fri, 27 Oct 2000 10:20:10 +0100
From: Fraser Chalmers <fraser.chalmers@ncl.ac.uk>
Subject: First steps
Message-Id: <8tbhcd$11i$1@ucsnew1.ncl.ac.uk>
Just getting into forms processing and have hit a wall! When submitting a
form with data in, all the browser does is offer to download the perl script
mentioned in the action tag. Nothing gets as far as the script itself,
which basically just sets the query_string to a variable and prints out (but
of course doesn't). Got a feeling I'm missing something crucial but dunno
what...
Any help appreciated,
Fraser
------------------------------
Date: 27 Oct 2000 09:33:56 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: First steps
Message-Id: <slrn8vij3c.28m.bernard.el-hagin@gdndev25.lido-tech>
On Fri, 27 Oct 2000 10:20:10 +0100, Fraser Chalmers
<fraser.chalmers@ncl.ac.uk> wrote:
>Just getting into forms processing and have hit a wall! When submitting a
>form with data in, all the browser does is offer to download the perl script
>mentioned in the action tag. Nothing gets as far as the script itself,
>which basically just sets the query_string to a variable and prints out (but
>of course doesn't). Got a feeling I'm missing something crucial but dunno
>what...
This has nothing whatsoever to do with Perl thus is not appropriate to
this newsgroup.
Cheers,
Bernard
--
perl -le'
($B,$e,$r,$n,$a,$r,$d)=q=$B$e$r$n$a$r$d==~m;
\$(.);xg;print$B.$e.$r.$n.$a.$r.$d;'
------------------------------
Date: Fri, 27 Oct 2000 09:53:37 GMT
From: arse <xerxes_2k@my-deja.com>
Subject: Re: First steps
Message-Id: <8tbjb0$8ju$1@nnrp1.deja.com>
do you have ~!/usr/bin/perl -w
on the first line.
if it is on a unix server, you might want to make sure u havent saved it
in ms-dos format.
--
[][][]{}{}~~';:.<<//?|1¬!"£$$%^^&*(())__+/*+
oooh random characters i must be coool!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 27 Oct 2000 04:11:10 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: How can I word wrap on STDOUT?
Message-Id: <yf7K5.187$7rc.171289088@news.frii.net>
In article <39f8e3dd$1@cs.colorado.edu>,
Tom Christiansen <tchrist@perl.com> wrote:
>In article <ZO2K5.176$7rc.170585600@news.frii.net>,
>Chris Fedde <cfedde@fedde.littleton.co.us> wrote:
>>In article <39f86ff2@cs.colorado.edu>, Tom Christiansen
>><tchrist@perl.com> wrote:
>>>
>>>And the visual appeal of a convenient WYSIWIG layout is not to be
>>>easily discarded, either.
>>>
>>
>>One thing that has always bugged me about formats is that there is
>>no obvious way to format text into a scalar or an array.
>
>Just man perlform and search for "swrite".
>
Right on!
I guess that the last time that I read the manual through was when
it still fit in one file. And I must have skipped that bit when I skimmed
through the page before I opened my mouth above.
I think that it was Sam Clemens that said "Better to keep you mouth closed
and be thought a fool than to open it and remove all doubt." One day I'll
learn :-)
chris
--
This space intentionally left blank
------------------------------
Date: 27 Oct 2000 07:29:58 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How can I word wrap on STDOUT?
Message-Id: <8tb7d6$jjh$1@orpheus.gellyfish.com>
On Thu, 26 Oct 2000 15:46:37 GMT NP wrote:
> merlyn@stonehenge.com wrote:
>
> : Same reason we say "use CGI" instead of "copy and paste from MSA".
>
> And that's a problem, not referring to "use CGI" in particular, but to
> the general "here, 'use blah blah'".
>
Sorry, I fail to understand you I think, are you advocating that we should
tell people to cut and paste crappy, broken code instead of using a piece
of well tested and maintained reusable code in the form of a module?
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Fri, 27 Oct 2000 08:05:19 GMT
From: ra jones <ra_jones@my-deja.com>
Subject: Re: How to output to printer
Message-Id: <8tbcvs$41f$1@nnrp1.deja.com>
Jason,
Sorry, I should have said it was required for an Apache server hosting a
web-site. open OUTPUT, '>LPT1:' does work for my local Windows PC
running Perl, but has no effect if I run it on the Apache web server. Is
there a modification I could use?
In article <MPG.14636b3e144cef2498985d@localhost>,
jason <elephant@squirrelgroup.com> wrote:
> ra jones wrote ..
> >I want to be able to send reports generated by a Perl script to a
> >printer. One way to do this would be to get the script to write to a
> >temporary file, then print it. Is there a system command or
alternative
> >way to output a file's contents to printer rather than screen?
>
> this is system dependant .. but usually for Windows the following will
> work
>
> open OUTPUT, 'LPT1:' or die "Bad open: $!";
> print OUTPUT "What you want printed\n";
>
> --
> jason -- elephant@squirrelgroup.com --
>
--
ra jones (posted via deja.com)
address for e-mail reply:
rajones(at)mail(dot)com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 27 Oct 2000 07:49:59 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to output to printer
Message-Id: <8tb8in$jm1$1@orpheus.gellyfish.com>
On Thu, 26 Oct 2000 11:23:53 +0200 Josef Moellers wrote:
> ra jones wrote:
>>
>> I want to be able to send reports generated by a Perl script to a
>> printer. One way to do this would be to get the script to write to a
>> temporary file, then print it. Is there a system command or alternative
>> way to output a file's contents to printer rather than screen?
>
> Since I only know Linux and other Unix derivates, I can only answer in
> that context: You can pipe the data into the lpr command.
> That simple.
>
Am alternative might be to use the module Net::Printer that performs a
similar function to lpr.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Fri, 27 Oct 2000 11:50:35 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: How to output to printer
Message-Id: <39F94FEB.AFF60DD1@fujitsu-siemens.com>
ra jones wrote:
> =
> Jason,
> =
> Sorry, I should have said it was required for an Apache server hosting =
a
> web-site. open OUTPUT, '>LPT1:' does work for my local Windows PC
> running Perl, but has no effect if I run it on the Apache web server. I=
s
> there a modification I could use?
Where exactly do you want to print? On the server side? In that case,
the mentioned techniques will work (open OUTPUT '>LPT1:', pipe to lpr,
use Net::Printer).
If you want to print on the client side, you should realize that the
Perl script runs on the server side and will produce HTML output. YOu
would need to use something like Javascript to print on the client side.
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
------------------------------
Date: Fri, 27 Oct 2000 16:10:40 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: in an eval, redirect STDOUT to a variable
Message-Id: <39F90E50.86555706@ot.com.au>
Jeff Zucker wrote:
> At the risk of drawing Tom's ire for suggesting a module, try:
I'm sure he keeps a little notebook of transgressors...
When I saw the original post, I immediately thought of tying filhandles.
It's something I've wanted to play with for a while, even though I was
vaguely aware that there was a module to do it for scalars (IO::Scalar,
perhaps?).
So here is my hackish effort, just for the fun of it:
#!/usr/bin/perl -w
{
package ToString;
sub TIEHANDLE
{
my $string;
return bless \$string, shift;
}
sub PRINT
{
my $self = shift;
$$self .= join("", @_);
}
}
$fred = tie (*FH, 'ToString');
print FH "hello ", "there ";
print FH "stranger.";
print "RESULT AFTER SUCCESSIVE PRINTS: $$fred\n";
$$fred = "";
print FH "Works?";
print "RESULT AFTER CLEARING AND PRINTING: $$fred\n";
$old = select FH;
print " Yes it does.\n";
select $old;
print "RESULT AFTER SELECT: $$fred";
__END__
Regards,
Ian
------------------------------
Date: Fri, 27 Oct 2000 04:42:28 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: jpeg image manipulation
Message-Id: <39f907b3.1218$259@news.op.net>
Keywords: Florida, Schlesinger, flora, siesta
In article <8t9aum$d3n$1@nnrp1.deja.com>, <ejehoel@my-deja.com> wrote:
>I'd like to manipulate (jpeg) images using perl. For example to
>generate thumbnails of large images or to increase the
>compression ratio.
I was going to write an article explaining how I like to do it, but I
thought it would probably be quicker to just show the code.
#!/usr/bin/perl
#
# makethumbnails
#
# Program for making thumbnails and thumbnail pages
# Copyright 2000 Mark Dominus
# You may distribute this program under the same terms as
# Perl version 5.6.0.
#
# Requires:
# unix (or unix-like) 'file' command
# 'netpbm' programs (http://netpbm.sourceforge.net/)
# Image::Size module (CPAN)
# djpeg / cjpeg programs (ftp://ftp.uu.net/graphics/jpeg/)
#
# Optional:
# pngtopnm (ftp://ftp.au.netbsd.org/pub/NetBSD/packages/distfiles)
# (only if you want support for PNG format images)
#
# Usage:
# makethumbnails file1 file2 file3...
# makethumbnails *.jpg
# makethumbnails (reads list of filenames from stdin)
#
# makethumbnails -s thumbnail-size -i index-page-name -d thumbnail-image-dir
#
# Defaults: thumbnail-size = 100 pixels
# index-page-name = "index%s.html"
# thumbnail-image-dir = "thumbs%s"
#
# In index-page-name and thumbnail-image-dir, the string '%s' is
# replaced with the thumbnail-size in pixels
#
#
# Obfuscation level: 3/10
#
use Image::Size;
use Getopt::Std;
getopts('s:i:d:') or die "Usage: $0 [-s size] [-i indexpage] [-d dir]\n";
$SIZE = $opt_s || 100;
$INDEX = $opt_i || "index%s.html";
$INDEX =~ s/%s/$SIZE/g;
$THUMBDIR = $opt_d || 'thumbs%s';
$THUMBDIR =~ s/%s/$SIZE/g;
unless (-d $THUMBDIR || mkdir $THUMBDIR, 0777) {
die "Couldn't make thumbnail directory $THUMBDIR: $!\n";
}
tie %URL => URL_Encode;
%progs = ('gif' => 'giftopnm',
'jpg' => 'djpeg',
'jpeg' => 'djpeg',
'pnm' => 'cat',
'ppm' => 'cat',
'pgm' => 'cat',
'pbm' => 'cat',
'png' => 'pngtopnm',
);
open INDEX, "> $INDEX"
or die "Couldn't open index.html for writing: $!; aborting";
unless (@ARGV) {
@ARGV = <STDIN>;
chomp @ARGV;
}
for (sort byfiles @ARGV) {
push @dirs, $_ if -d;
next unless -f;
my ($x, $y) = imgsize($_);
if ($x == 0 || $y == 0) {
print STDERR "Image $_ has zero size; skipping.\n";
next;
}
my ($nx, $ny);
if ($x > $y) {
($nx, $ny) = ($SIZE, int $y*$SIZE/$x);
} else {
($nx, $ny) = (int $x*$SIZE/$y, $SIZE);
}
my ($suf) = (/\.([^.]*$)/);
$suf = filetype($_) unless exists $progs{lc $suf};
unless (defined $suf) {
warn "Couldn't figure out file type for $_; skipping.\n";
next;
}
my $prog = $progs{lc $suf};
my $thumb = thumbname($_);
unless (-e "$THUMBDIR/\Q$thumb") {
system("$prog \Q$_\E | pnmscale -xysize $nx $ny | cjpeg > $THUMBDIR/\Q$thumb\E");
}
print INDEX qq{<a href="$URL{$_}"><img border=0 width=$nx height=$ny src="$URL{$THUMBDIR}/$URL{$thumb}"></a>\n};
print STDERR $_, "\n";
}
for (@dirs) {
print INDEX qq{<br><a href="$URL{$_}">$_</a>\n};
}
# sub thumbname {
# my ($n) = @_;
# my ($suf, $name) = split /\./, reverse $n, 2;
# (reverse $name) . "T.jpg";
# }
sub thumbname { $_[0] }
sub byfiles {
my @a = split /(\d+)/, $a;
my @b = split /(\d+)/, $b;
my $M = @a > @b ? @a : @b;
my $res = 0;
for (my $i = 0; $i < $M; $i++) {
return -1 if ! defined $a[$i];
return 1 if ! defined $b[$i];
if ($a[$i] =~ /\d/) {
$res = $a[$i] <=> $b[$i];
} else {
$res = $a[$i] cmp $b[$i];
}
last if $res;
}
$res;
}
sub filetype {
open TYPE, "file $_[0] |"
or return;
local $_ = <TYPE>;
return 'jpg' if /JPEG/;
return 'gif' if /GIF/;
return 'ppm' if /PPM/;
return 'pgm' if /PGM/;
return 'pbm' if /PBM/;
return;
}
package URL_Encode;
sub TIEHASH { my $x = "dummy"; bless \$x => __PACKAGE__ }
sub FETCH { my ($dummy, $url) = @_;
$url =~ s/([\/\s\%\&\;\?])/'%' . sprintf("%2x", ord($1))/ge;
$url;
}
------------------------------
Date: Fri, 27 Oct 2000 05:11:17 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: jpeg image manipulation
Message-Id: <slrn8vi3ji.ksa.mgjv@verbruggen.comdyn.com.au>
On Fri, 27 Oct 2000 04:42:28 GMT,
Mark-Jason Dominus <mjd@plover.com> wrote:
> In article <8t9aum$d3n$1@nnrp1.deja.com>, <ejehoel@my-deja.com> wrote:
> >I'd like to manipulate (jpeg) images using perl. For example to
> >generate thumbnails of large images or to increase the
> >compression ratio.
>
> I was going to write an article explaining how I like to do it, but I
> thought it would probably be quicker to just show the code.
> %progs = ('gif' => 'giftopnm',
I'd recommend having a look at Image::Magick. It'll really take the
pain out of this sort of thing.
> if ($x > $y) {
> ($nx, $ny) = ($SIZE, int $y*$SIZE/$x);
> } else {
> ($nx, $ny) = (int $x*$SIZE/$y, $SIZE);
> }
and this.
$im->Scale(geometry => "${SIZE}x$SIZE");
> sub filetype {
and this.
$im->Get('magick');
but you really never need to worry about what the current type is.
Martien
--
Martien Verbruggen |
Interactive Media Division | Think of the average person. Half of
Commercial Dynamics Pty. Ltd. | the people out there are dumber.
NSW, Australia |
------------------------------
Date: Fri, 27 Oct 2000 05:59:44 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: jpeg image manipulation
Message-Id: <39f919cf.134d$2da@news.op.net>
Keywords: boomerang, drizzle, goblet, monsieur
In article <slrn8vi3ji.ksa.mgjv@verbruggen.comdyn.com.au>,
Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>> %progs = ('gif' => 'giftopnm',
>
>I'd recommend having a look at Image::Magick. It'll really take the
>pain out of this sort of thing.
But I didn't find it painful. It was pleasant.
Sometimes downloading and installing a new software package is a lot
more painful than writing simple code to use what you already have.
The pbm stuff is already familiar to me, and I use it all the time for
all kinds of things, so it would be stupid to install a big fat
package just to save ten lines of code.
------------------------------
Date: Fri, 27 Oct 2000 18:27:14 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: jpeg image manipulation
Message-Id: <slrn8vibii.c8.mgjv@martien.heliotrope.home>
On Fri, 27 Oct 2000 05:59:44 GMT,
Mark-Jason Dominus <mjd@plover.com> wrote:
> In article <slrn8vi3ji.ksa.mgjv@verbruggen.comdyn.com.au>,
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> >> %progs = ('gif' => 'giftopnm',
> >
> >I'd recommend having a look at Image::Magick. It'll really take the
> >pain out of this sort of thing.
>
> But I didn't find it painful. It was pleasant.
>
> Sometimes downloading and installing a new software package is a lot
> more painful than writing simple code to use what you already have.
> The pbm stuff is already familiar to me, and I use it all the time for
> all kinds of things, so it would be stupid to install a big fat
> package just to save ten lines of code.
Maybe. I am just so used to having ImageMagick installed already that I
just don't see its installation as a problem. I use the command line
tools all the time, especially the viewer. I also use the netpbm tools,
and djpeg and stuff like that, but I generally tend to avoid calls to
external programs.
But YMMV and peoples preferences differ :)
Martien
--
Martien Verbruggen |
Interactive Media Division | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: 27 Oct 2000 07:24:21 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: jpeg image manipulation
Message-Id: <8tb72l$jj5$1@orpheus.gellyfish.com>
On Thu, 26 Oct 2000 13:18:21 GMT ejehoel@my-deja.com wrote:
> I'd like to manipulate (jpeg) images using perl. For example to
> generate thumbnails of large images or to increase the
> compression ratio.
I think you'll find the module Image::Magick is what you want.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Fri, 27 Oct 2000 05:05:17 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Legal email addresses...
Message-Id: <h28K5.8403$O5.180112@news.itd.umich.edu>
In article <39f9b593.25104824@news.ispchannel.com>,
Al <nospamapgraham@ispchannel.com---> wrote:
>On 26 Oct 2000 08:15:14 +0100, Jonathan Stowe
><gellyfish@gellyfish.com> wrote:
>>> I'd like to see Sean try to register
>>> "( system('rm -rf /*'); print("Gotcha!\n") )foo.com"
>>> as a domain name.
>>Read the RFC. foo.com is a perfectly valid domain name - the rest of it
>>is a comment as has been pointed out. This can form part of a perfectly
>>valid e-mail address without having to invoke the URL deux ex machina.
>I re-read the RFC (I actually managed to stay awake) and couln't find
>anything allowing comments in the domain part of an email address.
You must have dozed off then. Section 3.1.4 includes an example of a
valid address with a comment in front of the domain:
Muhammed.(I am the greatest) Ali @(the)Vegas.WBA
The contents of comments being irrelevant to the validity of the address,
this is essentially equivalent to the example I gave.
>Comments ARE allowed in the local part (before the @).
>Please educate my with a more specific ref.
Section 3.4.3, "COMMENTS":
>The comment construct permits message originators to add text which
>will be useful for human readers, but which will be ignored by the
>formal semantics. ^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^
(Emphasis added.) And later:
>When a comment acts as the delimiter between a sequence of two lexical
>symbols, such as two atoms, it is lexically equivalent with a single
>SPACE...
Satisfied?
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
Date: Fri, 27 Oct 2000 06:38:49 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Linked lists
Message-Id: <39f922f8.1434$26b@news.op.net>
Keywords: Colosseum, devotee, pod, splintery
I once said that linked list structures are never useful in Perl, and
that the things they are useful for in other languages are almost
always better-served by arrays.
However, last week I found an exception.
------------------------------
Date: 27 Oct 2000 07:16:01 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Linked lists
Message-Id: <slrn8vib0p.28m.bernard.el-hagin@gdndev25.lido-tech>
On Fri, 27 Oct 2000 06:38:49 GMT, Mark-Jason Dominus <mjd@plover.com>
wrote:
>
>
>I once said that linked list structures are never useful in Perl, and
>that the things they are useful for in other languages are almost
>always better-served by arrays.
>
>However, last week I found an exception.
Well don't be so mysterious, man! Tell us about it! :-)
Cheers,
Bernard
--
perl -le'
($B,$e,$r,$n,$a,$r,$d)=q=$B$e$r$n$a$r$d==~m;
\$(.);xg;print$B.$e.$r.$n.$a.$r.$d;'
------------------------------
Date: 27 Oct 2000 07:16:50 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: log in on a UNIX machine
Message-Id: <8tb6ki$jio$1@orpheus.gellyfish.com>
On Thu, 26 Oct 2000 15:38:41 +0200 Lex Hagen wrote:
> Does anyone know how to log-in on a UNIX machine from a WinNT machine
> using PERL? So connecting, logging in (giving username, p.w.).
>
You will probably want to use the module Net::Telnet to do this.
> I would like to eventuelly do this from Visual Basic, does anyone know
> if that is possible also?
>
You will have to ask in some group that discusses Visual Basic about this.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Fri, 27 Oct 2000 11:59:51 +0200
From: "Jan Krag" <jak@framfab.dk>
Subject: Matching and removing multiline block in perl 1-liner
Message-Id: <8tbjmp$fch$1@news.inet.tele.dk>
Hi.
I am having some problems making a small regexp work.
I am trying to remove the following block of code:
<!-- PRINT_BLOCK - STATIC -->
<tr align="right" valign="top">
<td colspan="2"><a
href="javascript:popUp('printUrl','pagePrint',584,500,'scrollbars');"
class="dark"><img src="/opencms/content/internal/img/bn/bn_ic_print.gif"
width="17" height="14" border="0" alt="Print" />Print</a></td>
</tr>
<!-- PRINT_BLOCK - STATIC -->
(including the <!-- PRINT_BLOCK - STATIC --> comments)
from a large number of files in a directory structure.
I have attempted to use the following 1-liner in various (quite many)
modifications:
perl -i -pe 's/<!-- PRINT_BLOCK - STATIC -->.*<!-- PRINT_BLOCK -
STATIC -->//gs;' index.html
perl -i -pe 's/\<\!-- PRINT_BLOCK - STATIC --\>.\*\<\!-- PRINT_BLOCK -
STATIC --\>//gs;' index.html
perl -i -pe 's/<!-- PRINT_BLOCK - STATIC -->.*?<!-- PRINT_BLOCK -
STATIC -->//gs;' index.html
but it doesn't seem to want to match.
(yes, It will finally be run on * instead of index.html only, but i want to
see it work first :-)
And while I am asking; Is there a smart commandline switch (that I have
missed) that will make it work recursively in subdirectories?
.
Regards
Jan Krag
_Apprentice_ Wizard
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4740
**************************************