perl.beginners
  Home FAQ Contact Sign in
perl.beginners only
 
Advanced search
January 2008
motuwethfrsasuw
 123456 1
78910111213 2
14151617181920 3
21222324252627 4
28293031    5
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
perl.beginners Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  Threaded chat server         


Author: Turner
Date: Jan 13, 2008 11:34

Hello Perl gurus,

I'm currently in the process of writing a chat server in Perl.
Everything is all hunky-dory--it parses commands as it should, and is,
of course, quite satisfying. Except for one thing, and that is that...
Show full article (1.94Kb)
3 Comments
  Controlling external I/O with Perl         


Author: Joseph L. Casale
Date: Jan 13, 2008 09:28

I have a need at work to monitor external I/O from a PC. Basically I need to turn outputs on and off and monitor some various inputs for different ranges. Since I know *some* Perl and the PC won't be doing anything else I am not worried about making sure the code is enterprise scalable. Is there any direction anyone can point me to start my reading into such a requirement? Additionally if anyone knows of any external hardware with a Perl API that exists, that would be great!

Thanks for any comments!
jlc
1 Comment
  Strange interaction of "my"-variables with initialization         


Author: Peter Daum
Date: Jan 13, 2008 03:22

Hi,

I just got bitten by a very simple issue, where Perl behaves totally
different from what I had expected;

According to the documentation, lexical variables are visible only after
the line they have been declared in; they may be initialized;
otherwise their value is undefined, so the following short code snippet:

foreach (qw(a b c)) {
my $t;
warn("\$t == ", $t||'undef', "\n");
$t=$_;
}

will 3 times print "$t == undef" (as to be expected).
Now a minor variation:

my $x=undef;
foreach (qw(a b c)) {
my $t =$x if $x;
warn("\$t == ", $t||'undef', "\n");
$t=$_;
}
Show full article (1.05Kb)
6 Comments
  perl for uploading file shows weird characters.         


Author: Patrik Hasibuan
Date: Jan 12, 2008 14:55

Dear my friends...

I am still new in perl.

I am writing perl-cgi application for uploading a file. I did "chmod
777 ../../artikel". But I get weird displayed message:
"
ueri: ------------4CyrMz2ZeGIClwYfFsVdcv Co........
î 6êÎ]Ë kšfþx·¾ ðfS4M3>º {½‡<Óöù³®�¯3çýGèBù= „¬È›øRƒ.....
&ƒ ÿƒ&m‡îø'-n nÊÐJ(pÇ 9çqîÎ.........
Ê ¨‚¡ÀÜ EÖ� z!ª˜Y6�¬úÒ„â0J¼“ñË.......
[end so on. very longg.............]
".

And no file copied/uploaded in '../../artikel'. But inserting the record onto
the mysql run properly.

Please tell me why.....
Show full article (4.71Kb)
no comments
  Re: space in variable referencing         


Author: John W. Krahn
Date: Jan 12, 2008 13:32

ciwei wrote:
> Question from a newbie: how to properly use space
> when reference to variables, array, hash etc.
>
> please see the code below:
> why the first line, second, and third line all output differiently.
> thanks.
> ciwei
>
> ========code below ======
> #!/usr/bin/perl

The next two lines should be:

use warnings;
use strict;
> my %%ttys =();
> open ( WHO, "who|") or die "can;t \n";

You should include the $! variable in the error message so you know why
open() failed:

open WHO, 'who |' or die "Cannot open pipe from 'who' $!";
Show full article (1.91Kb)
no comments
  Re: length in bytes not characters         


Author: Chas. Owens
Date: Jan 12, 2008 11:16

On Jan 12, 2008 1:50 PM, newsguy.com> wrote:
> Rob Dixon 350.com> writes:
>
>> which outputs "char<19>".
>>
>> If you're hoping for something different from this then perhaps you
>> would let us know.
>
> Sorry if I was unclear as to what I was after. Yes that was it.
>
>> 'bytes' is a pragma, and documentation on it can be retrieved in the
>> same way as for all pragma and modules by issuing
>
>> perldoc bytes
>
> And the bit about `perldoc bytes' was new ground for me too.
>
> I never ran into that usage I guess. Or never really thought to look
> a `pragma'.
> ...
Show full article (1.83Kb)
1 Comment
  Re: length in bytes not characters         


Author: reader
Date: Jan 12, 2008 10:50

Rob Dixon 350.com> writes:
> which outputs "char<19>".
>
> If you're hoping for something different from this then perhaps you
> would let us know.

Sorry if I was unclear as to what I was after. Yes that was it.
> 'bytes' is a pragma, and documentation on it can be retrieved in the
> same way as for all pragma and modules by issuing
> perldoc bytes

And the bit about `perldoc bytes' was new ground for me too.

I never ran into that usage I guess. Or never really thought to look
a `pragma'.

I thought, right along, that kind of syntax was reserved for pulling
up documentation of a module, like `perldoc File::Find' or whatever.
And have been confused about `pragma' as well.

You've helped clear that up for me too.... thanks.
no comments
  Re: length in bytes not characters         


Author: Chas. Owens
Date: Jan 12, 2008 10:17

On Jan 12, 2008 12:29 PM, Rob Dixon 350.com> wrote:
snip
> My best guess at what you're looking for is the total number of bytes in
> all the elements of an array. This can be achieved by manually
> accumulating the lengths:
>
> use strict;
> use warnings;
>
> my @ar = qw(one two three four five);
>
> $char = 0;
> $char += length foreach @ar;
>
> print "char<$char>\n";
>
> which outputs "char<19>".
>
> If you're hoping for something different from this then perhaps you
> would let us know. ...
Show full article (1.93Kb)
1 Comment
  Why doesn't this work: trinary operator?         


Author: Kevin Zembower
Date: Jan 11, 2008 13:16

When I execute this line:

$type eq "unknown" ? $type="human" : $type="both";

$type is always "both". But executing this line:

if ($type eq "unknown") {$type="human"} else {$type="both"};

$type is "human", which is want I want and expect. The context for these
statements in my program is pasted in at the bottom.

Thanks for your guidance.

-Kevin

Kevin Zembower
Internet Services Group manager
Center for Communication Programs
Bloomberg School of Public Health
Johns Hopkins University
111 Market Place, Suite 310
Baltimore, Maryland 21202
410-659-6139
====================================
my $type = "unknown"; #The default.
Show full article (1.28Kb)
3 Comments
  Re: find2perl         


Author: Oryann9
Date: Jan 11, 2008 11:32

>You're misusing it. Set it within the wanted() routine when you're
>looking at
>a directory that you don't want to descend. It'll be cleared to 0
>before
>calling wanted(), so setting it before calling find() is completely
>useless.
>--
>Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
>0095
>stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
>Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.

-

Is this what you mean on line 9? I tried and it does not seem to work,
meaning it still descending.
Show full article (1.50Kb)
no comments
 
1 2 3 4