[23023] in Perl-Users-Digest
Perl-Users Digest, Issue: 5243 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 20 00:05:49 2003
Date: Sat, 19 Jul 2003 21:05:07 -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, 19 Jul 2003 Volume: 10 Number: 5243
Today's topics:
Re: "use" remote modules? <REMOVEsdnCAPS@comcast.net>
Re: "use" remote modules? <ben.goldberg@hotpop.com>
Re: Changing module dynamically <ben.goldberg@hotpop.com>
Re: crypt returns same string for different texts <wdr@world.std.com>
generalizing cgi handling <me@home.com>
Re: generalizing cgi handling <REMOVEsdnCAPS@comcast.net>
Re: generalizing cgi handling <pinyaj@rpi.edu>
Re: generalizing cgi handling <ben.goldberg@hotpop.com>
Image::Magick "geometry" atribute ?? <tommy@atrixnet.com>
Re: Image::Magick "geometry" atribute ?? <mgjv@tradingpost.com.au>
Re: IP Conversion..Sending to Subroutine.. <pinyaj@rpi.edu>
Re: JOIN problem ? (2nd attempt to post) (stu7)
Re: JOIN problem ? (2nd attempt to post) (Sam Holden)
Re: JOIN problem ? (2nd attempt to post) <pinyaj@rpi.edu>
Re: JOIN problem ? (2nd attempt to post) <mgjv@tradingpost.com.au>
Re: Notepad Bug when editing Perl scripts in Win XP? <kalinabears@hdc.com.au>
Re: Notepad Bug when editing Perl scripts in Win XP? <kalinabears@hdc.com.au>
Re: perlstyles <ben.goldberg@hotpop.com>
preventing string conversion to float. <bill@news.server>
Re: preventing string conversion to float. <pinyaj@rpi.edu>
Re: Secure module version <ben.goldberg@hotpop.com>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 19 Jul 2003 19:32:56 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: "use" remote modules?
Message-Id: <Xns93BDD0F742004sdn.comcast@206.127.4.25>
lawrence tierney <l.tierney@btinternet.com> wrote in
news:bfc9mv$1pr$1$8302bc10@news.demon.co.uk:
>
>>
>> Not to point out the painfully obvious, but . . . did you ever _use_
>> the module? Perhaps the top of your code should be
>>
>> BEGIN {
>> push @INC, \&get_remote_module;
>> use remote_module;
>> }
>>
>
> Yes, it resulted in compilation error
Change the "use" above to "require". The "use" is happening when the BEGIN
block is compiled, before the "push" happens.
--
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
------------------------------
Date: Sat, 19 Jul 2003 22:10:40 -0400
From: Benjamin Goldberg <ben.goldberg@hotpop.com>
Subject: Re: "use" remote modules?
Message-Id: <3F19FA20.B5AB0086@hotpop.com>
lawrence tierney wrote:
>
> Hello again,
>
> After reading your post and the "require" docs I came up with the
> following:
>
> #! /usr/bin/perl -w
>
> use strict;
>
> push @INC,\&get_remote_module('remote_module.pm');
This calls &get_remove_module('remote_module.pm'), and then takes a
reference \ to the result, and then stores that reference (which in this
case, is a ref to a filehandle) into @INC.
You want instead:
push @INC, \&get_remote_module;
require remote_module;
import remote_module qw(password);
Or maybe:
BEGIN { push @INC, sub {
require LWP::Simple;
my $name='http://www.remotehost.org/cgi-bin/'.pop;
my $doc=LWP::Simple::get($name) or return;
open(my($fh),"<:scalar",\$doc) or die 'urg!';
return $fh;
} }
use remote_module qw(password);
Note that you *can't* do:
BEGIN { push @INC, \&get_remote_module }
use remote_module qw(password);
Since get_remote_module won't be defined when the "use remote_module" is
executed.
> my $password=password(); # password() located in remote_module.pm
It might be there, but since you never actually loaded remote_module.pm,
it's not going to get seen.
> print qq/"$password"\n/;
>
> sub get_remote_module{
> require LWP::Simple;
> my $name='http://www.remotehost.org/cgi-bin/'.pop;
> my $doc=LWP::Simple::get($name) or return;
> open(my($fh),"<:scalar",\$doc) or die 'urg!';
> return $fh;
> }
>
> ### END CODE ###
>
> But it doesn't work. Notes:
>
> 1. The call to remote_module hook in @INC works.
Your code is not not actually putting a hook into @INC... it's calling
the hook, and then putting a reference to the filehandle that it returns
into @INC.
> 2. The LWP::Simple call works.
> 3. If I dump out $doc after the LWP::Simple call it is indeed the module
> I want, containing sub password.
> 4. Filehandle opens successfully
>
> Script dies however on the password() call with
>
> "Undefined subroutine &main::password called........"
>
> I also tried, in vain:
>
> $password=remote_module::password();
>
> but this died a similar death.
This is not surprising.
As some added debugging, put some print statements in each of the
following places:
Immediately before altering @INC.
Immediately after altering @INC.
Inside of get_remote_module.
Inside of remote_module.pm, outside of any subroutines.
Inside of remote_module::import. If it inherits from Exporter, but
doesn't define it's own import(), then add:
sub import {
print "in remote_module.pm's import\n";
goto &Exporter::import;
}
> I've spent an hour or so on it and am stumped. I get the feeling I'm
> missing something really obvious like a reference/derefence etc.
>
> Help?
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Sat, 19 Jul 2003 21:39:12 -0400
From: Benjamin Goldberg <ben.goldberg@hotpop.com>
Subject: Re: Changing module dynamically
Message-Id: <3F19F2C0.8A422F70@hotpop.com>
"Thomas M. Widmann" wrote:
>
> Hi,
>
> I have a slightly odd problem. I know I'm abusing OO programming a
> bit, but I cannot think of any better way.
>
> Simply stated, my problem is as follows: I'm writing a bibliography
> package with multilingual features, so all texts are encapsulated in
> functions.
>
> E.g., $bib->edition(5) might return 'fifth edition' or '5th ed.' if
> the language is English, and 'femte udgave' og '5. udg' if it's
> Danish.
>
> Now, if one only ever needed one language in each bibliography, one
> could simply have put something like
> use Bibulus::Lang::da;
> in the beginning of the script using the bibliography package, and
> Bibulus::Lang::da would then have defined the relevant language
> functions to return Danish texts and it would have inherited the rest
> from the parent.
Sounds good!
> However, the language can change for each entry. I could of course
> write functions like the following:
> sub edition {
> my $self = shift;
> my $ed = shift;
> if ($self->LANG eq 'da') {
> return "$ed. udgave";
> } elsif ($self->LANG eq 'en') {
> ...
This doesn't look like it's changing "for each entry". It looks like
it's changing whenever someone changes the $self->LANG property.
I would advise, that any time that someone does something which would
change the return value of the $self->LANG method, you re-bless() $self
into the appropriate class.
Presumably, the LANG method is something like:
sub LANG {
my $self = shift;
if( @_ ) {
$self->{LANG} = shift @_;
}
$self->{LANG};
}
Simply change it to:
sub LANG {
my $self = shift;
if( @_ ) {
my $newlang = shift @_;
require "Biblius/Lang/$newlang.pm";
bless $self, "Bibulus::Lang::$newlang";
$self->{LANG} = $newlang;
}
$self->{LANG};
}
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Sun, 20 Jul 2003 01:40:50 +0000 (UTC)
From: William Ricker <wdr@world.std.com>
Subject: Re: crypt returns same string for different texts
Message-Id: <bfcrv2$vc6$1@pcls4.std.com>
> Yes, with DES crypt only the first 8 characters are significant (not sure
> about MD5 crypt). A password can have more characters for ease of
> remembering it, but extra characters are ignored.
That's typical with BLOCK ciphers. There are helper functions to
break up and handle a sequence of blocks, but you have to pick one
of several based on the operational mode desired.
DES, 3DES, AES, etc are BLOCK ciphers. Stream ciphers will handle
arbitrary sequences of bytes, but are less popular with
cryptographers, since the theory of block ciphers is currently well
developed.
bill
--
/"\ Bill Ricker N1VUX wdr@world.std.com
\ / http://world.std.com/~wdr/
X Member of the ASCII Ribbon Campaign Against HTML Mail
/ \
------------------------------
Date: Sat, 19 Jul 2003 20:20:03 -0700
From: Steve in NY <me@home.com>
Subject: generalizing cgi handling
Message-Id: <1j2khv43hf0adthp39jal8hk9lbutua18i@4ax.com>
Hi all, I want to get all that ugly cgi handling into a module so that several scripts
can all access it by just passing an array of varibles to the module. I would like
to do this very simply and not use something off of CPAN, since it is really a
learning experiment for me.
What I wrote below works, but I would rather use varibles instead of a hash.
But when I tried to do it, I would have to first load up the form_varible array to
pass to the module, then declare all my varibles and use some ugly thing like
shifting off a return array to define them.
The end result I would love to get is to just pass and array to the module and get
back a result for each defined key so:
$key_1 = value
$key_2 = value
What is down below is:
$a{key_1} = value
$a{key_2} = value
Any ideas? Also, any style pointers would be warmly welcome.
Thanks,
Steve
some_script.cgi
------------------------------------------------------------------------------------------
#!/usr/bin/perl -Tw
use strict;
# use CGI::Carp qw(fatalsToBrowser);
use lib "/home/sites/your_directory_here/";
use cgi_handling;
my @form_varibles = qw(affilate_ID
site_title
domain
logo
general_theme
keywords
template
bgcolor
text_color
links_color
file_system
);
my %a = cgi_handling (@form_varibles);
print "Content-type: text/html", "\n\n";
print "$a{affilate_ID}, $a{site_title}, $a{domain}, $a{logo}, $a{general_theme}, $a{keywords}, ";
print "$a{template}, $a{bgcolor}, $a{text_color}, $a{links_color}, $a{file_system}";
close(STDOUT);
exit (0);
cgi_handling.pm
------------------------------------------------------------------------------------------
package cgi_handling;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
use Exporter;
require 5.000;
@ISA = qw(Exporter);
@EXPORT = qw(cgi_handling);
sub cgi_handling {
my @form_input = @_;
my %a = ();
my ($input, @pairs, $pair, $key, $value);
read (STDIN, $input, $ENV{'CONTENT_LENGTH'});
@pairs = split (/&/, $input);
for $pair (@pairs) {
($key, $value) = split (/=/, $pair);
if (!defined($value)) { zero_value ($key) }
$value =~ tr/+/ /;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
if ($value =~ /^([-_\w\s]+)$/) { $value = $1 }
else { bad_data ($key, $value) }
for my $item (@form_input) {
if ($key == $item) { $a{$key} = $value }
else { unexpected_key ($key, $value); }
}
}
return %a;
}
sub bad_data {
my $string = $_[0];
my $error = $_[1];
$string =~ tr/_/ /;
print "<html><center><br><br><big>";
print "Input error: \"$string\" contains bad characters: \"$error\"<br>";
print "Please only use alphanumeric characters, the dash and underscore.<br>";
print "<a href=\"./index.html\">return</a>";
die;
}
sub unexpected_key {
my $string = $_[0];
my $error = $_[1];
$string =~ tr/_/ /;
print "<html><center><br><br><big>";
print "Input error: \"$string\" with a value of \"$error\" is not a valid key<br>";
print "<a href=\"./index.html\">return</a>";
die;
}
sub zero_value {
my $string = $_[0];
$string =~ tr/_/ /;
print "<html><center><br><br><big>";
print "Input error: please enter a value for \"$string\"<br>";
print "<a href=\"./index.html\">return</a>";
die;
}
1;
__DATA__
To do:
1. test length of string
------------------------------
Date: Sat, 19 Jul 2003 19:59:18 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: generalizing cgi handling
Message-Id: <Xns93BDD57054B55sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Steve in NY <me@home.com> wrote in
news:1j2khv43hf0adthp39jal8hk9lbutua18i@4ax.com:
> Hi all, I want to get all that ugly cgi handling into a module so that
> several scripts can all access it by just passing an array of varibles
> to the module. I would like to do this very simply and not use
> something off of CPAN, since it is really a learning experiment for
> me.
I strongly advise you to use something tested and true like CGI.pm for
real-world projects. However, what you want to do is excellent for a
learning project. You will likely learn a lot about both Perl and CGI
programming.
> What I wrote below works, but I would rather use varibles instead of a
> hash. But when I tried to do it, I would have to first load up the
> form_varible array to pass to the module, then declare all my varibles
> and use some ugly thing like shifting off a return array to define
> them.
Can I ask what is so bad about a hash? A hash keeps all your CGI
parameters and their values bundled up in one neat place, and there's no
chance that it'll interfere with any other variables your main program
uses elsewhere.
> The end result I would love to get is to just pass and array to the
> module and get back a result for each defined key so:
>
> $key_1 = value
> $key_2 = value
If you really really want to do that (and hey, this is just a learning
excercise so what the heck), you have to do something like the following.
# at start of cgi_handling function
my $caller_package = caller;
# later, at the point where you currently assign $a{$key}
{
no strict 'refs';
*{$caller_package . '::' . $key) = \$value;
}
Hmmm, now that I write that, I'm not 100% sure it'll work, since it
assigns a reference to a lexical variable ($value) to a package variable
slot in a typeglob (the *{...} part). But I *think* it'll work, since
it's a reference to a scalar.
>
> Any ideas? Also, any style pointers would be warmly welcome.
Since you're learning, would you like some constructive criticism?
>
> some_script.cgi
> -----------------------------------------------------------------------
> ------------------- #!/usr/bin/perl -Tw
> use strict;
I see that you're using taint-mode, warnings, and strict. Excellent.
> cgi_handling.pm
>
> package cgi_handling;
The usual convention is that all-lowercase package names are reserved for
perl pragmatic modules, and regular modules have capitalization like
"CGI_Handling". But hey, that's just a convention, and for your own work
you can do whatever feels right to you.
> sub cgi_handling {
>
> my @form_input = @_;
>
> my %a = ();
>
> my ($input, @pairs, $pair, $key, $value);
>
> read (STDIN, $input, $ENV{'CONTENT_LENGTH'});
Note that if the CGI was invoked with the GET method instead of the POST
method, STDIN isn't going to do you any good, because the cgi input will
be in the QUERY_STRING environment variable.
> @pairs = split (/&/, $input);
CGI parameters can be separated by semicolons too. In fact, that's the
current recommendation by the w3c committee, and more and more websites
are doing this. So: split (/[&;]/, $input);
> for $pair (@pairs) {
> ($key, $value) = split (/=/, $pair);
If a cgi variable has an unencoded = sign in it for some reason (a bad
form? A bad browser?), then your above statement will throw away
everything in the value from the = sign on. For example if the form was
submitted with "var=value1=value2". Do this instead:
($key, $value) = split (/=/, $pair, 2);
> if (!defined($value)) { zero_value ($key) }
You might want to have some sort of option to specify that a value is
optional, instead of making them all required all the time.
>
> if ($value =~ /^([-_\w\s]+)$/) { $value = $1 }
It would be a bit quicker to check for the existence of anything NOT in
the above character set, rather than checking that ALL of the characters
are in the set:
if ($value =~ /[^-\w\s]/) { bad_data($key, $value) }
(also note that \w includes the underscore character).
Hope this helps. Have fun.
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPxnpQWPeouIeTNHoEQJukQCdHhJd3oChQF8E1QD2fmaLzRVszEEAoPaT
V02Zr9SNw8t6paF/KNm74e2j
=ZzHX
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 19 Jul 2003 21:34:17 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: generalizing cgi handling
Message-Id: <Pine.SGI.3.96.1030719211705.146649A-100000@vcmr-64.server.rpi.edu>
On Sat, 19 Jul 2003, Steve in NY wrote:
>Hi all, I want to get all that ugly cgi handling into a module so that
>several scripts can all access it by just passing an array of varibles to
>the module. I would like to do this very simply and not use something off
>of CPAN, since it is really a learning experiment for me.
Eh, I don't think you want to learn it that way. The CGI.pm module, which
is a STANDARD module, does it. Correctly. If you want to learn the right
way to do it, study the code from the module, and use the module. Writing
it on your own is NOT easy.
>What I wrote below works, but I would rather use varibles instead of a
>hash. But when I tried to do it, I would have to first load up the
>form_varible array to pass to the module, then declare all my varibles
>and use some ugly thing like shifting off a return array to define them.
No, you don't want to have several variables. If your module creates a
bunch of variables, what happens when the name of a form field clashes
with a variable you're using for something else in your program? And
isn't it easier to have a hash that stores your form fields, so you can
access ALL of them at once, easily?
Creating variables on the fly ("symbolic references") is a bad idea for a
beginner, an intermediate, or an expert. There are very few occasions
where it's a good idea, honestly.
>Any ideas? Also, any style pointers would be warmly welcome.
You use tainting, warnings, and strictures. That's wonderful. Notice how
strict doesn't let you make variables on the fly like you wanted? Yeah,
there's a reason for that.
>package cgi_handling;
>use strict;
>use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
>
>use Exporter;
>require 5.000;
>@ISA = qw(Exporter);
>
>@EXPORT = qw(cgi_handling);
Here's a little secret -- the Exporter module uses symbolic references to
do the actual exporting of variables and functions. That's one of the FEW
times it's useful to use symrefs. See the Exporter module for how it's
done.
>sub cgi_handling {
>
> my @form_input = @_;
>
> my %a = ();
>
> my ($input, @pairs, $pair, $key, $value);
>
> read (STDIN, $input, $ENV{'CONTENT_LENGTH'});
This only works for POSTs. What about GETs? What happens when you want
to upload a file? That's some tricky, ugly business.
> @pairs = split (/&/, $input);
> for $pair (@pairs) {
> ($key, $value) = split (/=/, $pair);
>
> if (!defined($value)) { zero_value ($key) }
>
> $value =~ tr/+/ /;
> $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
>
> if ($value =~ /^([-_\w\s]+)$/) { $value = $1 }
> else { bad_data ($key, $value) }
>
>
> for my $item (@form_input) {
> if ($key == $item) { $a{$key} = $value }
> else { unexpected_key ($key, $value); }
> }
> }
> return %a;
>}
What does your script do with multiple fields with the same name (like
checkboxes)? It doesn't do anything helpful. And you're restricting the
data you can put in a value. That's not polite. The user of the module
should do the taint-checking. I might need a form field to contain a "~"
or a "!", and your module won't allow that.
>
>sub bad_data {
> my $string = $_[0];
> my $error = $_[1];
You can also say
my ($string, $error) = @_;
or
my $string = shift;
my $error = shift;
I'd probably use the first one.
> print "<html><center><br><br><big>";
> print "Input error: \"$string\" contains bad characters: \"$error\"<br>";
> print "Please only use alphanumeric characters, the dash and underscore.<br>";
> print "<a href=\"./index.html\">return</a>";
Here-docs (or even different quoting characters) would look nicer here:
print << "END_HTML";
<html>
<center>
<br><br>
<big>
Input error: "$string" contains bad characters: "$error"<br>
Please only use alphanumeric characters, the dash, and the underscore.
</big>
<br>
<a href="index.html">Return</a>
</center>
</html>
END_HTML
That "END_HTML" has to be all the way to the left, which is why it looks a
bit out of place in my code. Also, it wouldn't hurt to have properly
formed HTML output (something I have not corrected).
You can also use qq{} or qq!! or qq[] or qq~~, etc. See 'perlop' for more
information on the qq() operator. It's basically just double quotes, but
you can choose your quoting character (like I've shown).
Then again, the CGI module also has HTML-generating methods/functions you
can use:
my $query = CGI->new;
print
$query->start_html,
$query->center(
$query->big(qq{Input error: "$string" ...}),
$query->br,
$query->big(qq{...}),
$query->br,
$query->a({ -href => "index.html" }, "Return"),
),
$query->end_html;
> die;
>}
It'd be nice to tell the server's error log something, like:
die "bad input ($string: '$error')";
Your code expects I came from index.html; that might not be the case.
Either use javascript:
<a href="javascript:history.back(1)">Return</a>
or get the URL they came from with the $ENV{HTTP_REFERER} variable.
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Sat, 19 Jul 2003 23:02:07 -0400
From: Benjamin Goldberg <ben.goldberg@hotpop.com>
Subject: Re: generalizing cgi handling
Message-Id: <3F1A062F.5EB55657@hotpop.com>
Steve in NY wrote:
[big snip]
How about the following:
package cgi_handling;
use base qw(Exporter);
@EXPORT = qw(cgi_handling);
sub cgi_handling {
require CGI;
return CGI::Vars();
}
1;
__END__
Some people might find something like the following a bit more useful,
though:
package CGI::Vars;
sub import {
my ($self, @names) = @_;
my $namespace = caller() . "::";
require CGI;
for my $name (@names) {
my $value = CGI::query($name);
*{$namespace.$name} = \$value;
}
};
1;
__END__
Then, they could do:
use strict;
use CGI::Vars qw(affilate_ID site_title domain
logo general_theme keywords template bgcolor
text_color links_color file_system);
print $affiliate_ID; # etc..
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Sat, 19 Jul 2003 23:16:33 GMT
From: Tommy Butler <tommy@atrixnet.com>
Subject: Image::Magick "geometry" atribute ??
Message-Id: <3789e4d815a26fba9ba824303de19736@free.teranews.com>
Many of the methods in Image::Magick require an argument named "geometry".
The docs at http://www.imagemagick.org/www/perl.html are very vague about this.
I don't understand what the "geometry" argument is for, and I don't understand
what kind of values to assign it. It requires a syntax that I can't grasp.
Can someone enlighten me?
Example taken from the documentation:
$x = $image->Crop(geometry=>'100x100"+100"+100');
A few methods that require the "geometry" argument, as described in the docs:
+-------------------+------------------------------------------------------+
| Method | Parameters |
+===================+======================================================+
| AdaptiveThreshold | geometry=>geometry, width=>integer, height=>integer, |
| | offset=>integer |
+-------------------+------------------------------------------------------+
| Blur | geometry=>geometry, radius=>double, sigma=>double |
+-------------------+------------------------------------------------------+
| Border | geometry=>geometry, width=>integer, height=>integer, |
| | fill=>color name |
+-------------------+------------------------------------------------------+
| ColorFloodfill | geometry=>geometry, x=>integer, y=>integer, |
| | fill=>color name, bordercolor=>color name, |
| | fuzz=>double |
+-------------------+------------------------------------------------------+
| Crop |geometry=>geometry, width=>integer, height=>integer, |
| |x=>integer, y=>integer |
+-------------------+------------------------------------------------------+
| Emboss | geometry=>geometry, radius=>double, sigma=>double |
+-------------------+------------------------------------------------------+
Some help please?
--
-Tommy Butler
see if I'm online »http://ooopps.sourceforge.net/online
Tommy Butler <tommy@atrixnet.com>
phone: (817)-466-2245
912 Greenridge Drive
Arlington, TX
76017-6243
the ooOPps Code Library
http://ooopps.sourceforge.net/pub/
------------------------------
Date: Sun, 20 Jul 2003 11:14:26 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Image::Magick "geometry" atribute ??
Message-Id: <slrnbhjr7h.rlm.mgjv@martien.heliotrope.home>
[Please, do not ask for follow-up to poster if the response could be
useful for all readers of the newsgroup. Followup to poster is generally
only used when a discussion has reached a point where it should no
longer be continued on the group anymore.]
On Sat, 19 Jul 2003 23:16:33 GMT,
Tommy Butler <tommy@atrixnet.com> wrote:
> Many of the methods in Image::Magick require an argument named
> "geometry". The docs at http://www.imagemagick.org/www/perl.html are
> very vague about this. I don't understand what the "geometry"
> argument is for, and I don't understand what kind of values to assign
> it. It requires a syntax that I can't grasp. Can someone enlighten
> me?
The documentation has several examples, as well as short lines stating
that geometry generally is short for widthXheight. This is generally the
case, although the 3rd and 4th argument chane their meaning sometimes,
depending on the methods called. Sometimes the geometry attribute can be
used with special characters that limit or extend its meaning, like
percentages for resizing. See the link below.
More information about geometry can be found in the generic manual pages
for the ImageMagick tools, and under the command line options to these
tools. See, for example
http://www.imagemagick.org/www/utilities.html
Without writing a complete reference for all methods (been there, done
that), I can't be that much more helpful.
I'd advise you to not use the geometry attribute, when there are options
that allow you to avoid it.
Martien
--
|
Martien Verbruggen |
| What's another word for Thesaurus?
|
------------------------------
Date: Sat, 19 Jul 2003 22:14:21 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Joe Henderson <joecool118@hotmail.com>
Subject: Re: IP Conversion..Sending to Subroutine..
Message-Id: <Pine.SGI.3.96.1030719221306.144785A-100000@vcmr-64.server.rpi.edu>
On Sat, 19 Jul 2003, Joe Henderson wrote:
>Or does ne1 have a better way...
I don't really know what you're doing, or why you're doing it.
>my $ip = "10.10.1.1";
>my @octet = split(/\./, $ip); #Like to remove this garbage.., Just send the
>my $dec = &decimal(@octet);
Then why not send the whole string and have the function do the splitting?
>my $dec1 = substr($dec, 0, 5); #Like to remove this garbage..
>my $dec2 = substr($dec, 5, 5); #Like to remove this garbage..
>my $ip = &ip($dec1, $dec2);
Why do you want to split the value into two pieces, only to rejoin them
later?!
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: 19 Jul 2003 18:40:43 -0700
From: stuseven@hotmail.com (stu7)
Subject: Re: JOIN problem ? (2nd attempt to post)
Message-Id: <d7dd90b0.0307191740.5f1bdb7c@posting.google.com>
*** No thanks to you Eric... not that usenet isn't plagued
*** with meaningless posts already - and your's fits right in...
*** however, to answer your "friendly post" -
*** A) Usenet is here, among a very few other reasons, so people
*** with legitimate questions can get answers from those who
*** already have encountered these problems... your post had
*** virtually nothing to do with my questions - which were, in
*** fact, answered politely and correctly by two posters previous
*** to your "style whine"_ value of your spam is ? (right... nothing).
***
*** B) If using my quoting style fouls up your newsreader, then,
*** I feel as though I have contributed something extra. Kindly
*** dont bother spamming people on these newsgroups again.
***
*** C) If you really feel a need to get your snaz signature and
*** puffy whines plastered all over the net, why not start your own
*** newsgroup... why not start it on your own computer... then you
*** you could have TOTAL control, ey ? :)
"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> belated, in message
news:<Xns93BD51D11A55Esdn.comcast@206.127.4.25>...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> Just a friendly tip: Please don't start every line of your post with
> "bleep" or any other character. Longstanding Usenet tradition is that you
> precede text lines with one or more characters like that when you're
> quoting someone else's text. Many newsreader programs highlight text
> differently if there's a leading string like your "bleep". I had to read
> your article twice to find your response.
>
> - --
> Eric
> $_ = reverse sort qw p ekca lre Js reh ts
> p, $/.r, map $_.$", qw e p h tona e; print
>
> -----BEGIN xxx SIGNATURE-----
> Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
>
> iQA/AwUBPxkzWGPeouIeTNHoEQI4SgCfUyiKy/p2/gwCBaszRO7NGCgErtMAn0T9
> RR5vzhu/02SiEJsfRGipAoSd
> =49+l
> -----END PGP SIGNATURE-----
------------------------------
Date: 20 Jul 2003 01:57:46 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: JOIN problem ? (2nd attempt to post)
Message-Id: <slrnbhjtoq.rop.sholden@flexal.cs.usyd.edu.au>
On 19 Jul 2003 18:40:43 -0700, stu7 <stuseven@hotmail.com> wrote:
> *** No thanks to you Eric... not that usenet isn't plagued
> *** with meaningless posts already - and your's fits right in...
> *** however, to answer your "friendly post" -
> *** A) Usenet is here, among a very few other reasons, so people
> *** with legitimate questions can get answers from those who
> *** already have encountered these problems... your post had
> *** virtually nothing to do with my questions - which were, in
> *** fact, answered politely and correctly by two posters previous
> *** to your "style whine"_ value of your spam is ? (right... nothing).
The chances of any of your legitimate questions being seen by the
very people who probably know the answers is quite slim now.
[snip a post that breaks almost all the conventions of clpm]
--
Sam Holden
------------------------------
Date: Sat, 19 Jul 2003 21:59:20 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: stu7 <stuseven@hotmail.com>
Subject: Re: JOIN problem ? (2nd attempt to post)
Message-Id: <Pine.SGI.3.96.1030719214555.141252A-100000@vcmr-64.server.rpi.edu>
[posted & mailed]
On 19 Jul 2003, stu7 wrote:
>"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> belated, in message
>news:<Xns93BD51D11A55Esdn.comcast@206.127.4.25>...
>> -----BEGIN xxx SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Just a friendly tip: Please don't start every line of your post with
>> "bleep" or any other character. Longstanding Usenet tradition is that you
>> precede text lines with one or more characters like that when you're
>> quoting someone else's text. Many newsreader programs highlight text
>> differently if there's a leading string like your "bleep". I had to read
>> your article twice to find your response.
>
>*** No thanks to you Eric... not that usenet isn't plagued
>*** with meaningless posts already - and your's fits right in...
>*** however, to answer your "friendly post" -
Well then, let me "plague" usenet with this post as well.
You're not being very polite at all. Eric is someone who helps out on
this list quite often. You're asking for help from people who are giving
their time free of charge (many people who give help on this list make
money doing consulting). Be grateful, please.
>*** A) Usenet is here, among a very few other reasons, so people
>*** with legitimate questions can get answers from those who
>*** already have encountered these problems... your post had
>*** virtually nothing to do with my questions - which were, in
>*** fact, answered politely and correctly by two posters previous
>*** to your "style whine"_ value of your spam is ? (right... nothing).
Do you know what "netiquette" is? If not, you should probably research
it. You're being awfully rude to Eric. He offered a polite suggestion.
If you're asking people to help you, you should try to do as they ask.
Make it as easy as possible for them to help you. This includes things
like bottom-posting, proper quoting and trimming, and general attitude.
(You top-posted, didn't trim the unnecessary parts from Eric's response,
and display poor attitude.)
>*** B) If using my quoting style fouls up your newsreader, then,
>*** I feel as though I have contributed something extra. Kindly
>*** dont bother spamming people on these newsgroups again.
Huh? If I write a program that crashes your OS, or deletes files, I don't
think I've "contributed something extra". I think I've made a mistake, or
have caused mischief. I apologize and try to correct the problem. And
anyone else who happens to see Eric's post now has the opportunity to
correct their own posting style if they notice it might cause problems.
You get more help if you're nice. People are liable to killfile you and
not help you if you have a bad attitude.
>*** C) If you really feel a need to get your snaz signature and
>*** puffy whines plastered all over the net, why not start your own
>*** newsgroup... why not start it on your own computer... then you
>*** you could have TOTAL control, ey ? :)
A quick google search reported at least 1230 postings by Eric on the
newsgroup. He's helping people. Trust me. He's not trying to get his
signature everywhere he can.
In closing, act politely, try not to piss off the people you're asking for
help, and accept criticism. Then perhaps you'll get a better reception
here.
--
Jeff Pinyan RPI Acacia #734 japhy on freenode IRC 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Sun, 20 Jul 2003 13:27:53 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: JOIN problem ? (2nd attempt to post)
Message-Id: <slrnbhk31p.rlm.mgjv@martien.heliotrope.home>
On 19 Jul 2003 18:40:43 -0700,
stu7 <stuseven@hotmail.com> wrote:
> *** No thanks to you Eric... not that usenet isn't plagued
> *** with meaningless posts already - and your's fits right in...
> *** however, to answer your "friendly post" -
> *** A) Usenet is here, among a very few other reasons, so people
> *** with legitimate questions can get answers from those who
> *** already have encountered these problems... your post had
> *** virtually nothing to do with my questions - which were, in
> *** fact, answered politely and correctly by two posters previous
> *** to your "style whine"_ value of your spam is ? (right... nothing).
You obviously have no clue, and are not willing to get one.
*plonk*
Martien
--
|
Martien Verbruggen | life ain't fair, but the root password helps.
| -- BOFH
|
------------------------------
Date: Sun, 20 Jul 2003 10:26:10 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Notepad Bug when editing Perl scripts in Win XP?
Message-Id: <3f19e2ac$0$23586$5a62ac22@freenews.iinet.net.au>
"randy" <cry-ofan@mylinuxisp.com> wrote in message
news:ssqihvo46u10f343qdapm8j21uhaheq6mp@4ax.com...
> Has anyone else tried editing perl scripts in notepad in XP? I am
> getting some characters inserted into the scripts.....
>
Never had any trouble writing/editing scripts in notepad on Win2k. However,
some text files (including scripts) that I've downloaded over the net,
contain line endings that notepad doesn't understand. Such text files are
pretty much unreadable in notepad, though they appear fine in wordpad. One
solution is to do your editing with wordpad.
Or you can create a cleaned up copy of the problem by running:
perl cleanup.pl <original_file >new_copy
where cleanup.pl looks like this:
use warnings;
binmode(STDIN);
while(<>) {print}
Hth.
Cheers,
Rob
------------------------------
Date: Sun, 20 Jul 2003 10:52:30 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Notepad Bug when editing Perl scripts in Win XP?
Message-Id: <3f19e8d8$0$23611$5a62ac22@freenews.iinet.net.au>
"Sisyphus" <kalinabears@hdc.com.au> wrote in message
> where cleanup.pl looks like this:
> use warnings;
> binmode(STDIN);
> while(<>) {print}
>
Actually, on a test I just ran, I find that 'binmode(STDIN)' is unnecessary.
The following worked just as well:
use warnings;
while(<>) {print}
Cheers,
Rob
------------------------------
Date: Sat, 19 Jul 2003 22:23:33 -0400
From: Benjamin Goldberg <ben.goldberg@hotpop.com>
Subject: Re: perlstyles
Message-Id: <3F19FD25.CE5843B5@hotpop.com>
Matija Papec wrote:
>
> I was wandering what would be more readable for code maintainers, I
> prefer first as it's far more obvious what's going on(not to mention
> typing laziness), but that's just me.
>
> #1
> @arr = join ',', map s|'|\\'|g && "'$_'", grep /^MB/, @arr;
> #2
> @arr = join(',', map(s|'|\\'|g && "'$_'", grep(/^MB/, @arr)));
I prefer:
@arr = join ',', map s|'|\\'|g ? "'$_'" : $_, grep /^MP/, @arr;
> and another one, how do you prefer $h{key} over $h{'key'} in case where
> key is strictly English \w class?
I generally prefer $h{key}, unless key happens to be a perl keyword or
the name of a subroutine, in which case I quote it. Not that I *need*
to quote it, but just in case I need to run the program on a dead
camel...
> Most importantly, what would you tell to someone who doesn't have a clue
> about use strict and warnings,
I would tell him to learn about strict and warnings.
> and at the same time insisting on quoted hash keys? :)
I'd say he's being silly.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Sat, 19 Jul 2003 22:12:38 -0400
From: Little Bill <bill@news.server>
Subject: preventing string conversion to float.
Message-Id: <vhjumef6446ud9@corp.supernews.com>
It has been a long time since I touched any perl, and I am having a
problem with parsing a text file. I need to pull out a string in the
form 1234-5678-9123. My problem is that perl want to interpolate this
as three numbers and then it does the subtraction.
Is there a way to prevent the interpolation as a float?
Any help would be appreciated.
LB
------------------------------
Date: Sat, 19 Jul 2003 22:27:01 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: preventing string conversion to float.
Message-Id: <Pine.SGI.3.96.1030719222630.148452A-100000@vcmr-64.server.rpi.edu>
On Sat, 19 Jul 2003, Little Bill wrote:
>It has been a long time since I touched any perl, and I am having a
>problem with parsing a text file. I need to pull out a string in the
>form 1234-5678-9123. My problem is that perl want to interpolate this
>as three numbers and then it does the subtraction.
>
>Is there a way to prevent the interpolation as a float?
You'll have to show us some code. The only way I see this happening is if
you eval() the string containing the numbers.
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Sat, 19 Jul 2003 21:52:57 -0400
From: Benjamin Goldberg <ben.goldberg@hotpop.com>
Subject: Re: Secure module version
Message-Id: <3F19F5F9.80B4B18@hotpop.com>
Gunnar Hjalmarsson wrote:
>
> I want to ensure that at least a certain version of a core module is
> used in a portable CGI script. Accordingly, a copy of that version is
> included in the distribution of my program, but if a later version is
> installed on the server, I would like that version to be used instead.
>
> This is my first attempt to a resolution:
>
> my %tempinc = %INC;
> require Module;
> unless (eval { Module->VERSION(2.5) }) {
> %INC = %tempinc;
> unshift @INC, 'mylib';
> require Module;
> }
The problem with this is that if/when we reach the second require(), the
older Module is still loaded into perl... there are a number of
potential problems with this, the least of which would be lots of
'subroutine redefined' warnings.
> It should work as long as the script is run as a plain CGI script, but
> scarcely when the program is run under mod_perl.
>
> Anybody who knows about a better way to accomplish the load of at
> least version X of a module, and that works also under mod_perl?
Does only.pm work under mod_perl?
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5243
***************************************