[31911] in Perl-Users-Digest
Perl-Users Digest, Issue: 3174 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 14 16:09:26 2010
Date: Thu, 14 Oct 2010 13:09:09 -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 Thu, 14 Oct 2010 Volume: 11 Number: 3174
Today's topics:
@INC <seikioh1@gmail.com>
Re: Communication across Perl scripts <tzz@lifelogs.com>
Re: FAQ 3.30 What's MakeMaker? <john@example.invalid>
Re: FAQ 3.30 What's MakeMaker? (Randal L. Schwartz)
Re: FAQ 4.38 Why don't my <<HERE documents work? <john@example.invalid>
Re: FAQ 4.38 Why don't my <<HERE documents work? <john@example.invalid>
Re: FAQ 4.38 Why don't my <<HERE documents work? <tadmc@seesig.invalid>
Re: FAQ 4.38 Why don't my <<HERE documents work? <tadmc@seesig.invalid>
Re: get value of variable number of arguments <mvdwege@mail.com>
Gtk2 <greymausg@mail.com>
Re: hashing for absent but not present cases (SOLVED) <ela@yantai.org>
Re: hashing for absent but not present cases <marc.girod@gmail.com>
Re: hashing for absent but not present cases <ela@yantai.org>
Re: hashing for absent but not present cases <tadmc@seesig.invalid>
Re: hashing for absent but not present cases <ela@yantai.org>
Re: hashing for absent but not present cases <jurgenex@hotmail.com>
Re: hashing for absent but not present cases sln@netherlands.com
Re: Help with Hash <tadmc@seesig.invalid>
Re: Help with Hash <pradeep.bg@gmail.com>
Re: Help with Hash <tadmc@seesig.invalid>
simple problem using GD <juliani.moon@gmail.com>
Re: toy list processing problem: collect similar terms <hjp-usenet2@hjp.at>
Re: why does this happen? <hjp-usenet2@hjp.at>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 14 Oct 2010 12:42:22 -0700 (PDT)
From: Sam Ohn <seikioh1@gmail.com>
Subject: @INC
Message-Id: <5bbdb831-9edb-4bfa-a7cf-eb3ee33597ae@c13g2000vbr.googlegroups.com>
I want to write perl script to load data to mysql database and wrote a
simple test code:
use mysql;
$host = "localhost";
$db="testdb";
$user="test";
$pwd="test";
$connect = connect($host, $db , $user, $pwd);
When the script was run, perl returned error message:
Can't locate mysql.pm in @INC (@INC contains: C:/xampp/perl/lib C:/
xampp/perl/site/lib .) at c:\tsql.pl line 1.
BEGIN failed--compilation aborted at c:\tsql.pl line 1.
mysql module is under c:\xampp/perl/site/lib/DBD and I tried to
specify the sub directory where the module is located.
use mysql 'DBD';
But, it did not solve the problem.
The system is Windows 7 installed the xampp
I appreciate any comments and suggestion.
------------------------------
Date: Thu, 14 Oct 2010 09:53:43 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Communication across Perl scripts
Message-Id: <87lj60x1u0.fsf@lifelogs.com>
On Tue, 12 Oct 2010 22:24:47 +0200 "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
PJH> On 2010-10-12 00:59, Ted Zlatanov <tzz@lifelogs.com> wrote:
>> On Mon, 11 Oct 2010 14:25:59 -0700 (PDT) "C.DeRykus" <derykus@gmail.com> wrote:
CD> With a named pipe though, each script just deals with the named file
CD> for reading or writing while the OS takes care of the messy IPC
CD> details for you. The 2nd script will just block until data is
CD> available so running order isn't a concern. As long as the two
CD> scripts are running more or less concurrently, I would guess memory
CD> use will be manageable too since the reader will be draining the
CD> pipe as the data arrives.
>>
>> The only warning I have there is that pipes are pretty slow and have
>> small buffers by default in the Linux kernel (assuming Linux).
PJH> Hmm. On my system (a 1.86 GHz Core2 - not ancient, but not the latest
PJH> and greatest, either) I can transfer about 800 MB/s through a pipe at
PJH> 32 kB buffer size. For larger buffers it gets a bit slower, but a buffer
PJH> size of 1MB is still quite ok.
Hmm, sorry for stating that badly.
The biggest problem is that pipes *block* normally. So even if your
reader is slow only once in a while, as long as you're using the default
buffer (which is small), your writer will block too. In my situation
(the writer was receiving data from TIBCO) that was deadly.
I meant to say that but somehow it turned into "pipes are slow" between
brain and keyboard. Sorry.
PJH> You may confuse that with other systems. Windows pipes have a
PJH> reputation for being slow.
Yes, on Windows we had even more trouble for many reasons. But I was
only talking about Linux so I won't take that bailout :)
>> I forget exactly why, I think it's due to terminal disciplines or
>> something, I didn't dig too much.
PJH> Unix pipes have nothing to do with terminals. Originally they were
PJH> implemented as files, BSD 4.x reimplemented them on top of Unix sockets.
PJH> I don't now how Linux implements them, but I'm quite sure that no
PJH> terminals are involved, and certainly no terminal disciplines.
PJH> Are you confusing them with ptys, perhaps?
Probably. I was on a tight deadline and the pipe approach simply did
not work, so I couldn't investigate in more detail. There's a lot more
resiliency in a file drop approach, too: if either side dies, the other
one is not affected. There is no leftover mess like with shared memory,
either. So I've been pretty happy with the file drop.
Ted
------------------------------
Date: Thu, 14 Oct 2010 13:28:50 -0600
From: John Smith <john@example.invalid>
Subject: Re: FAQ 3.30 What's MakeMaker?
Message-Id: <IMudnXYDYrhuxCrRnZ2dnUVZ5gadnZ2d@giganews.com>
Ben Morrow wrote:
> Quoth John Smith <john@example.invalid>:
>> PerlFAQ Server wrote:
>>
>>> 3.30: What's MakeMaker?
>>>
>>> (contributed by brian d foy)
>>>
>>> The "ExtUtils::MakeMaker" module, better known simply as "MakeMaker",
>>> turns a Perl script, typically called "Makefile.PL", into a Makefile.
>>> The Unix tool "make" uses this file to manage dependencies and actions
>>> to process and install a Perl distribution.
>> Does anyone have an example of this?
>
> Pick a module on CPAN. It will have either a Makefile.PL or a Build.PL,
> and if it has a Makefile.PL it will use either MakeMaker or
> Module::Install.
I see. I see a Makefile.PL in a lot of such listings. Why not this one?
http://search.cpan.org/~bshanks/Wiki-Gateway-0.001991/lib/Wiki/Gateway.pm
?
--
John Smith
------------------------------
Date: Thu, 14 Oct 2010 12:52:27 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: FAQ 3.30 What's MakeMaker?
Message-Id: <861v7s4kn8.fsf@red.stonehenge.com>
>>>>> "John" == John Smith <john@example.invalid> writes:
John> I see. I see a Makefile.PL in a lot of such listings. Why not this one?
John> http://search.cpan.org/~bshanks/Wiki-Gateway-0.001991/lib/Wiki/Gateway.pm
Blind, perhaps?
http://cpansearch.perl.org/src/BSHANKS/Wiki-Gateway-0.001991/
It's in there.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion
------------------------------
Date: Thu, 14 Oct 2010 02:36:01 -0600
From: John Smith <john@example.invalid>
Subject: Re: FAQ 4.38 Why don't my <<HERE documents work?
Message-Id: <vYKdnVQka4psXSvRnZ2dnUVZ5oKdnZ2d@giganews.com>
Tad McClellan wrote:
>> THAT
>> print fix(<<THIS);
>> usr/local/
>> usr/local/doc
>> usr
>> THIS
>
>
> It appears that fix() was not written to expect an argument
> that does not need any fixing.
>
> You can fix fix() (heh) by allowing zero leading spaces in the
> else clause rather than requiring at least one leading space:
>
> ($white, $leader) = (/^(\s*)/, '');
> ^
> ^
>
Ok.
> It looks to see whether each line begins with a common substring, and if
> so, strips that substring off.
I thought it was going to strip off usr, but apparently that's not the idea.
--
John Smith
------------------------------
Date: Thu, 14 Oct 2010 02:36:47 -0600
From: John Smith <john@example.invalid>
Subject: Re: FAQ 4.38 Why don't my <<HERE documents work?
Message-Id: <vYKdnVcka4qCXCvRnZ2dnUVZ5oKdnZ2d@giganews.com>
Tad McClellan wrote:
> brian d foy <brian.d.foy@gmail.com> wrote:
>> In article <2ic9o7-m472.ln1@osiris.mauzo.dyndns.org>, Ben Morrow
>> <ben@morrow.me.uk> wrote:
>>
>>> \g is a new (5.12?) means of unambiguously making a backref, without
>>> risking confusion with octal interpolation:
>> It's in 5.010. It's even in Learning Perl. :)
>
>
> I ought to read that book again sometime...
>
>
Do you think that would be a good book for me?
--
John smith
------------------------------
Date: Thu, 14 Oct 2010 08:37:21 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: FAQ 4.38 Why don't my <<HERE documents work?
Message-Id: <slrnibe22s.916.tadmc@tadbox.sbcglobal.net>
John Smith <john@example.invalid> wrote:
> Tad McClellan wrote:
>> brian d foy <brian.d.foy@gmail.com> wrote:
>>> In article <2ic9o7-m472.ln1@osiris.mauzo.dyndns.org>, Ben Morrow
>>> <ben@morrow.me.uk> wrote:
>>>
>>>> \g is a new (5.12?) means of unambiguously making a backref, without
>>>> risking confusion with octal interpolation:
>>> It's in 5.010. It's even in Learning Perl. :)
>>
>>
>> I ought to read that book again sometime...
>>
>>
>
> Do you think that would be a good book for me?
Yes.
I learned Perl from that book 15 years ago.
(It is now in its 5th Edition, I used the 1st Edition.)
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Thu, 14 Oct 2010 08:41:02 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: FAQ 4.38 Why don't my <<HERE documents work?
Message-Id: <slrnibe29o.916.tadmc@tadbox.sbcglobal.net>
John Smith <john@example.invalid> wrote:
> Tad McClellan wrote:
>
>>> THAT
>>> print fix(<<THIS);
>>> usr/local/
>>> usr/local/doc
>>> usr
>>> THIS
>> It looks to see whether each line begins with a common substring, and if
>> so, strips that substring off.
>
> I thought it was going to strip off usr, but apparently that's not the idea.
I can see where you would think that from reading the word description,
but, looking at the code, it should be obvious that it should have said:
... each line begins with a common non-word substring
if (/^\s*(?:([^\w\s]+)(\s*).*\n)(?:\s*\1\2?.*\n)+$/) {
^^^^^^^^
^^^^^^^^ prefix must not contain word chars nor whitespace
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Thu, 14 Oct 2010 09:12:22 +0200
From: Mart van de Wege <mvdwege@mail.com>
Subject: Re: get value of variable number of arguments
Message-Id: <86zkuhuu21.fsf@gareth.avalon.lan>
Mart van de Wege <mvdwege@mail.com> writes:
> I have a script here that merges multiple PDFs
> into one:
>
> #!/usr/bin/perl
>
> use Getopt::Long;
> use PDF::API2;
>
<snip>
And of course you should use 'use strict; use warnings;' in any script
you write.
First time I forgot this in more than a year. But the script in question
runs perfectly fine with no errors or warnings after adding them.
Mart
--
"We will need a longer wall when the revolution comes."
--- AJS, quoting an uncertain source.
------------------------------
Date: 14 Oct 2010 12:52:35 GMT
From: maus <greymausg@mail.com>
Subject: Gtk2
Message-Id: <slrnibe0i3.net.greymausg@gmaus.org>
Trying to move on from Perl::Tk to Perl::Gtk2 as Perl GUI's
but I can find little on Gtk2 in books or whatever, except
for the man pages, and some unhelpful example programs.
Any Ideas?,, Even on Gtk2?.
--
greymaus
.
..
...
------------------------------
Date: Thu, 14 Oct 2010 22:12:03 -0700
From: "ela" <ela@yantai.org>
Subject: Re: hashing for absent but not present cases (SOLVED)
Message-Id: <i9732v$rlk$1@ijustice.itsc.cuhk.edu.hk>
Thanks Tad McClellan & Marc Girod, after several rounds of trial & error, I
understood the codes finally~
------------------------------
Date: Thu, 14 Oct 2010 06:00:04 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: hashing for absent but not present cases
Message-Id: <e9de214e-10e8-47b6-bce7-71741ebf166c@v12g2000vbh.googlegroups.com>
On Oct 14, 8:46=A0pm, "ela" <e...@yantai.org> wrote:
> a) map
> b) {$_ =3D> 1}
perldoc -f map
> c) 1..keys
perldoc perlop
Look for 'range operator'
Marc
------------------------------
Date: Thu, 14 Oct 2010 21:30:38 -0700
From: "ela" <ela@yantai.org>
Subject: Re: hashing for absent but not present cases
Message-Id: <i970la$qq8$1@ijustice.itsc.cuhk.edu.hk>
I have modified the codes to test what they are for:
my @ids = qw/2 1 4/;
my %countries = qw(
3 Japan
1 USA
4 England
2 China
5 Australia
);
#my %absent = map {$_ => 1} 1..keys %countries;
my %absent = map {$_ => 1} 3..keys %countries;
foreach $key (sort(keys %absent)) {print $key, '=', $absent{$key},
"\n";}print "\n";
foreach $key (keys %absent) {print $key, '=', $absent{$key}, "\n";}
delete $absent{$_} for @ids;
print "missing countries:\n";
print "$_\n" for @countries{keys %absent};
and then the result is like this:
3=1
4=1
5=1
4=1
3=1
5=1
missing countries:
Japan
Australia
so while I was expecting only "Australia" is to print, so what does
"3..keys" actually mean?
------------------------------
Date: Thu, 14 Oct 2010 08:31:09 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: hashing for absent but not present cases
Message-Id: <slrnibe1n8.916.tadmc@tadbox.sbcglobal.net>
ela <ela@yantai.org> wrote:
> While your example
Whose example?
Please quote some context with an attribution in followups like
everybody else does.
Have you seen the Posting Guidelines that are posted here frequently?
Use an effective followup style
When composing a followup, quote only enough text to establish the
context for the comments that you will add. Always indicate who
wrote the quoted material. Never quote an entire article. Never
quote a .signature (unless that is what you are commenting on).
Intersperse your comments *following* each section of quoted text to
which they relate. Unappreciated followup styles are referred to as
"top-posting", "Jeopardy" (because the answer comes before the
question), or "TOFU" (Text Over, Fullquote Under).
Reversing the chronology of the dialog makes it much harder to
understand (some folks won't even read it if written in that style).
For more information on quoting style, see:
http://web.presby.edu/~nnqadmin/nnq/nquote.html
My example was code (loading a hash), not data.
> has the key and value pair on the same row,
Whitespace, such as newlines, does not matter in Perl source code.
> mine is
> different
Yours was data (a file), not code.
> and may span several rows, e.g.
>
>>1
> USA, MA, Boston
>>2
> China,
> Beijing,
> Chaoyang
>>3
> ...
If you change the problem, then the answer will change.
If you post a problem, and then change the problem, people will
give up on helping you, because you may change the problem yet again,
making any answer they give worthless and wasting their time.
> so I have to parse the information file first.
You said before that that could be "solved easily" so I assumed
that that part was already solved, and I skipped reading of any
data file and went straight to the data structure needed to solve
the remaining problem.
I will leave reading the file into a hash as an exercise for the reader.
> However, I don't know how
>
> my %absent = map {$_ => 1} 1..keys %countries;
>
> works.
map (and grep) are just foreach loops in disguise. They can
always be rewritten as a foreach loop:
my %absent;
foreach (1..keys %countries) {
$absent{$_} = 1;
}
> I'd appreciate if you would explain a little for the abc below because
> perldoc map examples do not cover the combined concepts below:
> a) map
I don't know how to explain it any better than is already done in
perldoc -f map
> b) {$_ => 1}
That creates 2 elements of the list returned from the map (and
stored in the hash.
If
my @a = ('x', 'y');
then
map {$_ => 1} @a;
makes the list
x, 1, y, 1
When assigning a list to a hash, the list must be alternating
keys and values, so
my %absent = (x, 1, y, 1);
is the same as
my %absent;
$absent{x} = 1;
$absent{y} = 1;
> c) 1..keys
That is incomplete, as you must name a hash for keys() to operate on.
perldoc -f keys
My code used keys() in a scalar context, so it returns the number of
keys in the hash.
See the "Range Operators" section in
perldoc perlop
for the meaning of ".."
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Thu, 14 Oct 2010 21:36:21 -0700
From: "ela" <ela@yantai.org>
Subject: Re: hashing for absent but not present cases
Message-Id: <i97102$qsf$1@ijustice.itsc.cuhk.edu.hk>
"Marc Girod" <marc.girod@gmail.com> wrote in message
news:e9de214e-10e8-47b6-bce7-71741ebf166c@v12g2000vbh.googlegroups.com...
On Oct 14, 8:46 pm, "ela" <e...@yantai.org> wrote:
perldoc perlop
Look for 'range operator'
Marc
Thanks for your reference, again all the examples use @array but not %array
so I still don't know how 1..keys work out and why the printout result is
different from expected.
------------------------------
Date: Thu, 14 Oct 2010 07:12:01 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: hashing for absent but not present cases
Message-Id: <7f3eb65o758qh3dcd9bih7drpqgbp8rfm6@4ax.com>
"ela" <ela@yantai.org> wrote:
[...]
>#my %absent = map {$_ => 1} 1..keys %countries;
>my %absent = map {$_ => 1} 3..keys %countries;
> so what does "3..keys" actually mean?
It means nothing because it is a context error: the function key() is
missing its operand.
However
3..keys %countries
means a list ranging from 3 to the number of elements in the hash
%countries because that is what the function keys() returns in scalar
context. see the second sentence in "perldoc -f keys".
jue
------------------------------
Date: Thu, 14 Oct 2010 11:53:26 -0700
From: sln@netherlands.com
Subject: Re: hashing for absent but not present cases
Message-Id: <1bkeb6tjpgjnnm5cngajo2p119htb5ct54@4ax.com>
On Thu, 14 Oct 2010 10:44:13 -0700, "ela" <ela@yantai.org> wrote:
>if i have a table like:
>
>ID
>2
>19
>117
>67
>8
>
>and information file like:
>
>1
>USA
>2
>China
>3
>Japan
>4
>England
>...
>100000
>Australia
>
>then I can first put the information file into hash and then retrieve the
>country information later by the hashed ID. This is the "present" case that
>can be solved easily. How can the other way, that is, those IDs that are
>absent, to retrieve the coresponding "absent" country information?
>
What about those IDs that don't exist? Orphan ids
-sln
------------------------------
Date: Thu, 14 Oct 2010 08:54:33 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Help with Hash
Message-Id: <slrnibe333.916.tadmc@tadbox.sbcglobal.net>
Deepu <pradeep.bg@gmail.com> wrote:
> use vars qw($opt_help $opt_dir $opt_debug);
You should always prefer lexical variables over package variables,
except when you can't.
Why do you think you need package variables here?
You don't, so you should use lexical variables instead:
my($opt_help $opt_dir $opt_debug);
> my $Dir = "$opt_dir";
perldoc -q vars
What's wrong with always quoting "$vars"?
so that should be:
my $Dir = $opt_dir;
> if (-d "$Dir/$tempdir")
> opendir (SUB, "$Dir"."/$tempdir" ) || die "Can't open
You should be consistent and write the same strings the same way
each time you write them.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Thu, 14 Oct 2010 07:30:23 -0700 (PDT)
From: Deepu <pradeep.bg@gmail.com>
Subject: Re: Help with Hash
Message-Id: <ad7e0905-5f96-412c-bd19-eb8222cca083@c21g2000vba.googlegroups.com>
> =A0 =A0 You should always prefer lexical variables over package variables=
,
> =A0 =A0 except when you can't.
>
> Why do you think you need package variables here?
>
> You don't, so you should use lexical variables instead:
>
> =A0 =A0 my($opt_help $opt_dir $opt_debug);
>
Thanks for this info..i will use the lexical variables as there was no
reason for using package variables...
So can you suggest a logic to get the $num_of_hits for the
$num_of_elements after comparing all 3 files?
------------------------------
Date: Thu, 14 Oct 2010 11:30:10 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Help with Hash
Message-Id: <slrnibec6u.9ka.tadmc@tadbox.sbcglobal.net>
Deepu <pradeep.bg@gmail.com> wrote:
> How can i generate a output file:
>
> File_Output:
>
> ABCD : 1
> DECF : 1
> DREF : 1
> DSER : 0
> QWSA : 1
>
> In addition to this FileOutput should contain:
> Num of Hits : 4 (Elements with 1 after comparing all 3 files)
>
>
> how i get the Num of
> Hits after comparing all 3 files.
------------------------
#!/usr/bin/perl
use warnings;
use strict;
my $file_a=<<ENDFILE;
ABCD : 1
DECF : 0
DREF : 1
DSER : 0
QWSA : 0
ENDFILE
my $file_b=<<ENDFILE;
ABCD : 1
DECF : 1
DREF : 0
DSER : 0
QWSA : 0
ENDFILE
my $file_c=<<ENDFILE;
ABCD : 1
DECF : 0
DREF : 1
DSER : 0
QWSA : 1
ENDFILE
my %out;
foreach my $file_contents ($file_a, $file_b, $file_c) {
foreach my $file_line (split /\n/, $file_contents) {
my($string, $count) = split / : /, $file_line;
if ($count) {
$out{$string} = 1;
}
else {
$out{$string} = 0 unless exists $out{$string};
}
}
}
foreach my $string (sort keys %out) {
print "$string : $out{$string}\n";
}
my $hits_count = grep $_, values %out;
print "Num of Hits : $hits_count\n";
------------------------
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Thu, 14 Oct 2010 12:12:31 -0700 (PDT)
From: "juliani.moon@gmail.com" <juliani.moon@gmail.com>
Subject: simple problem using GD
Message-Id: <3eddea77-d192-40e9-9d32-be052a7b6040@x23g2000vba.googlegroups.com>
I am using "GD::Image" to draw graphs, and have this line to print a
text:
$newimg->string(gdSmallFont,3,2,"Data Source: User submitted",$red);
which works fine.
However, when I try to use a variable to define its position, like in:
$ftop= 20;
$newimg->string(gdSmallFont,3,$ftop,"Data Source: User submitted",
$red);
or
$newimg->string(gdSmallFont,3,"$ftop","Data Source: User submitted",
$red);
they fail to work (graph is drawn without the text).
Any suggestion?
joe
------------------------------
Date: Thu, 14 Oct 2010 21:20:59 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: toy list processing problem: collect similar terms
Message-Id: <slrnibem0t.ft3.hjp-usenet2@hrunkner.hjp.at>
On 2010-10-12 02:37, Ertugrul Söylemez <es@ertes.de> wrote:
> "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>> On 2010-10-08 22:22, Ertugrul Söylemez <es@ertes.de> wrote:
>> > Josef <e9427749@stud4.tuwien.ac.at> wrote:
>> >> Am 08.10.2010 04:38, schrieb Ertugrul Söylemez:
>> >> > Josef<e9427749@stud4.tuwien.ac.at> wrote:
>> >> >> I don't know the reason of the silence,
>> >> >> but if anybody of the c.l.f people indeed fall sick.
>> >> >> This time the code example is attempt for resuscitation, or
>> >> >> at least to sedate your hearts. ;-)
>> >> >
>> >> > Functional programmers write obfuscated code, too. But unlike Perl,
>> ^^^^^^^^^^
>> >> > it still looks beautiful.
>> >>
>> >> Ok, what i learned now, is that perception of beautifulness could be
>> >> very different.
>> >
>> > Well, in fact the code I posted is beautiful in a number of ways. It's
>> > easy to read, very fast and also elegant. However, it is not beautiful
>> ^^^^^^^^^^^^
>>
>> Code cannot be both "obfuscated" and "easy to read" at the same time.
>> "Obfuscated" means hard to read (it can still be beautiful, though).
>>
>> [...]
>>
>> "Those Perl symbols" are part of the language syntax. So saying you
>> need to understand those Perl symbols is the same as saying you just
>> need to understand the language syntax.
>
> That might be your definition of "obfuscated".
Not sure what you mean by "that". My definition of "obfuscated" is
"(deliberately written to be) hard to read".
AFAIK this is the usual meaning of "obfuscated" in programming. See for
example the rules of the Obfuscated C Code Contest or the Wikipedia
article on obfuscated code. If you have a different definition, you
might want to get into the habit of posting your definition before using
the word to ensure you will be understood.
(By "read" I mean of course "understand", not "read aloud without
getting your tongue twisted". And by "hard to read" I mean "hard to read
by someone familiar with the language" - every non-trivial program is
hard to read for someone who doesn't know the language)
> Code can be hard to understand, even if you happen to know all the
> language elements and library functions it uses.
Yes, of course.
> My code example is of that kind.
So it is not "easy to read", as you claimed.
hp
------------------------------
Date: Thu, 14 Oct 2010 21:25:46 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: why does this happen?
Message-Id: <slrnibem9r.ft3.hjp-usenet2@hrunkner.hjp.at>
On 2010-10-13 22:16, J G Miller <miller@yoyo.ORG> wrote:
> On Sat, 02 Oct 2010 10:13:50 +0200, Peter J. Holzer wrote:
>> Actually, if you use an editor to open file "A", possibly edit it, and
>> then save it as "B", I don't think it is entirely unreasonable to assume
>> that B will have the same permissions as A.
>
> A big assumption there.
>
> What if A is owned by somebody else?
Well, what does cp do in this case?
I don't see why "open file A in editor, save as B" should work
differently than "cp A B".
hp
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 3174
***************************************