[25857] in Perl-Users-Digest
Perl-Users Digest, Issue: 8092 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 18 14:05:17 2005
Date: Wed, 18 May 2005 11:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 18 May 2005 Volume: 10 Number: 8092
Today's topics:
Re: DBI: adding columns to table xhoster@gmail.com
no such file or directory? <geoff.cox@notquitecorrectfreeuk.com>
Perl programmer needed jbg00d@pontiac-fiero.com
semi-opacity with GD <richard.bennett@nospam.skynet.be>
Re: test if statement from database xhoster@gmail.com
Re: test if statement from database <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 May 2005 17:23:17 GMT
From: xhoster@gmail.com
Subject: Re: DBI: adding columns to table
Message-Id: <20050518132317.407$bK@newsreader.com>
"Bigus" <someone@somewhere.com> wrote:
...
> That's where $k = "owner". If I remove the single quotes round $k in teh
> ALTER TABLE line then the owner column is created fine, but of course it
> then falls over when $k = "reply-to" because of the hyphen.
>
> When I use PHPMyadmin to create the owner column it works fine and tells
> me it's used the syntax:
>
> ALTER TABLE `list_headers` ADD `owner` TEXT
If PHPMyadmin told you that it used backticks, and that seemed to work,
then I would suggest that you try using backticks in your Perl program.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Wed, 18 May 2005 15:22:40 GMT
From: Geoff Cox <geoff.cox@notquitecorrectfreeuk.com>
Subject: no such file or directory?
Message-Id: <hsmm8118oovhc569m96htl6on942d91i9n@4ax.com>
Hello,
I am using File::Find and wish to use the following but ger error
"cannot open assets/i-<filename.htm> : No such file or directory at
index.pl line 67".
open OUT, ">>assets/i-$name" or die "cannot open assets/$name : $!" ;
the structure is similar to
folder1
folder2/assets
folder3
and I am guessing that the error comes because the assets directory
is not always found ? If I use simply i-$name, then the code works.
How do I correct this?
Thanks
Geoff
------------------------------
Date: Wed, 18 May 2005 15:34:48 GMT
From: jbg00d@pontiac-fiero.com
Subject: Perl programmer needed
Message-Id: <d6fnar0ohi@news3.newsguy.com>
Hi,
I have a replicating page project that i need built. also, an image gallery
that's links to it.
If you're interested, please contact me at jgb00d@pontiac-fiero.com
------------------------------
Date: Wed, 18 May 2005 19:54:21 +0200
From: Richard Bennett <richard.bennett@nospam.skynet.be>
Subject: semi-opacity with GD
Message-Id: <428b814b$0$13326$ba620e4c@news.skynet.be>
Hi,
i tried this question in comp.lang.perl.modules without any luck - maybe
someone here has an idea about it? :
I have GD2.0.33, and the most recent GD.pm on Linux.
I want to write a script that will load a PNG image, and make the image
semi-transparent.
I want to show this image over another one in the browser, and be able to
see the background image through the top one.
(I know this can be done in CSS, but am looking for a Firefox-only solution
using PNG alpha-channel)
I can make an image which does the right thing when I create a new image
like this:
#!/usr/bin/perl -w
use GD;
my $im; # The Image object
my $xsize = 160; my $ysize = 160;
my $bgcol = colourARGB( 70, 100, 255, 255 );
$im = new GD::Image->newTrueColor( $xsize, $ysize )
|| die "$0: Failed to create image -- $!\n";
$im->saveAlpha(1);
$im->alphaBlending(0);
$im->filledRectangle( 0, 0, $xsize - 1, $ysize - 1, $bgcol );
$im->alphaBlending(1);
binmode STDOUT;
print "Content-type: image/png\n\n";
print $im->png;
sub colourARGB($$$$) {
my $alpha = shift; my $red = shift;
my $green = shift; my $blue = shift;
# Alpha is in range 0 (opaque) to 127 (fully transparent),
# R, G, B in range 0 .. 255. Force values into range.
$alpha &= 0x7f; $red &= 0xff;
$green &= 0xff; $blue &= 0xff;
return $alpha << 24 | $red << 16 | $green << 8 | $blue;
}
But I cannot seem to find out how to manipulate an existing image to make it
semi-opaic. I tried like this:
#!/usr/bin/perl -w
use GD;
my $im; # The Image object
my $bgcol = colourARGB( 50, 200, 200, 200 );
$im = newFromPng GD::Image('top.png');
$im->saveAlpha(1);
$im->alphaBlending(0);
binmode STDOUT;
print "Content-type: image/png\n\n";
print $im->png;
sub colourARGB($$$$) {
my $alpha = shift; my $red = shift; my $green = shift; my $blue =
shift;
# Alpha is in range 0 (opaque) to 127 (fully transparent),
# R, G, B in range 0 .. 255. Force values into range.
$alpha &= 0x7f; $red &= 0xff; $green &= 0xff; $blue &= 0xff;
return $alpha << 24 | $red << 16 | $green << 8 | $blue;
}
The image displays ok, but I can't see how to add the opacity in.
Thanks for any tips,
richard
------------------------------
Date: 18 May 2005 17:47:49 GMT
From: xhoster@gmail.com
Subject: Re: test if statement from database
Message-Id: <20050518134749.474$9x@newsreader.com>
ef <efbo@hotmail.com> wrote:
> Hi,
>
> I have an compare statement stored in the database. e.g. 'fieldx > 10'.
> I read that and want to use that directly in a perl statement, something
> like
>
> $iffromdatabase =~ s/fieldx/realvalueoffieldx/;
> if ( /$iffromdatabase/e ){
> .....
> }
>
> can this be done somehow?
You could probably do this with eval, but you would probably be better
off doing something like:
my ($field,$op,$constant) = $fromdb =~ /$(.*) (>) (.*)$/ or die;
if (apply_logic($valueof{$field},$op,$constant)) {
#...
};
sub apply_logic {
return $_[0] < $_[2] if $_[1] eq '<';
return $_[0] > $_[2] if $_[1] eq '>';
return $_[0] == $_[2] if $_[1] eq '==';
die "Don't know how to $_[1]"
};
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Wed, 18 May 2005 17:53:17 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: test if statement from database
Message-Id: <Xns965A8D1EC31C0asu1cornelledu@127.0.0.1>
xhoster@gmail.com wrote in news:20050518134749.474$9x@newsreader.com:
> ef <efbo@hotmail.com> wrote:
>> I have an compare statement stored in the database. e.g. 'fieldx >
>> 10'. I read that and want to use that directly in a perl statement,
>> something like
>>
>> $iffromdatabase =~ s/fieldx/realvalueoffieldx/;
>> if ( /$iffromdatabase/e ){
>> .....
>> }
...
> You could probably do this with eval, but you would probably be better
> off doing something like:
>
> my ($field,$op,$constant) = $fromdb =~ /$(.*) (>) (.*)$/ or die;
Based on apply_logic below, this should probably be (untested):
my ($field,$op,$constant) = $fromdb =~ /$(.*) (<|=|>) (.*)$/ or die;
> sub apply_logic {
> return $_[0] < $_[2] if $_[1] eq '<';
> return $_[0] > $_[2] if $_[1] eq '>';
> return $_[0] == $_[2] if $_[1] eq '==';
> die "Don't know how to $_[1]"
> };
Nice, very nice.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
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 8092
***************************************