How to load text into Curses::UI::TextEditor -> -text?

2006-10-09 Thread ert weerr
Guys,

I'd like to write a perl-based tool that helps me to
do my regular system monitoring tasks.
It would be running in console mode but using
'windows' to list the command outputs.

Curses::UI::TextEditor would be one of the elements
that I use to present the output in a nice formatted
way.

It appears to me that its -text option is not
accepting strings from a function but only static
texts.

Is there anyone here who already had to struggle with
this module before?

Sorry if it's an off-topic email here, I really don't
know where to ask my question.

Thanks in advance!

Regards,

John

Here's an example:

$w{202}->add(
undef, 'TextEditor',
-title => 'Disk
space',
-y => 0, -padright =>
0, -border => 1,
-padbottom => 0,
-readonly => 1,
-vscrollbar => 1,
-hscrollbar => 1,
-text => $text,
);

The variable $text has only a simple string value
something like "This is a test...", but when I run the
code the TextEditor only present '1'.

If I try to use the function like this

-text => \&fs_check,

The the result is 'CODE(0x972e3c4)'

It only works if I write a static string next to text:

-text => "This is a test..."

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Perl Script as a Cron Job

2006-10-09 Thread Mazhar

Hi All,

I have prepared a script that is to be run as a cron job every 10 minutes, i
have added the same in cron as below,

*0,10,20,30,40,50 * * * * /scripts/x.pl*

But the above is not running properly, should i add something in the code.

Need your inputs on the above

Thanks in Advance

Regards
Mazhar


Re: Perl Script as a Cron Job

2006-10-09 Thread Bjørge Solli
On Monday 09 October 2006 11:03, Mazhar wrote:
> I have prepared a script that is to be run as a cron job every 10 minutes,
> i have added the same in cron as below,
>
> *0,10,20,30,40,50 * * * * /scripts/x.pl*

You have too many stars, remove the leading and trailing stars, or try:
*/10 * * * * /path/script.pl

http://en.wikipedia.org/wiki/Crontab
http://www.computerhope.com/unix/ucrontab.htm

-- 
Bjørge Solli - Office:+47 55205847
Mohn-Sverdrupsenteret, Nansensenteret, Høyteknologisenteret T47
Thormöhlensgate 47, 5006 Bergen, Norway - www.nersc.no
Google Earth: www.nersc.no/GE - TOPAZ: topaz.nersc.no

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Perl Script as a Cron Job

2006-10-09 Thread Jeff Pang

>
>I have prepared a script that is to be run as a cron job every 10 minutes, i
>have added the same in cron as below,
>
>*0,10,20,30,40,50 * * * * /scripts/x.pl*
>
>But the above is not running properly, should i add something in the code.
>

Try this:

*/10 * * * * /scritps/xxx.pl

The xxx.pl should be executable.



--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Why is Perl a SHE

2006-10-09 Thread Mathew Snyder
zentara wrote:
> On Sat, 7 Oct 2006 11:19:34 +0200, [EMAIL PROTECTED] ("@ Rocteur CC")
> wrote:
> 
>> Hi,
>>
>> I was just reading The State of the Onion 10 http://www.perl.com/pub/ 
>> a/2006/09/21/onion.html by Larry, and if you have not read it I think  
>> you will enjoy it. I really ROFL when I saw that Randal was our own  
>> Evil Brother Damian ;-)
>>
>> Anyway, Larry refers to Perl as SHE.. Does anyone know when Perl  
>> became a SHE and why ?
>>
>> Thanks and have a GREAT weekend all,
>>
>> Jerry
> 
> This is perfect for jokes.
> How about:
> 
> Because he loves Perl, and he isn't gay?
> 
> He loves to f**k with his code all day?
> 
> Perl's a bitch until you get to know her?
> 
> Perl coding is like mental masterbation?
> 
> 
> 

Those are just bad...real bad.


Mathew Snyder

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




how do i assign variables from a different file..

2006-10-09 Thread positive mind

Greetings !!

i am beginer in Perl and have task in hand to do..i got to read lot of
variables and parameters which are defined in one file. I have to use these
variables in my perl script ..how do i do this...(how do i use the variables
in one file in my perl script...)

thnx,
pm


Re: Perl Script as a Cron Job

2006-10-09 Thread Mazhar

When i add the entry as specified i get the below error (i.e) */10 * * * *
/scritps/xxx.pl in cron

*crontab: error on previous line; unexpected character found in line.*

Regards
Mazhar


On 10/9/06, Jeff Pang <[EMAIL PROTECTED]> wrote:



>
>I have prepared a script that is to be run as a cron job every 10
minutes, i
>have added the same in cron as below,
>
>*0,10,20,30,40,50 * * * * /scripts/x.pl*
>
>But the above is not running properly, should i add something in the
code.
>

Try this:

*/10 * * * * /scritps/xxx.pl

The xxx.pl should be executable.



--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 





Re: How to load text into Curses::UI::TextEditor -> -text?

2006-10-09 Thread D. Bolliger
ert weerr am Montag, 9. Oktober 2006 09:24:
> Guys,

Hello

> I'd like to write a perl-based tool that helps me to
> do my regular system monitoring tasks.
> It would be running in console mode but using
> 'windows' to list the command outputs.
>
> Curses::UI::TextEditor would be one of the elements
> that I use to present the output in a nice formatted
> way.
>
> It appears to me that its -text option is not
> accepting strings from a function but only static
> texts.
>
> Is there anyone here who already had to struggle with
> this module before?
>
> Sorry if it's an off-topic email here, I really don't
> know where to ask my question.
>
> Thanks in advance!
>
> Regards,
>
> John
>
> Here's an example:
>
> $w{202}->add(
>   undef, 'TextEditor',
>   -title => 'Disk space',
>   -y => 0, -padright => 0, -border => 1,
>   -padbottom => 0,
>   -readonly => 1,
>   -vscrollbar => 1,
>   -hscrollbar => 1,
>   -text => $text,
> );
>
> The variable $text has only a simple string value
> something like "This is a test...", but when I run the
> code the TextEditor only present '1'.
>
> If I try to use the function like this
>
> -text => \&fs_check,
>
> The the result is 'CODE(0x972e3c4)'

You assigned a reference to a subroutine, and it's address is correctly shown, 
since the value of this attribute is not called by the code but displayed
literally.

You probably want to assign the result string of a call of the subroutine:

   -text => fs_check(),


Does this help?

Dani

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Perl Script as a Cron Job

2006-10-09 Thread Mazhar

I tried with the below and made my script as executable with chmod command
but the same is not running every 10 minutes.

Need your help

Regards
Mazhar


On 10/9/06, Hal Wigoda <[EMAIL PROTECTED]> wrote:


get rid of the /.


On Oct 9, 2006, at 5:55 AM, Mazhar wrote:

> When i add the entry as specified i get the below error (i.e) */10
> * * * *
> /scritps/xxx.pl in cron
>
> *crontab: error on previous line; unexpected character found in line.*
>
> Regards
> Mazhar
>
>
> On 10/9/06, Jeff Pang <[EMAIL PROTECTED]> wrote:
>>
>>
>> >
>> >I have prepared a script that is to be run as a cron job every 10
>> minutes, i
>> >have added the same in cron as below,
>> >
>> >*0,10,20,30,40,50 * * * * /scripts/x.pl*
>> >
>> >But the above is not running properly, should i add something in the
>> code.
>> >
>>
>> Try this:
>>
>> */10 * * * * /scritps/xxx.pl
>>
>> The xxx.pl should be executable.
>>
>>
>>
>> --
>> Jeff Pang
>> NetEase AntiSpam Team
>> http://corp.netease.com
>>
>> --
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>  
>>
>>
>>




Problems with Net::Pcap

2006-10-09 Thread Mihir Kamdar

hii,

I want to capture all the http packets having all the response information
like message type(GET/POST),etc. Also if the method is POST then postbody
also I want to capture. I am using Net::Pcap for achieving this. The filter
string that I am using is "port 80". But the output I am getting is not
desirable. I am getting a lot of extra unwanted data along with the required
HTTP data. Even the HTTP data that I am getting does not give me postbody
which  is a must for me.

Please advice me how to filter more efficiently to get only HTTP data  and
all  the GET/POST  details.

thanks,

regards,
Mihir


Re: how do i assign variables from a different file..

2006-10-09 Thread Jeff Pang

>
>i am beginer in Perl and have task in hand to do..i got to read lot of
>variables and parameters which are defined in one file. I have to use these
>variables in my perl script ..how do i do this...(how do i use the variables
>in one file in my perl script...)

HELLO,

Simply,you can declare all the variables in that file to be the package 
variable.For example,in the template.file,

template.file

our $header = '...';
our $footer = '...';



Then in the main script,you can get these variables' value by:

script.pl

require "/path/template.file";
our $header;
our $footer;

print $header;  # it should get the variable's value you defined in the 
template.file
print $footer;   # the same


The other way,you can define the codes in that file to be a package,then export 
the variables you needed.

Also about perl's variable scope,please read this article:
http://perl.plover.com/FAQs/Namespaces.html.en



--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Why is Perl a SHE

2006-10-09 Thread Mathew
zentara wrote:
> On Mon, 09 Oct 2006 06:18:58 -0400, [EMAIL PROTECTED] (Mathew
> Snyder) wrote:
> 
>> zentara wrote:
>>> This is perfect for jokes.
>>> How about:
> 
>> Those are just bad...real bad.
>> Mathew Snyder
> 
> So was the question.
> 
> 

To rephrase an old statement, there's no such thing as a bad question.

Mathew


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Problems with Net::Pcap

2006-10-09 Thread Jeff Pang

>I want to capture all the http packets having all the response information
>like message type(GET/POST),etc. 

Hi,

How about using HTTPLook?it's fairly simple and powerful.See:

http://www.httpsniffer.com/

--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Problems with Net::Pcap

2006-10-09 Thread Mihir Kamdar

hii,

I want to capture all the http packets having all the response information
like message type(GET/POST),etc. Also if the method is POST then postbody
also I want to capture. I am using Net::Pcap for achieving this. The filter
string that I am using is "port 80". But the output I am getting is not
desirable. I am getting a lot of extra unwanted data along with the required
HTTP data. Even the HTTP data that I am getting does not give me postbody
which  is a must for me.

Please advice me how to filter more efficiently to get only HTTP data  and
all  the GET/POST  details.

thanks,

regards,
Mihir


Re: Perl Script as a Cron Job

2006-10-09 Thread Paul Johnson
On Mon, Oct 09, 2006 at 03:23:49PM +0400, Mazhar wrote:

> I tried with the below and made my script as executable with chmod command
> but the same is not running every 10 minutes.

Once you have worked out your crontab syntax, almost all cron problems are due
to permissions or environment.

> Need your help

Since you have provided no information whatsoever on how your script is
failing it is hard to say more than that.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Non-deprecated way to capture array length

2006-10-09 Thread Marc Sacks
I needed to find out the length of an array and did it by referencing 
the array in scalar context. However, "use warnings" indicated that this 
is a deprecated feature.  Is there a non-deprecated way to do this 
(other than looping through the whole array until I run out of 
elements)? Thanks.


--
Marc Sacks, Ed.D. | Quality Assurance Manager
Lextranet | 107 Union Wharf | Boston, MA 02109
http://www.lextranet.com
(617) 227-4469 Extension 228 
[EMAIL PROTECTED]


THE INFORMATION IN THIS MESSAGE IS INTENDED ONLY FOR THE PERSONAL AND 
CONFIDENTIAL USE OF THE DESIGNATED RECIPIENTS NAMED ABOVE AND MAY CONTAIN 
LEGALLY PRIVILEGED INFORMATION. If the reader of this message is not the 
intended recipient or an agent responsible for delivering it to the intended 
recipient, you are hereby notified that you have received this document in 
error, and that any review, dissemination, distribution or copying of this 
message is strictly prohibited. If you have received this communication in 
error, please notify us immediately by telephone at 617-227-4469 Ext. 228.  
Thank you.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Non-deprecated way to capture array length

2006-10-09 Thread Jeff Pang

>I needed to find out the length of an array and did it by referencing 
>the array in scalar context. However, "use warnings" indicated that this 
>is a deprecated feature.  Is there a non-deprecated way to do this 
>(other than looping through the whole array until I run out of 
>elements)? Thanks.
>

How do you write it? I can get it like:

$ perl -Mstrict -Mwarnings -le 'my @arr=qw/aa bb cc/;print length(join 
"",@arr)'  
6

--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Non-deprecated way to capture array length

2006-10-09 Thread Derek B. Smith
--- Marc Sacks <[EMAIL PROTECTED]> wrote:

> I needed to find out the length of an array and did
> it by referencing 
> the array in scalar context. However, "use warnings"
> indicated that this 
> is a deprecated feature.  Is there a non-deprecated
> way to do this 
> (other than looping through the whole array until I
> run out of 
> elements)? Thanks.
> 

Hi Mark, 

the best practice/standard way to get an array length
is:

print scalar @array_name,"\n";
or
my $array_lnght = scalar @array_name;

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Non-deprecated way to capture array length

2006-10-09 Thread John W. Krahn
Marc Sacks wrote:
> I needed to find out the length of an array and did it by referencing
> the array in scalar context. However, "use warnings" indicated that this
> is a deprecated feature.  Is there a non-deprecated way to do this
> (other than looping through the whole array until I run out of
> elements)? Thanks.

Using an array in scalar context is *not* deprecated.

Since you haven't shown any code I would have to guess that you are using
defined() on an array which *is* deprecated.



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.   -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Non-deprecated way to capture array length

2006-10-09 Thread Jeff Pang

>
>>I needed to find out the length of an array and did it by referencing 
>>the array in scalar context. However, "use warnings" indicated that this 
>>is a deprecated feature.  Is there a non-deprecated way to do this 
>>(other than looping through the whole array until I run out of 
>>elements)? Thanks.
>>
>
>How do you write it? I can get it like:
>
>$ perl -Mstrict -Mwarnings -le 'my @arr=qw/aa bb cc/;print length(join 
>"",@arr)'  
>6
>

Sorry, if you mean the number of elements in an array,then it should be: 
my $num = scalar @array;

--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Non-deprecated way to capture array length

2006-10-09 Thread Helliwell, Kim

-Original Message-
From: Jeff Pang [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 09, 2006 7:48 AM
To: beginners
Subject: Re: Non-deprecated way to capture array length


>
>>I needed to find out the length of an array and did it by referencing 
>>the array in scalar context. However, "use warnings" indicated that
this 
>>is a deprecated feature.  Is there a non-deprecated way to do this 
>>(other than looping through the whole array until I run out of 
>>elements)? Thanks.
>>
>
>How do you write it? I can get it like:
>
>$ perl -Mstrict -Mwarnings -le 'my @arr=qw/aa bb cc/;print length(join
"",@arr)'  
>6
>

Sorry, if you mean the number of elements in an array,then it should be:

my $num = scalar @array;

--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

-- 
Perhaps I'm behind the times here, but what's wrong with:

my $num = $#array

??

That's how I always do it.

Kim Helliwell
LSI Logic Corporation
Work: 408 433 8475
Cell: 408 832 5365
[EMAIL PROTECTED]
 
Please Note: My email address will change to [EMAIL PROTECTED] on
Oct 14. The old 'lsil.com' email address will stop working after Jan 15,
2007. Please update your address book and distribution lists
accordingly. Thank you.

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Non-deprecated way to capture array length

2006-10-09 Thread Jeff Pang

>-- 
>Perhaps I'm behind the times here, but what's wrong with:
>
>my $num = $#array
>
>??

[EMAIL PROTECTED] ~]$ perl -Mstrict -Mwarnings -le 'my @arr=qw/aa bb cc/;print 
$#arr'  
2
[EMAIL PROTECTED] ~]$ perl -Mstrict -Mwarnings -le 'my @arr=qw/aa bb cc/;print 
scalar @arr'
3

They are not the same.
The $#arr is the last element's index number,while 'scalar @arr' is all the 
elements' total number.

--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Non-deprecated way to capture array length

2006-10-09 Thread Helliwell, Kim
-Original Message-
From: Jeff Pang [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 09, 2006 8:25 AM
To: beginners
Subject: RE: Non-deprecated way to capture array length


>-- 
>Perhaps I'm behind the times here, but what's wrong with:
>
>my $num = $#array
>
>??

[EMAIL PROTECTED] ~]$ perl -Mstrict -Mwarnings -le 'my @arr=qw/aa bb
cc/;print $#arr'  
2
[EMAIL PROTECTED] ~]$ perl -Mstrict -Mwarnings -le 'my @arr=qw/aa bb
cc/;print scalar @arr'
3

They are not the same.
The $#arr is the last element's index number,while 'scalar @arr' is all
the elements' total number.

--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

-- 

Oops, you're right! Guess I'm still half asleep this morning.
But $#arr + 1 is surely another way to get the result sought.
That's the way I always do it, not realizing that scalar @arr
was even available, I guess. However, scalar @arr is computationally
more efficient, I bet, and only slightly longer to write. So it's
probably a better way.

I'm not exactly a Perl beginner, but looks like I learned something
already from this list. Pretty good, seeing I only signed up 3 days
ago

Kim Helliwell
LSI Logic Corporation
Work: 408 433 8475
Cell: 408 832 5365
[EMAIL PROTECTED]


To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Non-deprecated way to capture array length

2006-10-09 Thread John W. Krahn
Marc Sacks wrote:
> John W. Krahn wrote:
> 
>> Marc Sacks wrote:
>>
>>> I needed to find out the length of an array and did it by referencing
>>> the array in scalar context. However, "use warnings" indicated that this
>>> is a deprecated feature.  Is there a non-deprecated way to do this
>>> (other than looping through the whole array until I run out of
>>> elements)? Thanks.
>>
>> Using an array in scalar context is *not* deprecated.
>>
>> Since you haven't shown any code I would have to guess that you are using
>> defined() on an array which *is* deprecated.
>
> Actually, what I did was something like

"what I did was something like" is not the same as "this is the actual code
that produced the warning".


> my @arr = (a,b,c,d,e);
> $length = $arr;

@arr and $arr are two separate variables, the second of which is not even an
array.  There is nothing in that example that should produce a warning message.




John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.   -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: how do i assign variables from a different file..

2006-10-09 Thread Ken Foskey
On Mon, 2006-10-09 at 16:24 +0530, positive mind wrote:
> Greetings !!
> 
> i am beginer in Perl and have task in hand to do..i got to read lot of
> variables and parameters which are defined in one file. I have to use these
> variables in my perl script ..how do i do this...(how do i use the variables
> in one file in my perl script...)
> 
> thnx,
> pm

How about:

while( <$parm> ) {

s/\r//g;

s/\s*#.*//; # Strip comments.

next if( /^\s*$/ );  ## skip blank lines

chomp;
($key,$value) = split(/=/,$_,2);

$ref->{$key} = $value;
}




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Bad scoping? Bad prototyping?

2006-10-09 Thread Helliwell, Kim
The following test script fails to compile, complaining that there are
not enough arguments

in the call to sub2. 

 

#!/bin/perl

 

sub1("Hello, ");

sub1("world\n");

 

sub sub2($str)

{

print $str;

}

sub sub1($str)

{

sub2($str)

}

 

 

The basic problem is that I'm trying to call one subroutine from inside
another. I'm sure I've had

this work before, but there's clearly something I'm doing wrong this
time.

 

Any clues?

 

Thanks,

 

 

 

Kim Helliwell

LSI Logic Corporation

Work: 408 433 8475

Cell: 408 832 5365

[EMAIL PROTECTED]

 

Please Note: My email address will change to [EMAIL PROTECTED]
  on Oct 14. The old 'lsil.com' email
address will stop working after Jan 15, 2007. Please update your address
book and distribution lists accordingly. Thank you.

 



Re: Bad scoping? Bad prototyping?

2006-10-09 Thread Andy Greenwood

On 10/9/06, Helliwell, Kim <[EMAIL PROTECTED]> wrote:

The following test script fails to compile, complaining that there are
not enough arguments

in the call to sub2.



#!/bin/perl



sub1("Hello, ");

sub1("world\n");


Are you sure you want sub1 prototyped twice?




sub sub2($str)

{

print $str;

}

sub sub1($str)

{

sub2($str)

}





The basic problem is that I'm trying to call one subroutine from inside
another. I'm sure I've had

this work before, but there's clearly something I'm doing wrong this
time.



Any clues?



Thanks,







Kim Helliwell

LSI Logic Corporation

Work: 408 433 8475

Cell: 408 832 5365

[EMAIL PROTECTED]



Please Note: My email address will change to [EMAIL PROTECTED]
  on Oct 14. The old 'lsil.com' email
address will stop working after Jan 15, 2007. Please update your address
book and distribution lists accordingly. Thank you.








--
I'm nerdy in the extreme and whiter than sour cream

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Bad scoping? Bad prototyping?

2006-10-09 Thread John W. Krahn
Helliwell, Kim wrote:
> The following test script fails to compile, complaining that there are
> not enough arguments in the call to sub2. 
> 
> #!/bin/perl
> 
> sub1("Hello, ");
> sub1("world\n");
> 
> sub sub2($str)
> {
> print $str;
> }
> 
> sub sub1($str)
> {
> sub2($str)
> }
> 
> The basic problem is that I'm trying to call one subroutine from inside
> another. I'm sure I've had this work before, but there's clearly
> something I'm doing wrong this time.

It looks like you are trying to write a C program using Perl.

perldoc perlsub


You want something like:

#!/bin/perl
use warnings;
use strict;

sub1("Hello, ");
sub1("world\n");

sub sub2
{
my $str = shift;
print $str;
}

sub sub1
{
my $str = shift;
sub2($str)
}



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.   -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Bad scoping? Bad prototyping?

2006-10-09 Thread John W. Krahn
Andy Greenwood wrote:
> On 10/9/06, Helliwell, Kim <[EMAIL PROTECTED]> wrote:
>> The following test script fails to compile, complaining that there are
>> not enough arguments in the call to sub2.
>>
>> #!/bin/perl
>>
>> sub1("Hello, ");
>> sub1("world\n");
> 
> Are you sure you want sub1 prototyped twice?

Those are function *calls* not prototypes.

perldoc perlsub




John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.   -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Bad scoping? Bad prototyping?

2006-10-09 Thread Aaron Priven

On Oct 9, 2006, at 10:35 AM, Helliwell, Kim wrote:


#!/bin/perl

sub1("Hello, ");

sub1("world\n");


sub sub2($str)

{
print $str;
}

sub sub1($str)
{
sub2($str)
}



Prototyping in perl does not do what you think it does. It does not  
turn your arguments into variables. All it does is supply a scalar or  
list context to entries in your argument list. It is not a useful  
feature for most people most of the time, and should be avoided.


http://library.n0i.net/programming/perl/articles/fm_prototypes/

Arguments to subs are always in the array @_

#!/bin/perl
use warnings;
use strict;
# no Top::Posting;

sub1('Hello, ');
sub1("world\n");

sub sub2 {
  my $str = shift; # implicitly uses @_
  print $str;
}

sub sub1 {
   my $str = shift;
   sub2($str)
}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]