[24407] in Perl-Users-Digest
Perl-Users Digest, Issue: 6595 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 21 18:05:57 2004
Date: Fri, 21 May 2004 15: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 Fri, 21 May 2004 Volume: 10 Number: 6595
Today's topics:
Re: * or x ? (Walter Roberson)
Re: * or x ? <gnari@simnet.is>
Re: 2-1/2 regexp questions <tassilo.parseval@rwth-aachen.de>
Re: 2-1/2 regexp questions <abigail@abigail.nl>
Re: advice on backing up a DB from server? (dan baker)
Re: how can I send messages from both sides through soc <jgibson@mail.arc.nasa.gov>
Re: Password scheme/Persistent session... <jgibson@mail.arc.nasa.gov>
Re: Perl apache <tore@aursand.no>
perl script to move email (Jim)
perl script to move email (Jim)
Re: perl script to move email <usenet@morrow.me.uk>
Re: Perl vs PHP <dha@panix2.panix.com>
Re: Perl vs PHP <dha@panix2.panix.com>
Re: Perl vs PHP <noreply@gunnar.cc>
Re: Perl vs PHP <perl@my-header.org>
Re: perlmagick and image size (dan baker)
Problem installing modules <tpsX@vr-web.de>
Re: Problem installing modules <matthew.garrish@sympatico.ca>
quoting in perl command in shell script <rduke15@hotmail__.__com>
Re: quoting in perl command in shell script <barmar@alum.mit.edu>
Re: quoting in perl command in shell script <rduke15@hotmail__.__com>
Re: Sockets: receiving data <jgibson@mail.arc.nasa.gov>
String search/match question (Kevin Potter)
Re: String search/match question <perl@my-header.org>
Re: String search/match question <someone@somewhere.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 May 2004 19:51:08 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: * or x ?
Message-Id: <c8lmjc$7qr$1@canopus.cc.umanitoba.ca>
In article <c8lfsh$g5f$1@reader2.panix.com>,
<vjp2.at@at.BioStrategist.dot.dot.com> wrote:
:* or X ??
:I want to stick blank or (tribar) striped lines in between text
'x' is the string repetition operation. '*' is [unless overloaded]
the arithmetic multiplication operator.
--
Everyone has a "Good Cause" for which they are prepared to spam.
-- Roberson's Law of the Internet
------------------------------
Date: Fri, 21 May 2004 19:50:02 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: * or x ?
Message-Id: <c8lmed$5o2$1@news.simnet.is>
<vjp2.at@at.BioStrategist.dot.dot.com> wrote in message
news:c8lfsh$g5f$1@reader2.panix.com...
> * or X ??
>
> perl -pe 'if ($.%4==2){$_.="-" x 37} elseif {$.%4==0) {$_.="=" x 37}
$_.="\n"' < %1 >%1
apart from the syntax errors,
a) why don't you try it ?
b) you want to use -i, it seems
c) please use correct Newsgroups line
gnari
------------------------------
Date: Fri, 21 May 2004 20:16:07 +0200
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: 2-1/2 regexp questions
Message-Id: <2h6vbaF9foo6U1@uni-berlin.de>
Also sprach J Krugman:
> 1. Supposed I wanted apply s/// at a particular (offset, length)
> substring of a string (for example, applying s/(a[^a]+)/*\U$1*/ to the
> (offset = 7, length = 3) substring in 'abracadabra', to get
> 'abracad*ABR*a'). I could use some labored code like this:
>
> $string = 'abracadabra';
> ($substring = substr($string, 7, 3)) =~ s/(a[^a]+)/;
> substr($string, 7, 3) = $substring;
>
> This requires creating an auxiliary variable $substring and two calls
> to substr, which seems like a waste. Is there any way to target s///
> to a particular substring in a string?
substr() returns a left-value and you are already making use of that in
the above code. And since a lvalue can also be target of a substitution,
nothing will stop you from writing:
substr($string, 7, 3) =~ s/(.*)/*\U$1*/;
> 2. Given any finite string S and given any regexp R, there is a finite
> set A of (o, w) pairs, such that the substring S[o, w] of S, beginning
> at offset o and having length w matches R [1]. For example, if
>
> S = '1a21b4xy' and
> R = /(\d+)/,
>
> then the pairs in the set A would be
>
> (0, 1) --> '1'
> (2, 1) --> '2'
> (2, 2) --> '21'
> (3, 1) --> '1'
> (5, 1) --> '4'
>
> Does Perl offer any simple and/or built-in way to generate the set
> A?
Hardly. This can be done recursively:
my $s = '1a21b4xy';
my @s;
find_set($1, pos($s) - length($1)) while $s =~ /(\d+)/g;
print Dumper \@s;
sub find_set {
my ($m, $offset) = @_;
if (length $m > 1) {
my $num = length($m)-1;
find_set($1, $offset + pos($m) - length($1)) while $m =~ /(\d{$num})/g;
}
push @s, [ $offset, length($m), $m ];
}
I wouldn't call that a beauty though.
> 2.5 There's a *different* problem, simpler for me to code than the one
> described in (2): generate the set B of all pairs (length($PREMATCH),
> length($MATCH)) generated during a "global" (i.e. /g-modified) match.
> For example:
>
> while ($S =~ /(\d+)/g) {
> push @pairs, [ map length, ($`, $&) ];
> }
>
> For the string S and the regexp R in the example given in question 2,
> the set B would be { (0, 1), (2, 2), (5, 1) }.
>
> Does Perl offer some built-in mechanism to get directly at the set B?
Maybe not directly, but it's not very hard either:
my @s;
while ($s =~ /(\d+)/g) {
push @s, [ pos($s) - length($1), length($1) ];
}
> [1] If we changed R in (2) to the anchored regexp /^(\d+)/ we would
> get the same set A as before, and not the set { (0, 1) }, because each
> substring S[o, w] is tested against R in isolation.)
In this case you have to change the algorithm. Mine will _not_ work with
an anchored pattern. As a matter of fact, I doubt that mine works for
any (non-anchored) pattern.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 21 May 2004 19:06:11 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: 2-1/2 regexp questions
Message-Id: <slrncaskp3.ct.abigail@alexandra.abigail.nl>
J Krugman (jkrugman345@yahbitoo.com) wrote on MMMCMXVI September MCMXCIII
in <URL:news:c8lb76$ea3$1@reader2.panix.com>:
`'
`'
`'
`' 1. Supposed I wanted apply s/// at a particular (offset, length)
`' substring of a string (for example, applying s/(a[^a]+)/*\U$1*/ to the
`' (offset = 7, length = 3) substring in 'abracadabra', to get
`' 'abracad*ABR*a'). I could use some labored code like this:
`'
`' $string = 'abracadabra';
`' ($substring = substr($string, 7, 3)) =~ s/(a[^a]+)/;
`' substr($string, 7, 3) = $substring;
`'
`' This requires creating an auxiliary variable $substring and two calls
`' to substr, which seems like a waste. Is there any way to target s///
`' to a particular substring in a string?
substr() returns an lvalue, and can hence be modified. Including using s///.
$string = 'abracadabra';
substr ($string, 7, 3) =~ s/a[^a]+//;
print $string; # Prints abracada
`' 2. Given any finite string S and given any regexp R, there is a finite
`' set A of (o, w) pairs, such that the substring S[o, w] of S, beginning
`' at offset o and having length w matches R [1]. For example, if
`'
`' S = '1a21b4xy' and
`' R = /(\d+)/,
`'
`' then the pairs in the set A would be
`'
`' (0, 1) --> '1'
`' (2, 1) --> '2'
`' (2, 2) --> '21'
`' (3, 1) --> '1'
`' (5, 1) --> '4'
`'
`' Does Perl offer any simple and/or built-in way to generate the set
`' A?
use re 'eval';
my $s = '1a21b4xy';
my $r = '\d+';
my $re = qr /($r)(?{print "(", $- [-1], ", ", $+ [-1] - $- [-1], ")",
" --> '$^N'\n"})(?!)/;
$s =~ $re;
__END__
(0, 1) --> '1'
(2, 2) --> '21'
(2, 1) --> '2'
(3, 1) --> '1'
(5, 1) --> '4'
`'
`' 2.5 There's a *different* problem, simpler for me to code than the one
`' described in (2): generate the set B of all pairs (length($PREMATCH),
`' length($MATCH)) generated during a "global" (i.e. /g-modified) match.
`' For example:
`'
`' while ($S =~ /(\d+)/g) {
`' push @pairs, [ map length, ($`, $&) ];
`' }
`'
`' For the string S and the regexp R in the example given in question 2,
`' the set B would be { (0, 1), (2, 2), (5, 1) }.
`'
`' Does Perl offer some built-in mechanism to get directly at the set B?
my $s = '1a21b4xy';
my @a;
push @a => [$- [0] => $+ [0] - $- [0]] while $s =~ /(\d+)/g;
print "(", $_ -> [0], ", ", $_ -> [1], ")\n" for @a;
__END__
(0, 1)
(2, 2)
(5, 1)
Abigail
--
my $qr = qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
$qr =~ s/$qr//g;
print $qr, "\n";
------------------------------
Date: 21 May 2004 14:45:38 -0700
From: botfood@yahoo.com (dan baker)
Subject: Re: advice on backing up a DB from server?
Message-Id: <13685ef8.0405211345.57d3ea04@posting.google.com>
Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> wrote in message
...
> 1) Investigate the tools your database software has for backing up
> your database. They will certainly be helpful, even if you decide to
> roll your own eventually.
----------
the DB is a really simple one using perl DB_file and tie(). But that
is irrelevant.
> 3) Don't post database questions to comp.lang.perl.misc. If you end
> up writing Perl code, and need help, then you might try this newsgroup
> first. But database questions are probably more appropriate somewhere
> else.
> ---------------
my question is not a "database question."
I would like some input on possible perl-driven approaches to back up
some files from a remote server to my local computer. I was thinking
that perhaps people could give some meaningful advise on the pros and
cons of using perl modules like Net:FTP or Mirror, or whether it might
be best to push it from the remote server, or pull it from my
computer. My question IS: what might be the simplest, easiest perl
module to copy a file from a remote server to my local computer.
Get off your high-horse, and contribute a meaningful reply if you have
one.
d
------------------------------
Date: Fri, 21 May 2004 11:45:46 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: how can I send messages from both sides through socket?
Message-Id: <210520041145463621%jgibson@mail.arc.nasa.gov>
In article <x32rc.69143$325.1485289@news20.bellglobal.com>, B. W.
<mysympatico001@sympatico.ca> wrote:
> I want to send a request from A to B through socket, then B returns the
> process result back to A for display. I run B script first then start A
> script, but I got error message at B side "can't use an undefined value as a
> symbol reference at line 'print $sock_send "$result";'. How can I have both
> sides to support sending messages?
1. You don't have the line 'print $sock_send "$result"' in your code.
2. You need to use bind() and listen() calls in your server (script B).
Get a book on network socket programming or check out 'perldoc perlipc'
and search for 'Sockets'.
3. You can send data both ways over a socket. There is no need to use
two sockets.
[ scripts snipped]
------------------------------
Date: Fri, 21 May 2004 12:47:19 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Password scheme/Persistent session...
Message-Id: <210520041247195176%jgibson@mail.arc.nasa.gov>
In article <237aaff8.0405202019.6ffc3e47@posting.google.com>, krakle
<krakle@visto.com> wrote:
> "John W. Kennedy" <jwkenne@attglobal.net> wrote in message
> news:<_55rc.106204$MH.21799388@news4.srv.hcvlny.cv.net>...
> > krakle wrote:
> > > The question IS ontopic to this group.
> >
> > No, it is not. You are asking a question about how the web works, not
> > how Perl works.
>
> I never asked how the web works or any sort of question to that
> nature. It was a question pertaining to sessions in mod_perl. Yes it
> will be used for a web site obviously but it DOESN'T make sense to ask
> a PERL question in a regular newsgroup dealing with the web that
> doesn't relate to PERL... Why is this so hard for you guys to
> understand...
Because we are morons.
------------------------------
Date: Sat, 22 May 2004 00:04:20 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Perl apache
Message-Id: <pan.2004.05.20.16.04.14.866354@aursand.no>
On Tue, 18 May 2004 16:40:35 -0400, Profetas wrote:
> If this question shouldn't be posted here, just ignore it I have been
> trying to config perl and apache.
Reading your post over and over: Are you speaking of Perl, Apache and
mod_perl, or just Perl and Apache?
Anyway: I would suggest that you install Apache _and_ mod_perl. Just
download the source for both of these from the Apache web site and be sure
to _read the documentation_ for how to install these simultaneously.
It's quite simple; Unpack both archives (Apache and mod_perl) and install
mod_perl. When asked about the Apache source dir, tell it where to find
it and the installation script will compile and install Apache for you.
Then download the latest Perl distribution (the source), and compile and
install it.
If this sounds scary, and you're running Red Hat, download the RPM
packages instead.
> My apache has been running for a while. and I already had perl
> installed, but I guessed a new installation would be better.
Why did you guess so?
--
Tore Aursand <tore@aursand.no>
"What we see depends mainly on what we look for." (Sir John Lubbock)
------------------------------
Date: 21 May 2004 11:47:19 -0700
From: jwarter@coldedge.com (Jim)
Subject: perl script to move email
Message-Id: <a712d8b1.0405211047.6fa8555e@posting.google.com>
Hi all,
I have written a perl script to read emails in my Outlook inbox and
then parse the emails based on part of the Subject line. What I need
to add is moving the emails to one of my Personal Folders after I am
finished with it, so that multiple days worth of data are not scanned.
This is so that when/if I go on vacation I don't have to worry about
putting the program on somebody elses PC. Anybody have any thoughts
here?
Thanks in advance,
Jim
------------------------------
Date: 21 May 2004 11:47:45 -0700
From: jwarter@coldedge.com (Jim)
Subject: perl script to move email
Message-Id: <a712d8b1.0405211047.6eb36c6c@posting.google.com>
Hi all,
I have written a perl script to read emails in my Outlook inbox and
then parse the emails based on part of the Subject line. What I need
to add is moving the emails to one of my Personal Folders after I am
finished with it, so that multiple days worth of data are not scanned.
This is so that when/if I go on vacation I don't have to worry about
putting the program on somebody elses PC. Anybody have any thoughts
here?
Thanks in advance,
Jim
------------------------------
Date: Fri, 21 May 2004 18:58:48 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: perl script to move email
Message-Id: <c8ljh8$ffd$1@wisteria.csv.warwick.ac.uk>
Quoth jwarter@coldedge.com (Jim):
> I have written a perl script to read emails in my Outlook inbox and
> then parse the emails based on part of the Subject line. What I need
> to add is moving the emails to one of my Personal Folders after I am
> finished with it, so that multiple days worth of data are not scanned.
> This is so that when/if I go on vacation I don't have to worry about
> putting the program on somebody elses PC. Anybody have any thoughts
> here?
How are you accessing the inbox? Win32::OLE? Reading the file directly?
I would have thought you could move mail between folders in the same way.
Ben
--
Every twenty-four hours about 34k children die from the effects of poverty.
Meanwhile, the latest estimate is that 2800 people died on 9/11, so it's like
that image, that ghastly, grey-billowing, double-barrelled fall, repeated
twelve times every day. Full of children. [Iain Banks] ben@morrow.me.uk
------------------------------
Date: Fri, 21 May 2004 19:43:54 +0000 (UTC)
From: "David H. Adler" <dha@panix2.panix.com>
Subject: Re: Perl vs PHP
Message-Id: <slrncasmvq.980.dha@panix2.panix.com>
On 2004-05-21, krakle <krakle@visto.com> wrote:
> Tad McClellan <tadmc@augustmail.com> wrote in message news:<slrncaoaj1.86e.tadmc@magna.augustmail.com>...
>> Wappler <wappler@gmx.net> wrote:
>>
>> > there is
>> > nothing you can't do with PERL.
>>
>>
>> There is nothing you can't do with Perl either.
>
> or perl or pErL or PErl... We all know what language he is referring
> to by when he says PERL. Ok tad, or Tad rather...
I think it's my turn. :-)
Please see the entry 'What's the difference between "perl" and "Perl"?'
in perlfaq1
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
You're still hoping for a new, good Star Trek series??? You must be
a Cubs fan.
- Michael G. Schwern
------------------------------
Date: Fri, 21 May 2004 19:46:56 +0000 (UTC)
From: "David H. Adler" <dha@panix2.panix.com>
Subject: Re: Perl vs PHP
Message-Id: <slrncasn5g.980.dha@panix2.panix.com>
On 2004-05-21, krakle <krakle@visto.com> wrote:
>
> If I had to start all over and select a language to learn from scratch
> FOR the web I'd use PHP because 1. It's easier 2. More convienent and
> 3. faster than CGI.
For the sake of accuracy, I just want to point out that #3 seems
somewhat off, as PHP is a programming language and CGI is an interface.
Apples and oranges, you know. :-)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
...whoever wrote it clearly didn't feel it was necessary to test it.
Funny thing how the worst programmers have the most faith in their
code... - Benjamin Holzman
------------------------------
Date: Fri, 21 May 2004 22:08:28 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl vs PHP
Message-Id: <2h75vpF9e19iU1@uni-berlin.de>
Juha Laiho wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> said:
>> Charlton Wilbur wrote:
>>> For instance, mod_perl can't really be run safely in a shared
>>> environment the way mod_php can, because mod_perl gives the
>>> user access to server internals, and an error can hose all the
>>> server children -- even those serving other virtual hosts.
>>
>> I would find it valuable if somebody could expand on (or provide
>> a pointer to info about) what it is that can actually happen with
>> mod_perl but not with mod_php.
>
> Hmm.. messing up with PerlChildInitHandler might well make a server
> completely inoperative - and I think PHP doesn't have comparable
> functionality (i.e. any access to Apache internals).
But PerlChildInitHandler may only appear in the global server
configuration and in virtual hosts, so that handler should typically
*not* be a problem in a shared environment.
> Also the various request-phase handlers provide very good hooks for
> extending Apache functionality
I have the impression that you can control the access to handlers via
the PerlOptions directive. As far as I understand, if you load
mod_perl, while configuring the server in a sensible way, you can well
let users in a shared environment run their programs under mod_perl
without giving them access to server critical handlers etc.
So let me re-phrase my question: Assuming a sensible server
configuration, what it is that can actually happen with mod_perl in a
shared environment but not with mod_php? ;-)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 21 May 2004 22:15:27 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: Perl vs PHP
Message-Id: <neosa0lqb6jln0q7hgi0uu4j4jp4rmoo96@4ax.com>
X-Ftn-To: David H. Adler
"David H. Adler" <dha@panix2.panix.com> wrote:
>> FOR the web I'd use PHP because 1. It's easier 2. More convienent and
>> 3. faster than CGI.
>
>For the sake of accuracy, I just want to point out that #3 seems
>somewhat off, as PHP is a programming language and CGI is an interface.
>Apples and oranges, you know. :-)
It seems that CGI stands for many things, apples and oranges are probably
ok, but how one could describe a very common "CGI == perl_script"?
--
Secure and instant E-pay for web shops
http://www.ouroboros.hr/?e-placanje
------------------------------
Date: 21 May 2004 11:11:28 -0700
From: botfood@yahoo.com (dan baker)
Subject: Re: perlmagick and image size
Message-Id: <13685ef8.0405211011.2e1b13d8@posting.google.com>
rossz <rosszNOSPAM@vamos-wentworth.org> wrote in message
> I need to adjust an image to a minimum size, but without distoring it,
> so I basically want to add space evenly around the existing image.
> ----------------------
a while back I wrote some tools to resize and build thumbnails for a
photo gallery site (http://www.NormsGallery.com) and I thought I'd
post the sub that does most of the image sizing for you to look at.
Its probably not the most glamorous way to do it, and perhaps Martin
will suggest some improvements. ;)
d
--------------
sub SizeAndThumb { my ( $FileNameIn ) = @_ ;
=head1 Purpose
This sub examines the current size of image passed in, and re-samples
so that it fits within the maximum allowable area defined by
$cMaxFullimgX , $cMaxFullimgY . If $cAnnotateText is defined, it will
also add the annotation.
Resampling is always done, even if the image is already the right
size
so that it get save with the right compression quality. Image might
have
been uploaded at higher quality with larger filesize.
Then, a thumbnail image is created with the name
$FileNameIn_$cMaxThumbimgX .
=head1 Input
$FileNameIn = relative path to a single image file to process
=head1 Output
- overwrites $FileNameIn, and creates a thumbnail image in the same
folders with a name based on $FileNameIn_$cMaxThumbimgX
- returns a 0 for success, or an error message string
=head1 Notes and Usage
# Note that subConfig.pl MUST be required in main:: because it uses
parameters:
#
( $cMaxFullimgX , $cMaxFullimgY ) = (600,400);
( $cMaxThumbimgX , $cMaxThumbimgY ) = (100,100);
$cImageQuality = 75 ; # value 10-90
$cAnnotateFont = '@Comic.ttf' ;
$cAnnotatePointsize = 11 ;
$cAnnotateText = '(c)2000 www.NormsGallery.com' ; # set undef to skip
annotation
$cLowSRCText = '(c)2000 www.NormsGallery.com' ; # set undef to image
label
$ErrorMsg = &SizeAndThumb( $FileNameIn ); # returns 0 for success,
# $ErrorMsg for failure
This sub does NOT die on error, but does return an error message, so
the calling script can decide to die or continue.
=head1 History
written 10/18/2000 - Dan Baker, dan_at_dtbakerprojects.com
revised 12/3/2000 - changed to use Scale() instead of Sample()
- recoded Annotate() section for light outline
=cut
# ------------------------------------------------------------------------------
# declarations
use lib "./lib/perl5/site_perl/5.005/i386-linux" ;
use Image::Magick;
# local var declarations
my $tempString = "";
my $ErrMsg = "";
my $DoSample = "true" ;
# ------------------------------------------------------------------------------
# -------------------------------- executable ---------------
# read $FileNameIn to new object
# -----
my $image = Image::Magick->new;
$ErrMsg = $image->Read( $FileNameIn ) ;
if ($ErrMsg ) {
return( "$ErrMsg : Image-Magick could not read $FileNameIn " );
} elsif ( $cDEBUG ) {
print DEBUG_LOG "read $FileNameIn into ImageMagick object. \n" ;
}
# re-size
# -----
$ErrMsg = $image->Scale( geometry=>"${cMaxFullimgX}x${cMaxFullimgY}"
);
if ($ErrMsg ) {
return( "$ErrMsg : Image-Magick could not re-size $FileNameIn " );
} elsif ( $cDEBUG ) {
print DEBUG_LOG "resized $FileNameIn to ${MaxFullimgX}x${MaxFullimgY}
\n" ;
}
# annotate if text is defined
# -----
my $DidAnnotate = 0;
if ( $cAnnotateText ) { # only annotate if a text string is defined
print DEBUG_LOG "\t attempting to annotate. \n" if $cDEBUG ;
# we cant trust gravity=>'South' or 'North
# so figure offset manually
# -----
# get actual scaled size
my ( $imgX , $imgY ) = $image->Get('columns', 'rows');
my ( $Xoffset , $Yoffset ) = (0 , 0) ;
my $AnnotateOutline = 'LightGrey' ;
my $AnnotatePen = 'Black' ;
# figure out $Xoffset
# -----
$Xoffset = int( $imgX/2 -
(length($cAnnotateText)*($cAnnotatePointsize/1.5))/2 ) ;
# set up for differences between v4.2.9 and 5.2.4
# -----
if ( $^O =~ m/mswin32/i ) { # calculations for v4.2.9 on win98
# use $cAnnotatePointsize from config file
$Yoffset = int($imgY*.90) ;
} else { # calculations for v5.2.4 on LINUX
$cAnnotatePointsize += 3 ; # has to be set bigger to match
$Yoffset = int($imgY*.93) ;
}
# insert 8 instances of annotation in outline positions and color,
# 1 pixel offset in all directions
$image->Annotate( text=>$cAnnotateText ,
font=> $cAnnotateFont ,
pointsize=> $cAnnotatePointsize ,
pen=> $AnnotateOutline ,
x=> $Xoffset -1 ,
y=> $Yoffset -1 ,
);
$image->Annotate( text=>$cAnnotateText ,
font=> $cAnnotateFont ,
pointsize=> $cAnnotatePointsize ,
pen=> $AnnotateOutline ,
x=> $Xoffset -1 ,
y=> $Yoffset ,
);
$image->Annotate( text=>$cAnnotateText ,
font=> $cAnnotateFont ,
pointsize=> $cAnnotatePointsize ,
pen=> $AnnotateOutline ,
x=> $Xoffset -1 ,
y=> $Yoffset +1 ,
);
$image->Annotate( text=>$cAnnotateText ,
font=> $cAnnotateFont ,
pointsize=> $cAnnotatePointsize ,
pen=> $AnnotateOutline ,
x=> $Xoffset ,
y=> $Yoffset +1 ,
);
$image->Annotate( text=>$cAnnotateText ,
font=> $cAnnotateFont ,
pointsize=> $cAnnotatePointsize ,
pen=> $AnnotateOutline ,
x=> $Xoffset +1 ,
y=> $Yoffset +1 ,
);
$image->Annotate( text=>$cAnnotateText ,
font=> $cAnnotateFont ,
pointsize=> $cAnnotatePointsize ,
pen=> $AnnotateOutline ,
x=> $Xoffset +1 ,
y=> $Yoffset +0 ,
);
$image->Annotate( text=>$cAnnotateText ,
font=> $cAnnotateFont ,
pointsize=> $cAnnotatePointsize ,
pen=> $AnnotateOutline ,
x=> $Xoffset +1 ,
y=> $Yoffset -1 ,
);
$image->Annotate( text=>$cAnnotateText ,
font=> $cAnnotateFont ,
pointsize=> $cAnnotatePointsize ,
pen=> $AnnotateOutline ,
x=> $Xoffset ,
y=> $Yoffset -1 ,
);
# insert annotation on top of outline
$ErrMsg =
$image->Annotate( text=>$cAnnotateText ,
font=> $cAnnotateFont ,
pointsize=> $cAnnotatePointsize ,
pen=> $AnnotatePen ,
x=> $Xoffset ,
y=> $Yoffset ,
);
if ( $ErrMsg ) {
$tempString = "\t $ErrMsg : Image-Magick failed to annotate
$FileNameIn \n" ;
print DEBUG_LOG $tempString if $cDEBUG ;
return( $tempString );
} else {
print DEBUG_LOG "\t ...annotated \n" if $cDEBUG ;
$DidAnnotate = 'true' ;
}
}
# save the sized image
# ------
if ( $DidAnnotate or $DoSample ) {
$ErrMsg = $image->Write( filename=>$FileNameIn ,
quality=>$cImageQuality );
if ( $ErrMsg ) {
return( "$ErrMsg : Image-Magick failed to overwrite ".
"$FileNameIn with resampled image" );
} elsif ( $cDEBUG ) {
print DEBUG_LOG "\t ...saved \n"
}
}
# re-sample for thumbnail
# -----
$ErrMsg = $image->Scale( geometry=>"${cMaxThumbimgX}x${cMaxThumbimgY}"
);
if ($ErrMsg ) {
return( "$ErrMsg : Image-Magick failed to resample $FileNameIn to ".
"thumbnail ${cMaxThumimgX}x${cMaxThumimgY} " ) ;
} elsif ( $cDEBUG ) { print DEBUG_LOG "\t thumbnailed ok... \n" }
# figure out name and write thumbnail image
# -----
my $FileNameThum = $FileNameIn ;
$FileNameThum =~ s/(.*)\.(.+)$/$1/ ; # grab base filename and
extension
$FileNameThum = "$1_$cMaxThumbimgX.$2" ; # insert the thumb X to
filename
$ErrMsg = $image->Write( filename=>$FileNameThum ,
quality=>$cImageQuality );
if ( $ErrMsg ) {
return( "$ErrMsg : Image-Magick failed to write $FileNameThum
thumbnail image" ) ;
} elsif ( $cDEBUG ) { print DEBUG_LOG "\t ...saved thumbnail to
$FileNameThum \n" }
undef $image; # release object memory
print DEBUG_LOG scalar(localtime).
"finished SizeAndThumb for $FileNameIn and $FileNameThum \n" if
$cDEBUG;
# ------------------------------------------------------------------------------
return (0) ; # return success, no error message
}
1 ; # done.....
------------------------------
Date: Fri, 21 May 2004 20:24:44 +0200
From: Thomas Schweikle <tpsX@vr-web.de>
Subject: Problem installing modules
Message-Id: <2h70hhF9qcf5U1@uni-berlin.de>
Hi!
Trying to install "AppConfig":
C:\HOME\xch4008>perl -MCPAN -e"install AppConfig"
CPAN: Storable loaded ok
Going to read C:\HOME\xch4008\.cpan\Metadata
Database was generated on Fri, 21 May 2004 14:37:43 GMT
Running install for module AppConfig
Running make for A/AB/ABW/AppConfig-1.56.tar.gz
CPAN: Digest::MD5 loaded ok
CPAN: Compress::Zlib loaded ok
Checksum for
C:\HOME\xch4008\.cpan\sources\authors\id\A\AB\ABW\AppConfig-1.56.tar.gz
ok
Scanning cache C:\HOME\xch4008\.cpan\build for sizes
AppConfig-1.56/
AppConfig-1.56/t/
AppConfig-1.56/t/cgi.t
AppConfig-1.56/t/args.t
AppConfig-1.56/t/appconfig.t
AppConfig-1.56/t/novars.t
AppConfig-1.56/t/block.t
AppConfig-1.56/t/sys.t
AppConfig-1.56/t/getopt.t
AppConfig-1.56/t/flag.t
AppConfig-1.56/t/default.t
AppConfig-1.56/t/compact.t
AppConfig-1.56/t/state.t
AppConfig-1.56/t/multi.t
AppConfig-1.56/t/file.t
AppConfig-1.56/t/const.t
AppConfig-1.56/lib/
AppConfig-1.56/lib/AppConfig/
AppConfig-1.56/lib/AppConfig/File.pm
AppConfig-1.56/lib/AppConfig/CGI.pm
AppConfig-1.56/lib/AppConfig/Args.pm
AppConfig-1.56/lib/AppConfig/Getopt.pm
AppConfig-1.56/lib/AppConfig/State.pm
AppConfig-1.56/lib/AppConfig/Sys.pm
AppConfig-1.56/lib/AppConfig.pm
AppConfig-1.56/Changes
AppConfig-1.56/MANIFEST
AppConfig-1.56/TODO
AppConfig-1.56/README
AppConfig-1.56/Makefile.PL
Removing previously used C:\HOME\xch4008\.cpan\build\AppConfig-1.56
CPAN.pm: Going to build A/AB/ABW/AppConfig-1.56.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for AppConfig
-- OK
Running make test
test -- NOT OK
Running make install
make test had returned bad status, won't install without force
Now two questions:
1. What may be missing?
2. How to force installation?
--
Thomas
------------------------------
Date: Fri, 21 May 2004 17:17:59 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Problem installing modules
Message-Id: <7murc.89891$325.1966731@news20.bellglobal.com>
"Thomas Schweikle" <tpsX@vr-web.de> wrote in message
news:2h70hhF9qcf5U1@uni-berlin.de...
> Hi!
>
> Trying to install "AppConfig":
>
> C:\HOME\xch4008>perl -MCPAN -e"install AppConfig"
>
Since you're a bit thin on details about what you're doing, I'll guess that
you were trying to run the cpan shell and it died, so you're now trying to
install the module it died on? I'll also guess that you aren't using cygwin,
and give you a hint that there is no make on Windows.
If you're using ActivePerl, use ppm to install modules.
Matt
------------------------------
Date: Fri, 21 May 2004 20:50:01 +0200
From: rduke15 <rduke15@hotmail__.__com>
Subject: quoting in perl command in shell script
Message-Id: <c8lj0q$dn9$1@newshispeed.ch>
Hi,
I have a weird problem with this simple bash script calling a Perl
command in a variable. I don't understand what's wrong.
$ cat test.sh
#!/bin/sh
set -x
cmd="perl -e 'print 1+2'"
$cmd
$ ./test.sh
+ cmd=perl -e 'print 1+2'
+ perl -e 'print 1+2'
Can't find string terminator "'" anywhere before EOF at -e line 1.
I also tried all sorts of variations with the quotes, but nothing seems
to work.
Thanks for any help...
------------------------------
Date: Fri, 21 May 2004 15:26:01 -0400
From: Barry Margolin <barmar@alum.mit.edu>
Subject: Re: quoting in perl command in shell script
Message-Id: <barmar-E5E728.15260121052004@comcast.dca.giganews.com>
In article <c8lj0q$dn9$1@newshispeed.ch>,
rduke15 <rduke15@hotmail__.__com> wrote:
> Hi,
>
> I have a weird problem with this simple bash script calling a Perl
> command in a variable. I don't understand what's wrong.
>
> $ cat test.sh
>
> #!/bin/sh
> set -x
> cmd="perl -e 'print 1+2'"
> $cmd
>
> $ ./test.sh
>
> + cmd=perl -e 'print 1+2'
> + perl -e 'print 1+2'
> Can't find string terminator "'" anywhere before EOF at -e line 1.
>
>
> I also tried all sorts of variations with the quotes, but nothing seems
> to work.
Try: eval $cmd
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
------------------------------
Date: Fri, 21 May 2004 21:42:50 +0200
From: rduke15 <rduke15@hotmail__.__com>
Subject: Re: quoting in perl command in shell script
Message-Id: <c8lm3r$g5v$1@newshispeed.ch>
>>$ cat test.sh
>>
>> #!/bin/sh
>> set -x
>> cmd="perl -e 'print 1+2'"
>> $cmd
>>
>>$ ./test.sh
>>
>> + cmd=perl -e 'print 1+2'
>> + perl -e 'print 1+2'
>> Can't find string terminator "'" anywhere before EOF at -e line 1.
>>
>>
>>I also tried all sorts of variations with the quotes, but nothing seems
>>to work.
>
>
> Try: eval $cmd
Yes, that works!
Thanks a lot.
------------------------------
Date: Fri, 21 May 2004 13:29:16 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Sockets: receiving data
Message-Id: <210520041329166224%jgibson@mail.arc.nasa.gov>
In article <c8kurh$169i@newton.cc.rl.ac.uk>, Bigus
<someone@somewhere.com> wrote:
> > > my $email = 'my@email.address'
> >
> > Missing semi-colon at the end of the line above. Is this the code you
> > actually ran?
>
> No.. I had to change that line when copying it into the post, lest I be
> spammed to eternity.
>
> > > my $cmd = "review LISTNAME msg pw=password";
> > >
> > > # --- Connect to Listserv --- #
> > >
> > > use IO::Socket;
> > > my $lsv = IO::Socket::INET->new(
> > > Proto => "tcp",
> > > PeerAddr => "localhost",
> > > PeerPort => '2306')
> > > or die print "Connection problem :$!";
> >
> > You create a TCP socket here.
> > ...
> >
> > > # send command header
> > > print $lsv "1B".$bin;
> > > recv($lsv, my $ans, 100, 0);
> > > if($ans !~ /^250/){print "Failed because $ans\n"; exit;}
> >
> > recv is for UDP.
>
> Oh. Sounds kind of fudnamental.. it works for smaller amounts of data
> though. The main reason I am using that is because there's an example script
> in C that does what I'm trying to do here. I don't understand half of it,
> but it does use the recv command and is definitely over TCP, since the
> interface is called TCPGUI. Maybe C is different in the way it handles
> sockets or something.
Perl calls the socket functions in the C library for your platform, so
the behavior should be the same. Perl recv calls C recvfrom, and is
definitely a UDP function.
Stick to the object-oriented versions of the socket functions. E.g.,
use $lsv->recv(...) instead of recv(...) (although as you have
discovered you should be using read instead of recv). You are calling
the basic Perl recv function with a reference to an IO::Socket::INET
object instead of a file handle as the first argument. That may or may
not work.
>
> Is there a quick-fix TCP alternative to recv in this context, or am I going
> to have to do a loop again and get into a loop again and revisit the block
> scenario?
>
> Thanks
> Bigus
>
>
>
------------------------------
Date: 21 May 2004 13:12:09 -0700
From: krpotter@co.douglas.or.us (Kevin Potter)
Subject: String search/match question
Message-Id: <64f69747.0405211212.9493543@posting.google.com>
I have a string, that I need to find the first occurance of a
particular known character in ("index" comes to mind), but with a
twist.
The problem is, I need to find the first occurance of this character
that is not enclosed in brackets "[]" in this string.
Example string:
"abcdefg[extra]hijklmn[texas]opqrstuvwxYZabc[tex]defghijklmnopqrstuvwxyz".
How can I find the POSITION number of the first occurance of the
letter "x" that is not enclosed in the bracketed text (the one I want
is the one directly before the capital YZ).
I've tried numerous versions indexing this and that, comparing this to
the positions of the first and successive brackets, but cannot come up
with a realiable method.
Any thoughts, or pointers would be really appreciated. Maybe a fancy
regex would be able to do this?
------------------------------
Date: Fri, 21 May 2004 22:35:56 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: String search/match question
Message-Id: <oqpsa0t6pcbrah8iqu2o7m6oh26rs6ido8@4ax.com>
X-Ftn-To: Kevin Potter
krpotter@co.douglas.or.us (Kevin Potter) wrote:
>How can I find the POSITION number of the first occurance of the
>letter "x" that is not enclosed in the bracketed text (the one I want
>is the one directly before the capital YZ).
>
>I've tried numerous versions indexing this and that, comparing this to
>the positions of the first and successive brackets, but cannot come up
>with a realiable method.
>
>Any thoughts, or pointers would be really appreciated. Maybe a fancy
>regex would be able to do this?
It's not fancy but it should be reliable. :)
my $s =
"abcdefg[extra]hijklmn[texas]opqrstuvwxYZabc[tex]defghijklmnopqrstuvwxyz";
s/(\[.+?\])/' ' x length $1/ge, $_ = index $_,'x' for my $pos = $s;
print "$pos\n";
--
Secure and instant E-pay for web shops
http://www.ouroboros.hr/?e-placanje
------------------------------
Date: Fri, 21 May 2004 20:39:09 GMT
From: "Bigus" <someone@somewhere.com>
Subject: Re: String search/match question
Message-Id: <f105985d50c25b3e152cdefb553ec7c8@news.teranews.com>
"Matija Papec" <perl@my-header.org> wrote in message
news:oqpsa0t6pcbrah8iqu2o7m6oh26rs6ido8@4ax.com...
> X-Ftn-To: Kevin Potter
>
> krpotter@co.douglas.or.us (Kevin Potter) wrote:
> >How can I find the POSITION number of the first occurance of the
> >letter "x" that is not enclosed in the bracketed text (the one I want
> >is the one directly before the capital YZ).
> >
> >I've tried numerous versions indexing this and that, comparing this to
> >the positions of the first and successive brackets, but cannot come up
> >with a realiable method.
> >
> >Any thoughts, or pointers would be really appreciated. Maybe a fancy
> >regex would be able to do this?
>
> It's not fancy but it should be reliable. :)
>
> my $s =
> "abcdefg[extra]hijklmn[texas]opqrstuvwxYZabc[tex]defghijklmnopqrstuvwxyz";
>
> s/(\[.+?\])/' ' x length $1/ge, $_ = index $_,'x' for my $pos = $s;
> print "$pos\n";
think you might need to add 1 to that.. it's cleverer than my solution
though:
$match = "x";
$str =
"abcdefg[extra]hijklmn[texas]opqrstuvwxYZabc[tex]defghijklmnopqrstuvwxyz";
($ms) = $str =~ /(?:^|\])[^\[]*$match(.*$)/;
print length($str)-length($ms);
Bigus
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6595
***************************************