[20027] in Perl-Users-Digest
Perl-Users Digest, Issue: 2222 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 27 21:06:01 2001
Date: Tue, 27 Nov 2001 18:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1006913109-v10-i2222@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 27 Nov 2001 Volume: 10 Number: 2222
Today's topics:
Re: [resource] perl script <oddjob10@lycos.com>
comparison failure. <jks@selectacast.net>
Re: comparison failure. <tony_curtis32@yahoo.com>
Re: comparison failure. <joe+usenet@sunstarsys.com>
Re: comparison failure. <uri@stemsystems.com>
File::Copy - Which Perl Versions Include It? <matt@mattkruse.com>
How to implement "peres unbiasing" in perl. <goldbb2@earthlink.net>
Re: How to trap calls to undefined procedures at compil <cp@onsitetech.com>
Re: make subset of the search result <ajamtgaa@cisco.com>
Must be a better way.. (HoboSong)
Need Source for search engine like google/yahoo (Pavan)
Re: New problem.. <wyzelli@yahoo.com>
Re: Newbie Help... <wyzelli@yahoo.com>
Re: question about random~~~ help~~~ <swansun@kali.com.cn>
Re: question about random~~~ help~~~ <swansun@kali.com.cn>
Re: question about random~~~ help~~~ <swansun@kali.com.cn>
Re: Serious Regexp help... <ahamm@programmer.net>
Simple question about the print function (Matt Funk)
Re: Simple question about the print function (John J. Trammell)
Re: Simple question about the print function <joe+usenet@sunstarsys.com>
Re: Simple question about the print function (Sam Holden)
Re: Simple question about the print function <msanders76@hotmail.com>
Re: Special chars <goldbb2@earthlink.net>
Re: Summing Array Elements <whataman@home.com>
Re: Summing Array Elements <whataman@home.com>
Re: Summing Array Elements <godzilla@stomp.stomp.tokyo>
Re: Summing Array Elements (Damian James)
Re: Summing Array Elements <uri@stemsystems.com>
Re: Summing Array Elements <mgjv@tradingpost.com.au>
what's a CHUNK? (Sara)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 28 Nov 2001 00:40:50 GMT
From: logikal nonsense <oddjob10@lycos.com>
Subject: Re: [resource] perl script
Message-Id: <MPG.166dd22291c7d719897c0@207.217.77.25>
Was this the wrong group to post this query? help?
In article <MPG.166c659b7a610b89897be@207.217.77.25>, oddjob10@lycos.com
says...
> Maybe you guys can help me out with the problem
> since I haven't had time to work on it. Here is a
> message I posted to a msg board asking about the
> problem:
>
> I was wondering if any of you guys could help me
> with a
> resource issue here.
>
> I'm using a perl script (in my web mixmaster
> interface cgi script) to
> open mixmaster (2.9beta23) using:
>
> open(MIX, "|$mix -p -l
> \"$remailer1\",\"$remailer2\"");
>
>
> and then i'm putting in the input:
>
> ..
> print MIX "Subject: $subject\n";
> ..and whatever else
>
> and then I'm closing MIX (which adds the msg to the
> mixmaster msg pool):
>
> close(MIX);
>
> This will add the message to the pool.
>
> However, on the close(MIX); statement, the mix
> process is still open
> in the system and it can sometimes take one or two
> minutes for it to
> finally "close" and add the message to the pool. It
> only takes a
> second to send when I type the command in
> manually at the console.
> By MIX not closing right away, it's causing a system
> resource problem
> since mix processes are still waiting to be executed
> and more are
> coming in (from the web). I do notice that user
> "apache" is running
> the mixmaster executable, but I made sure the
> executable and pool
> directory were writable so "apache" has no problems
> running it.
>
> If anyone knows what could be causing the long
------------------------------
Date: Tue, 27 Nov 2001 19:50:04 -0500
From: Joseph Shraibman <jks@selectacast.net>
Subject: comparison failure.
Message-Id: <3C0434BC.3060102@selectacast.net>
Here is test.pl:
#!/usr/bin/perl
if ("95" > 90){
print "95 > 90\n";
} else {
print "NOT 95 > 90\n";
}
$temp = `df`;
if (1){
$temp =
"Filesystem 1k-blocks Used Available Use% Mounted on
/dev/hda1 3958767 3528286 225654 94% /
/dev/hda5 1981000 1702295 176293 91% /home
/dev/hda7 6086800 3579554 2191972 62% /local"
}
( $garbage, @lines) = split /\n/, $temp; #get rid of first entry
foreach $line (@lines){
print "line is $line\n";
$line =~ /\s(\d+)\%\s+(.*)/;
$perc = $1;
$mount = $2;
$iperc = int $perc;
print "perc: $perc mount: $mount iperc: $iperc\n";
if ($iprec > 90){ #iprec or prec doesn't make a difference.
print "WARNING! fs partition mounted as '$mount' is $perc% full.\n";
} else {
print "fs partition mounted as '$mount' is $perc% full.\n";
}
}
Here is the output:
# ./test.pl
95 > 90
line is /dev/hda1 3958767 3528286 225654 94% /
perc: '94' mount: / iperc: 94
fs partition mounted as '/' is 94% full.
line is /dev/hda5 1981000 1702295 176293 91% /home
perc: '91' mount: /home iperc: 91
fs partition mounted as '/home' is 91% full.
line is /dev/hda7 6086800 3579554 2191972 62% /local
perc: '62' mount: /local iperc: 62
fs partition mounted as '/local' is 62% full.
# perl --version
This is perl, version 5.005_03 built for i386-linux
Copyright 1987-1999, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
For some reason the > comparison is returning false all the time. Is this a known bug?
------------------------------
Date: Tue, 27 Nov 2001 18:55:51 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: comparison failure.
Message-Id: <87k7wb67e0.fsf@limey.hpcc.uh.edu>
>> On Tue, 27 Nov 2001 19:50:04 -0500,
>> Joseph Shraibman <jks@selectacast.net> said:
> Here is test.pl: #!/usr/bin/perl
> ... if ($iprec > 90) ...
^^^^^
> For some reason the > comparison is returning false all
> the time. Is this a known bug?
What does "perl -cw" say about your script? Don't forget
"use strict" too.
hth
t
--
Oh! I've said too much. Smithers, use the amnesia ray.
------------------------------
Date: 27 Nov 2001 20:00:07 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: comparison failure.
Message-Id: <m3itbv4smg.fsf@mumonkan.sunstarsys.com>
Joseph Shraibman <jks@selectacast.net> writes:
> For some reason the > comparison is returning false all the time. Is
> this a known bug?
Yes- perl doesn't work right unless you enable strictures
(warnings too, but that's not the problem here :)
--
Joe Schaefer "The man who sets out to carry a cat by its tail learns
something that will always be useful and which never will grow
dim or doubtful."
--Mark Twain
------------------------------
Date: Wed, 28 Nov 2001 01:09:26 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: comparison failure.
Message-Id: <x7elmj8zuh.fsf@home.sysarch.com>
>>>>> "JS" == Joseph Shraibman <jks@selectacast.net> writes:
JS> Here is test.pl:
JS> #!/usr/bin/perl
no -w there. bad.
JS> if ("95" > 90){
don't compare strings to numbers like that.
JS> "Filesystem 1k-blocks Used Available Use% Mounted on
JS> /dev/hda1 3958767 3528286 225654 94% /
JS> /dev/hda5 1981000 1702295 176293 91% /home
JS> /dev/hda7 6086800 3579554 2191972 62% /local"
JS> }
JS> ( $garbage, @lines) = split /\n/, $temp; #get rid of first entry
JS> foreach $line (@lines){
JS> print "line is $line\n";
JS> $line =~ /\s(\d+)\%\s+(.*)/;
hmm, did this work? check the results of a match before you grab stuff
from it.
JS> $perc = $1;
JS> $mount = $2;
JS> $iperc = int $perc;
why the int call? i don't see any fractions anywhere
JS> print "perc: $perc mount: $mount iperc: $iperc\n";
JS> perc: '94' mount: / iperc: 94
those two lines don't match. i don't see the '' in the print string.
so you must have used different code or output here. please make sure
they are exactly what you have. i can't debug unknown code.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 28 Nov 2001 02:00:16 GMT
From: "Matt Kruse" <matt@mattkruse.com>
Subject: File::Copy - Which Perl Versions Include It?
Message-Id: <QyXM7.185952$My2.109699953@news1.mntp1.il.home.com>
Can anyone tell me which versions of Perl include File::Copy as part of the
standard distribution?
Do all versions back to 5.001 include it?
Matt Kruse
http://www.mattkruse.com/
------------------------------
Date: Tue, 27 Nov 2001 19:06:28 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: How to implement "peres unbiasing" in perl.
Message-Id: <3C042A84.2351C06A@earthlink.net>
I'm trying to implement a really funky algorithm known as "Peres
unbiasing."
I couldn't find the original paper online, but did find it described in
the paper "Tossing a Biased Coin" by Michael Mitzenmacher, [which is
available at http://www.fas.harvard.edu/~libcs124/CS/coinflip3.pdf and
at http://www.fas.harvard.edu/~libcs124/CS/coinflip3.ps ], as something
called the "Advanced Multi-Level Strategy."
I understand the basic "Multi-Level Strategy," [also described in that
paper] but the "Advanced" one is hurting my brane.
Here's the code I have so far:
my ($f, $bits, $bcount, @heads, @tails) = ('','',0);
sub get_bit {
until($bcount) {
my ($d, $coin) = (0, coinflip());
do {
$coin ? ++$heads[$d] : ++$tails[$d];
if( my $mask = $heads[$d] & $tails[$d] ) {
$heads[$d] &= ~$mask; $tails[$d] &= ~$mask;
vec($bits, $bcount++, 1) = $coin;
}
$coin = $mask & 1;
} until( vec($f, $d++, 1) ^= 1 );
}
vec($bits, --$bcount, 1);
}
Unfortunately, I think that I have a fencepost problem of some sort
somewhere.
For testing, I am using sub coinflip() { int(rand(2)) } to simulate a
coin with no bias.
According to my testing, coinflip() is called about 1.5 times for every
call to get_bit(). This is wrong. It should get called approximately
once for every call to get_bit()... at least according to the paper.
Can anyone see what's wrong? Is it my code, or am I simply not running
enough trials? The paper only says that this *approaches* one flip per
bit in the long run, but not how long it takes to begin to get close to
one flip per bit. Maybe 1E6 calls to get_bit is too few?
Or is the problem merely that int(rand(2)) is a poor prng?
--
Klein bottle for rent - inquire within.
------------------------------
Date: 28 Nov 2001 00:19:52 GMT
From: "Curtis Poe" <cp@onsitetech.com>
Subject: Re: How to trap calls to undefined procedures at compile time
Message-Id: <9u1aj8$joq@dispatch.concentric.net>
> Thanks Curtis,
>
> I think this lack of verification is a serious flaw in the language
> design. It's a pity and makes Perl less suitable for large projects.
>
> Or do the Perl-language designers think that this is a feature and not a
> design flaw :)
>
> Peter
Peter,
First, "you're welcome". Second, this, like all things, has tradeoffs.
For example, when working with Java, the inability to generate code on the
fly can get annoying when you have to write 30 "public void setFoo()"
methods. This can slow down productivity. Sometimes, it can even cause
code problems as coding 30 "set" methods means 30 more chances for bugs,
whereas robust code generators can do wonders for producing tight (albeit
less flexible) code. Of course, having those 30 "set" methods separate
means that I don't have to worry about a poorly designed code generator
spreading bugs everywhere.
Perl is great for heavy text analysis.
VB is great for rapid GUI prototyping.
C is great for device drivers.
PROLOG is great for AI.
COBOL is great for headaches.
In other words, I want to use languages for their strengths, not their
weaknesses :)
--
Cheers,
Curtis Poe
Senior Programmer
ONSITE! Technology
www.onsitetech.com
503.233.1418
------------------------------
Date: Tue, 27 Nov 2001 17:27:37 -0700
From: Arne Jamtgaard <ajamtgaa@cisco.com>
Subject: Re: make subset of the search result
Message-Id: <3C042F79.7BC3F8CF@cisco.com>
qiang wrote:
> I 've seen some web search engine( like google ) that list search
> result with a subset of the data ( like the first 30 items ) then
> have a button or link to get more of the search hits.. but i don't
> know how to accomplish it in perl.. can someone give me an idea or
> some .. since i know there are always another way (for better ) to
> do it .. :-)
So, you're running the search result in your cgi script, storing it
somewhere (an array?), and displaying some results.
Pass along an additional parameter in that button at the botton that
tells which 'n' items to print from the array. (No page # == print
1-30, page #2 == print 31-60, etc.)
Unless I'm missing something...
Arne
(I suppose re-running the search is not optimal, but there's always
that processing/memory tradeoff...)
--
Arne Jamtgaard
Boulder DevTest
1-720-562-6331
ajamtgaa@cisco.com
------------------------------
Date: 27 Nov 2001 17:15:08 -0800
From: chrisvano@yahoo.com (HoboSong)
Subject: Must be a better way..
Message-Id: <4fbb9396.0111271715.68a37058@posting.google.com>
Clearly Im a newbie to both Perl and programming, but I havent learned
a better way to do this... Ive used similar many times without any problems
but Im trying to be more efficient, can someone just give me a nudge in the
right direction?
Thank you
while (<TEXTFILE>) {
if ( /SETTLEMENT SECTION/ ) {
$section = "settlement";
} elsif ( /DIVIDENDS REPORT/ ) {
$section = "divs";
} elsif ( /RISK MANAGEMENT REPORT/ ) {
$section = "risk";
}
if ( $section eq "settlement" ) {
parse_settlement($_);
} elsif ($section eq "divs" ) {
parse_divs($_);
} elsif ( $section eq "risk" ) {
parse_risk($_);
}
}
------------------------------
Date: 27 Nov 2001 16:35:02 -0800
From: pkkasu@yahoo.com (Pavan)
Subject: Need Source for search engine like google/yahoo
Message-Id: <4b5d8d86.0111271635.1ab87890@posting.google.com>
Hi Friends,
I am planning to develop a search engine like yahoo/ Google for our
small community. I am thinking to develop using Perl /PHP/ASP, MY Sql
& Linux. The site is a non commercial one. If any body have any source
code ,plz mail me at pkkasu@yahoo.com. I tried at sourceforge.net . I
didnt found the exact application i need. If any one found it on web
or if u developed, plz mail me.
plz dont expect business.
Thanks in Advance,
Pavan Kasu
pkkasu@yahoo.com
------------------------------
Date: Tue, 27 Nov 2001 16:44:33 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: New problem..
Message-Id: <o2HM7.1$uM3.40@vicpull1.telstra.net>
"Mike Schmitt" <mds@wam.umd.edu> wrote in message
news:9tv77l$e6q$1@hecate.umd.edu...
> I've just written a rather large PERL program which I feel could be used
as
> a viable tool for anyone with Windows and AIM. My only problem is, most
> non-powerusers don't have PERL on their systems, nor do they have any idea
> or concept of what PERL is. Is there a way of "compiling", per se, my
perl
> script into a file which is standalone-enough to be run by just any user
of
> Windows? For instance, MS Quick Basic has a "compiler" which I guess just
> rolls a version of the Basic interpreter together with the code, and all
> into a standalone EXE; is there a way of doing this with PERL?
You mean Perl not PERL. Check the FAQ for why.
But, you need to take a look at PerlAPP from Activestate Corp, or Perl2exe
from Dynamicstate.
Check the obvious urls, (www.activestate.com www.dynamicstate.com) or a
search engine.
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_!=1)? 's':'';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: Wed, 28 Nov 2001 09:18:53 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Newbie Help...
Message-Id: <CCVM7.12$KP3.335@vicpull1.telstra.net>
"HoboSong" <chrisvano@yahoo.com> wrote in message
news:4fbb9396.0111270042.66f697e5@posting.google.com...
> Chris White <chrisw_63@hotmail.com> wrote in message
news:<cv160uknnk6nj48lqkil5n5gp6i10t4htd@4ax.com>...
>
> >
> > #!/usr/local/bin/perl
> > # hello.pl -- my first perl script!
>
> use CGI; ## </~~ Try adding "use CGI;"
Why use a module when are not using any of the functions provided by that
module?
Having said that, most CGI development is greatly speeded up by using the
CGI module, so that is good advice in a generic sense rather than for this
particular problem.
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: Wed, 28 Nov 2001 09:27:59 +0800
From: "swansun" <swansun@kali.com.cn>
Subject: Re: question about random~~~ help~~~
Message-Id: <9u1ek5$2rp$1@mail.cn99.com>
thank u very much!!!!
:)
------------------------------
Date: Wed, 28 Nov 2001 09:28:30 +0800
From: "swansun" <swansun@kali.com.cn>
Subject: Re: question about random~~~ help~~~
Message-Id: <9u1el5$2th$1@mail.cn99.com>
thanks all!!!
------------------------------
Date: Wed, 28 Nov 2001 09:28:39 +0800
From: "swansun" <swansun@kali.com.cn>
Subject: Re: question about random~~~ help~~~
Message-Id: <9u1ele$31r$1@mail.cn99.com>
:)
------------------------------
Date: Wed, 28 Nov 2001 11:37:34 +1100
From: "Andrew Hamm" <ahamm@programmer.net>
Subject: Re: Serious Regexp help...
Message-Id: <3c043213_1@news.iprimus.com.au>
Ashley M. Kirchner wrote in message <3C036122.9CD487E8@pcraft.com>...
>
> Actually, Mona's original post of
>
>my @pieces = $line =~ /^(\S+)\s+(\d+)\s+(\S+)\s+(.+?)\s+(\S+)\s+(\$\S+)$/;
>
> ...works like a charm, unless I'm missing something. I did learn quite
a bit by the other regexp posted, mainly by following it bit by bit, trying
to figure out what it does, where and how.
>
> And I did manage to break $3 and $4, yes - but not after a long time of
staring at the screen.
>
I jumped in when I noticed the greediness problem, but neither of us in the
side conversation noticed the missing field.
Mona's result is the same as our corrected result (if you discount the
missing field) but just formatted differently. As such, it didn't need any
corrections ;)
--
Space Corps Directive #723
Terraformers are expressly forbidden from recreating Swindon.
-- Red Dwarf
------------------------------
Date: 27 Nov 2001 17:33:17 -0800
From: mfunk@telus.net (Matt Funk)
Subject: Simple question about the print function
Message-Id: <2900bb61.0111271733.4813715d@posting.google.com>
I'm attempting to learn perl and I don't understand a simple thing
about the print function.
If I have a one line program like this:
print "Hello World!";
it doesn't work. No errors when I run it with the -w option, it just
does nothing. But if I also print a newline character it works fine:
print "Hello World!\n";
Things that make you go hmmmm...if someone could explain what is
happening that would be great!
Thanks,
Matt
------------------------------
Date: Tue, 27 Nov 2001 19:41:38 -0600
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Simple question about the print function
Message-Id: <slrna08gc4.m89.trammell@haqq.el-swifto.com>
On 27 Nov 2001 17:33:17 -0800, Matt Funk <mfunk@telus.net> wrote:
> I'm attempting to learn perl and I don't understand a simple thing
> about the print function.
>
> If I have a one line program like this:
> print "Hello World!";
> it doesn't work. No errors when I run it with the -w option, it just
> does nothing. But if I also print a newline character it works fine:
> print "Hello World!\n";
>
> Things that make you go hmmmm...if someone could explain what is
> happening that would be great!
>
Try redirecting the output to a file
perl hw.pl > out.txt
or to a pager
perl hw.pl | more
What do you see?
------------------------------
Date: 27 Nov 2001 20:48:56 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Simple question about the print function
Message-Id: <m3elmj4qd3.fsf@mumonkan.sunstarsys.com>
mfunk@telus.net (Matt Funk) writes:
> If I have a one line program like this:
> print "Hello World!";
> it doesn't work. No errors when I run it with the -w option, it just
> does nothing. But if I also print a newline character it works fine:
> print "Hello World!\n";
>
> Things that make you go hmmmm...if someone could explain what is
> happening that would be great!
It's a buffering problem- your OS's stdout buffer isn't getting fflush(3)ed
to the terminal without a trailing newline. For a thorough discussion, see
http://perl.plover.com/FAQs/Buffering.html
--
Joe Schaefer "Whoever undertakes to set himself up as a judge of Truth and
Knowledge is shipwrecked by the laughter of the gods."
--Albert Einstein
------------------------------
Date: 28 Nov 2001 01:56:45 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Simple question about the print function
Message-Id: <slrna08h2t.enp.sholden@pgrad.cs.usyd.edu.au>
On 27 Nov 2001 17:33:17 -0800, Matt Funk <mfunk@telus.net> wrote:
>I'm attempting to learn perl and I don't understand a simple thing
>about the print function.
>
>If I have a one line program like this:
> print "Hello World!";
>it doesn't work. No errors when I run it with the -w option, it just
>does nothing. But if I also print a newline character it works fine:
> print "Hello World!\n";
>
>Things that make you go hmmmm...if someone could explain what is
>happening that would be great!
Chances are your shell/prompt/command interpretor/whatever uses a carriage
return (or some equivalent for your system) to go back to the beginning of the
line. In doing so it is overwriting the output of your program.
The obvious solution is to always output a newline character at the end.
You could also try:
$|=1;
print "Hello World!";
sleep 2;
Which should print Hello World! wait a couple of seconds and then exit (when
your prompt will erase the Hello World!).
The $| bit is to turn off buffering, this is explained in perlfaq5, under the
"How do I flush/unbuffer an output filehandle? Why must I do this?" FAQ.
--
Sam Holden
------------------------------
Date: Wed, 28 Nov 2001 02:03:43 +0000 (UTC)
From: "Martin Sanders" <msanders76@hotmail.com>
Subject: Re: Simple question about the print function
Message-Id: <ac000a4904ea00aca4d592f054c1fcbe.46432@mygate.mailgate.org>
Hi,
are you storing that in a file and then trying to run it?
i would do it like this, first store the following code in a text file called
hello.
#!/usr/bin/perl
print "Hello, World!";
then, make the script executable with the command:
chmod +x hello
Then run the program with the command:
./hello
You can also produce exactly the same output with the following program:
#!/usr/bin/perl
print <<HELLO;
Hello, World!
HELLO
I learnt this trick just today ;-)
Also, in the example you gave you did not say whether you included
#!/usr/bin/perl on the first line of your program.
I hope I have been able to help you.
Kind regards,
martin
"Matt Funk" <mfunk@telus.net> wrote in message
news:2900bb61.0111271733.4813715d@posting.google.com...
> I'm attempting to learn perl and I don't understand a simple thing
> about the print function.
>
> If I have a one line program like this:
> print "Hello World!";
> it doesn't work. No errors when I run it with the -w option, it just
> does nothing. But if I also print a newline character it works fine:
> print "Hello World!\n";
>
> Things that make you go hmmmm...if someone could explain what is
> happening that would be great!
>
> Thanks,
> Matt
--
Posted from cache-wit-hsi.cableinet.co.uk [62.30.192.1]
via Mailgate.ORG Server - http://www.Mailgate.ORG
------------------------------
Date: Tue, 27 Nov 2001 19:31:23 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Special chars
Message-Id: <3C04305B.D448B266@earthlink.net>
Derek Vokey wrote:
>
> Hi,
> I have a perl program running as sort of a socket server on a port on
> my web server. This program recieves connections from php and then
> sends that info out on another socket to a windows program. My problem
> is that all of the french special chars don't show up on the windows
> machines. I know this is a charset issue.
>
> Can someone point me in the right direction?
It's either an encoding or locale issue.
Search on cpan for either of those words, and maybe you'll find
something.
--
Klein bottle for rent - inquire within.
------------------------------
Date: Tue, 27 Nov 2001 23:28:44 GMT
From: "What A Man !" <whataman@home.com>
Subject: Re: Summing Array Elements
Message-Id: <3C0421C9.198EDBF3@home.com>
"Tassilo v. Parseval" wrote:
>
> > my $size = 0;
> > $size += length get $_ for @url;
> > print $size;
> >
Hmmm... I'm getting the wrong file sizes with the code above. For
example, a 400 and 600 bytesize file, add up to 2K instead of 1K. AND I
get a different value every time I refresh, why?
--Dennis
------------------------------
Date: Tue, 27 Nov 2001 23:59:11 GMT
From: "What A Man !" <whataman@home.com>
Subject: Re: Summing Array Elements
Message-Id: <3C0428E7.13E8570A@home.com>
"What A Man !" wrote:
>
> "Tassilo v. Parseval" wrote:
> >
> > > my $size = 0;
> > > $size += length get $_ for @url;
> > > print $size;
> > >
> Hmmm... I'm getting the wrong file sizes with the code above. For
> example, a 400 and 600 bytesize file, add up to 2K instead of 1K. AND I
> get a different value every time I refresh, why?
>
> --Dennis
My apologies. Your code above DOES work. It gives correct totals on .txt
and .gif files. The problem was with .pl files. This is probably because
it adds my server's banner coding to .pl files. I should've thought of
that.<slap>
--Dennis
------------------------------
Date: Tue, 27 Nov 2001 16:19:56 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Summing Array Elements
Message-Id: <3C042DAC.4307FB90@stomp.stomp.tokyo>
What A Man ! wrote:
> What A Man ! wrote:
> > Tassilo v. Parseval wrote:
(snipped)
> > > > my $size = 0;
> > > > $size += length get $_ for @url;
> > > > print $size;
> > Hmmm... I'm getting the wrong file sizes with the code above. For
> > example, a 400 and 600 bytesize file, add up to 2K instead of 1K. AND I
> > get a different value every time I refresh, why?
> My apologies. Your code above DOES work. It gives correct totals on .txt
> and .gif files. The problem was with .pl files. This is probably because
> it adds my server's banner coding to .pl files. I should've thought of
> that.<slap>
Perl's length () function counts a \n newline character as one.
Actual file size measurements count a \n newline as two.
I do not know if Perl's length () function recognizes all
characters for all types of binary files. I tested a common
jpg file and the actual file size and the reported file size
are equal.
I tested some of my text files using LWP Simple. A file with
an actual size of 704 bytes came back as 618 bytes due to this
length () miscount of newlines. A tested file with a size of
4783 bytes came back as 4586 bytes.
If you want accurate file sizes, true file sizes, you
need to compensate for this miscount of newlines.
Godzilla!
------------------------------
Date: 28 Nov 2001 00:25:06 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Summing Array Elements
Message-Id: <slrna08bn9.pmq.damian@puma.qimr.edu.au>
On Tue, 27 Nov 2001 22:54:38 +0100, Tassilo v. Parseval said:
>On Tue, 27 Nov 2001 14:58:45 -0600 (CST), BUCK NAKED1 wrote:
>> ...
>> foreach $Key (@urlsize) {
>> $Total += $Key;
>> }
>> print $Total;
>
If @urlsize is guaranteed to contain only digits (like those
returned by length()...), then this is safe:
sub sum { local $" = '+'; eval "@_" };
print sum @urlsize;
>my $size = 0;
>$size += length get $_ for @url;
>print $size;
>
Indeed, it makes more sense to calclulate the sum of the numbers
as they're gathered
Cheers,
Damian
--
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker,### http://home.pacific.net.au/~djames.hub
------------------------------
Date: Wed, 28 Nov 2001 01:00:44 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Summing Array Elements
Message-Id: <x7herf908z.fsf@home.sysarch.com>
>>>>> "G" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
G> Perl's length () function counts a \n newline character as one.
G> Actual file size measurements count a \n newline as two.
this is a bug in your brain. length is correct. you use redmond crapware
which converts \n to \n\r and vice versa. if you want accurate file
sizes, use binmode.
G> I do not know if Perl's length () function recognizes all
G> characters for all types of binary files. I tested a common
G> jpg file and the actual file size and the reported file size
G> are equal.
moronic as usual. length doesn't even LOOK at the data in any
scalar. all scalars have their length in a field which is retrieved by
the length function.
G> I tested some of my text files using LWP Simple. A file with
G> an actual size of 704 bytes came back as 618 bytes due to this
G> length () miscount of newlines. A tested file with a size of
G> 4783 bytes came back as 4586 bytes.
this is an issue with your server and not length. typical of you not
understanding what is really going on.
G> If you want accurate file sizes, true file sizes, you
G> need to compensate for this miscount of newlines.
and the rest of us must compensate for your stupidity.
uri (not frank)
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 28 Nov 2001 01:42:17 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Summing Array Elements
Message-Id: <slrna08g84.mnf.mgjv@verbruggen.comdyn.com.au>
On Tue, 27 Nov 2001 16:19:56 -0800,
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> What A Man ! wrote:
>
>> What A Man ! wrote:
>> > Tassilo v. Parseval wrote:
>
> (snipped)
>
>> > > > my $size = 0;
>> > > > $size += length get $_ for @url;
>> > > > print $size;
>
>> > Hmmm... I'm getting the wrong file sizes with the code above. For
>> > example, a 400 and 600 bytesize file, add up to 2K instead of 1K. AND I
>> > get a different value every time I refresh, why?
>
>
>> My apologies. Your code above DOES work. It gives correct totals on .txt
>> and .gif files. The problem was with .pl files. This is probably because
>> it adds my server's banner coding to .pl files. I should've thought of
>> that.<slap>
>
>
> Perl's length () function counts a \n newline character as one.
Which is correct.
> Actual file size measurements count a \n newline as two.
Not true in general. On some platforms an end of line is represented
by more than one character. DOS-based systems are the most common
example of this.
Read the perlport documentation, section /Newlines/, for real
information on this.
> I tested some of my text files using LWP Simple. A file with
> an actual size of 704 bytes came back as 618 bytes due to this
> length () miscount of newlines. A tested file with a size of
> 4783 bytes came back as 4586 bytes.
Don't spread FUD. It is not a miscount. There is no problem with
Perl's length() function.
> If you want accurate file sizes, true file sizes, you
> need to compensate for this miscount of newlines.
Nonsense. You use -s or stat() if that's what you want.
Martien
--
Do not pay any attention to what Godzilla says. It is a troll, and
has no decent working knowledge of Perl or programming in general.
Search groups.google.com to see a history of its posts and replies
to these posts.
------------------------------
Date: 27 Nov 2001 17:56:55 -0800
From: genericax@hotmail.com (Sara)
Subject: what's a CHUNK?
Message-Id: <776e0325.0111271756.120bc6e2@posting.google.com>
Got this..
Use of uninitialized value at ./procex.pl line 105, <IN> chunk 11.
main::export_recx ('HASH(0x821d890)') called at ./procex.pl line
[tux@tuxy ~]$ perldoc -q chunk
No documentation for perl FAQ keyword `chunk' found
looked in Camel index under "Chunk", no entry
Use of uninitialized value at ./process_mem.pl line 105, <IN> chunk
11.
main::export_freeuser('HASH(0x821d890)') called at ./process_mem.pl
line
does chunk 11 mean the 11th hash element if I was to do a keys %hash?
Since hashes are not ordered I'm uncertain what info this chunk
thingie tells me!
Thanks,
GX
------------------------------
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 2222
***************************************