RE: Using a variable name to invoke a subroutine

2002-09-24 Thread nkuipers
foreach $sub (@list_of_subs) { {$sub}; ##-- this is the part I am stuck on. This doesn't work } I don't know the answer to your question; I'm also interested in what others have to say. However, I have to wonder if Perl is looking at {$sub} and interpretting it as a command to

Re: Using a variable name to invoke a subroutine

2002-09-24 Thread WyvernGod
here is two examples of that work for me require pl/require.pl; $functiontocall ='RequireAll'; $functiontocall-(); -- - my $alias = home|SplitInput,LoadVariables,DirectUser,; my ($name, $subs) = split(/\|/,

RE: Using a variable name to invoke a subroutine

2002-09-24 Thread Wagner, David --- Senior Programmer Analyst --- WGO
24, 2002 11:11 To: Zielfelder, Robert Cc: [EMAIL PROTECTED] Subject: RE: Using a variable name to invoke a subroutine foreach $sub (@list_of_subs) { {$sub}; ##-- this is the part I am stuck on. This doesn't work } I don't know the answer to your question; I'm also interested in what

Re: Using a variable name to invoke a subroutine

2002-09-24 Thread david
efficient if I can. Any insight would be appreciated. if the order of executing your subroutine is NOT important, use a hash: #!/usr/bin/perl -w use strict; my %hash = ( sub1 = [\sub1,1,2], sub2 = [\sub2,3,4] ); while(my($name,$sub) = each %hash){ my @subs = @{$sub}; print calling

Re: Using a variable name to invoke a subroutine

2002-09-24 Thread John W. Krahn
Robert Zielfelder wrote: I have a script that uses an array to determine weather or not a subroutine needs to be run or not. I want to be able do a foreach on the array and invoke the subroutine using the control variable. The names of the subroutines are the same as the items inside

Array not being passed into a subroutine

2002-09-24 Thread Shaun Bramley
Hello all, I currently currently passing a subroutine one scalar value and two arrays. Both array's work before and after the function call. However only one of hte arrays works within the subroutine. example code: print @array1; //this works print @array2; //this works subroutine

Re: Array not being passed into a subroutine

2002-09-24 Thread John W. Krahn
Shaun Bramley wrote: Hello all, Hello, I currently currently passing a subroutine one scalar value and two arrays. Both array's work before and after the function call. However only one of hte arrays works within the subroutine. example code: print @array1; //this works print

RE: Array not being passed into a subroutine

2002-09-24 Thread Tiller, Jason
Hi, Shaun, :) I currently currently passing a subroutine one scalar value and two arrays. Hmm. This is not what you're doing in the example code. In the example code, this line: subroutine($a, @array1, @array2); says Call subroutine with arguments of $a, all of the entries in @array1

RE: Array not being passed into a subroutine

2002-09-24 Thread Timothy Johnson
When you pass an array to a subroutine in Perl, it takes the arguments and passes a list, I _think_ even if you use that format. It would be much better, IMHO to use references. Something like: ### SCRIPT # use strict;#Get in the habit of using

Re: sub1(@array,$var); - passing an array and scalar to a subroutine...

2002-09-17 Thread Anthony E.
thanks, i ended up getting what i wanted with references: sub1(\@array,$var); sub sub1() { my ($ref, $var) = @_; my @data = @$ref; ... } --- drieux [EMAIL PROTECTED] wrote: On Friday, Sep 13, 2002, at 16:29 US/Pacific, Anthony E. wrote: [..] for example, i tried this, but it

Re: Translating fortran subroutine to perl

2002-09-08 Thread John Cichy
. Compared to the goes image, the lat/lon pairs are stored by column first, then row; i.e. all the elements in row 1 are stored, then row 2 etc until the bottom of the image. The following is a fortran subroutine that can be used to read the goes.nav file

Re: Translating fortran subroutine to perl

2002-09-08 Thread John W. Krahn
John Cichy wrote: Thank you very much, you confirmed that I was at least on the right track with what I was doing. The numbers are still not coming out correctly (at least not what I was expecting). This file seems to be geared towards a sun system, could this be effecting my results, would

Re: Translating fortran subroutine to perl

2002-09-08 Thread John W. Krahn
John Cichy wrote: Thank you very much, you confirmed that I was at least on the right track with what I was doing. The numbers are still not coming out correctly (at least not what I was expecting). This file seems to be geared towards a sun system, could this be effecting my results, would

Re: Translating fortran subroutine to perl

2002-09-07 Thread John W. Krahn
until the bottom of the image. The following is a fortran subroutine that can be used to read the goes.nav file: subroutine getnav(lat,lon) c c* This routine reads goes.nav files

Translating fortran subroutine to perl

2002-09-07 Thread John Cichy
. The following is a fortran subroutine that can be used to read the goes.nav file: subroutine getnav(lat,lon) c c* This routine reads goes.nav files with a maximum size of * c* 2000 pixels

RE: Undefined subroutine main::param called

2002-07-31 Thread Kyle Babich
, but you might want to try something like this: $q = new CGI; my $con = $q-param('con'); Soheil -Original Message- From: Kyle Babich [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 31, 2002 1:37 PM To: beginners-cgi Subject: Undefined subroutine main::param called

passing hash to a subroutine

2002-07-11 Thread rory oconnor
Is it possible to pass a hash into a subroutine to be used as a local variable? I'm trying to do this: ($rows, %results) = Select($mytable, $where_f1, $compare1, $where_v1, @quick_check, %field_values); sub Select { my($db_table, $where_field, $comparison, $where_value,@fieldlist, %values

Re: passing hash to a subroutine

2002-07-11 Thread George Schlossnagle
The last item that you pass to a perl subroutine can be a array or a hash, but none but the last, since oerl will greedy-match your arrays when you assign them in your subroutine. The way around this is to pass them in by reference: ($rows, %results) = Select($mytable, $where_f1, $compare1

Re: passing hash to a subroutine

2002-07-11 Thread Jeff 'japhy' Pinyan
On Jul 11, rory oconnor said: Is it possible to pass a hash into a subroutine to be used as a local variable? I'm trying to do this: The arguments sent to a function are flattened into one big list. There's no way to know where your array ends and your hash begins. Furthermore, doing $x

Re: passing hash to a subroutine

2002-07-11 Thread Jenda Krynicky
From: George Schlossnagle [EMAIL PROTECTED] The last item that you pass to a perl subroutine can be a array or a hash, but none but the last, since oerl will greedy-match your arrays when you assign them in your subroutine. The way around this is to pass them in by reference: ($rows

How to pass the value of $@ to a subroutine

2002-07-03 Thread Ian Zapczynski
Hello all, What I want to do is simple - if an error occurs on my previous command (in this case, making an FTP connection via Net::FTP), I want to send the value of $@ to a subroutine which sends an e-mail containing the value of $@ in the body. However, it is clear that I don't understand

Re: How to pass the value of $@ to a subroutine

2002-07-03 Thread Ian Zapczynski
. Singh wrote: Hello all, What I want to do is simple - if an error occurs on my previous command (in this case, making an FTP connection via Net::FTP), I want to send the value of $@ to a subroutine which sends an e-mail containing the value of $@ in the body. However, it is clear that I

RE: How to pass the value of $@ to a subroutine

2002-07-03 Thread David . Wagner
into the sub. Wags ;) ps others may be to make clearer. -Original Message- From: Ian Zapczynski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 03, 2002 12:34 Cc: [EMAIL PROTECTED] Subject: Re: How to pass the value of $@ to a subroutine Thanks! Changing: my $message = @_; to: my ($message

RE: How to pass the value of $@ to a subroutine

2002-07-03 Thread Shishir K. Singh
Thanks! Changing: my $message = @_; to: my ($message) = @_; did put the correct value in the string. If anyone cares to explain the difference between the code I had and the code Shishir suggested so I can understand why this makes a difference, I'm all ears! @_ is an array. You were

Re: how to include a subroutine from external file?

2002-06-26 Thread drieux
On Wednesday, June 26, 2002, at 07:38 , Kipp, James wrote: so which is better? to make a lib file with functions or a modular/OOP pm file ? technically this is a false dichotomy. you can not tell if the file BAR.pm is an OO style Perl Module, or merely a Functional/Proceduralist style Perl

RE: how to include a subroutine from external file?

2002-06-26 Thread Kipp, James
so far all my libs (well there ain't much ) are all OO pm files. There is what I would call the 'dataLess' OO solution, what is known as a 'utility class' - where one has only a stack of methods that one wishes to have in a 'nameSpaceSafe' environment - so that you know that my

Re: how to include a subroutine from external file?

2002-06-24 Thread drieux
On Sunday, June 23, 2002, at 10:11 , Timothy Johnson wrote: [..] If you put the module above in a file called UC.pm in the site/lib/Tim folder, you will have a module with your reusable subroutine. The only weird part: Don't forget that the last line should be just a '1'. Just put a use

how to include a subroutine from external file?

2002-06-23 Thread Hytham Shehab
hi all of you, i have a multiple perl files that use the same subroutines, the only way i know to handle this - i know its not so cleaver - is to copy paste the portion of the subroutine in all perl files i want to use it, what is the more clever way? thx v. much -- Hytham Shehab

Re: how to include a subroutine from external file?

2002-06-23 Thread J. Lundeen
I'm not sure I understand what you're asking. Please clarify. -Jimmy James Hytham Shehab wrote: hi all of you, i have a multiple perl files that use the same subroutines, the only way i know to handle this - i know its not so cleaver - is to copy paste the portion of the subroutine

Re: how to include a subroutine from external file?

2002-06-23 Thread J. Lundeen
what you're asking. Please clarify. -Jimmy James Hytham Shehab wrote: hi all of you, i have a multiple perl files that use the same subroutines, the only way i know to handle this - i know its not so cleaver - is to copy paste the portion of the subroutine in all perl files i want

Re: how to include a subroutine from external file?

2002-06-23 Thread Hytham Shehab
i think that writing a module is not my answere, i think it is a huge complicated answere for a simple question. all what i want is simply put all my used subroutines in a seperate files, then call the subroutine from that file whenever i want to use the subroutine, am i clear now? no redundency

Re: how to include a subroutine from external file?

2002-06-23 Thread bob ackerman
the subroutine from that file whenever i want to use the subroutine, am i clear now? no redundency is my only target, thats it... thx v. much, specially Lundeen and drieux -- Hytham Shehab -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED

Re: how to include a subroutine from external file?

2002-06-23 Thread drieux
in a seperate files, then call the subroutine from that file whenever i want to use the subroutine, am i clear now? Ok, let start out simple then - we'll get you to h2xs and the rest of that as they become more useful. you need three basic things: a) a place to put them that you will always

Re: how to include a subroutine from external file?

2002-06-23 Thread drieux
; And the freaking code STILL works. all what i want is simply put all my used subroutines in a seperate files, then call the subroutine from that file whenever i want to use the subroutine, am i clear now? [..] Well I hope this will help you: http://www.wetware.com/drieux/pbl/perlTrick/subStuff

RE: how to include a subroutine from external file?

2002-06-23 Thread Timothy Johnson
= $_[0]; foreach my $element(@{$ref}){ $element = uc($element); } } 1 ## If you put the module above in a file called UC.pm in the site/lib/Tim folder, you will have a module with your reusable subroutine. The only weird part: Don't forget that the last line should be just

RE: subroutine or subroutine

2002-06-07 Thread kevin christopher
Jun 2002 08:23:33 -0500 Janek, Wouldn't it print: foo: foo:A B C Also, I believe that you must declare the subroutine before you are allowed to reference it without the . Am I right about that? -Original Message- From: Janek Schleicher [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June

RE: subroutine or subroutine

2002-06-06 Thread Camilo Gonzalez
Janek, Wouldn't it print: foo: foo:A B C Also, I believe that you must declare the subroutine before you are allowed to reference it without the . Am I right about that? -Original Message- From: Janek Schleicher [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 05, 2002 5:10 AM

RE: subroutine or subroutine

2002-06-06 Thread Camilo Gonzalez
]] Sent: Wednesday, June 05, 2002 8:30 AM To: 'Octavian Rasnita'; [EMAIL PROTECTED] Subject: RE: subroutine or subroutine -Original Message- From: Octavian Rasnita [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 04, 2002 2:06 PM To: [EMAIL PROTECTED] Subject: subroutine or subroutine

RE: subroutine or subroutine

2002-06-06 Thread Joel Hughes
No, the subroutinue body can occur before or after the invokation point with or without the . joel -Original Message- From: Camilo Gonzalez [mailto:[EMAIL PROTECTED]] Sent: 06 June 2002 14:24 To: 'Janek Schleicher'; [EMAIL PROTECTED] Subject: RE: subroutine or subroutine Janek

Fwd: notBob clarifies the Bob was Re: subroutine or subroutine

2002-06-06 Thread drieux
Begin forwarded message: From: drieux [EMAIL PROTECTED] Date: Thu Jun 06, 2002 07:38:29 US/Pacific To: begin begin [EMAIL PROTECTED] Subject: notBob clarifies the Bob was Re: subroutine or subroutine On Thursday, June 6, 2002, at 06:31 , Camilo Gonzalez wrote: [..] Since

RE: subroutine or subroutine

2002-06-06 Thread Janek Schleicher
Bob Showalter wrote at Wed, 05 Jun 2002 15:30:29 +0200: 3. Don't use the foo or foo(args) calling styles. Allthough I would miss it a little bit. I find the foo style useful when implementing a little polymorphic subroutine. Example: sub foo { /NUMERIC/ _foo_numeric

notBob clarifies the Bob was Re: subroutine or subroutine

2002-06-06 Thread drieux
On Thursday, June 6, 2002, at 06:31 , Camilo Gonzalez wrote: [..] Since this is a list for newbies, can you please be a bit more specific why you are opposed to those things you list. I'm quite fond of using the foo or foo(args) calling styles. Is this just a personal preference? [..] Bob

Re: subroutine or subroutine

2002-06-05 Thread kevin christopher
Yes, you can call subroutines either way, with or without the . The only case when the subroutine must be prefixed with an ampersand is, I believe, when you're assigning a reference variable, eg: $reference_x = \subroutine_y; But that's another story. Kevin -- Original Message

Re: subroutine or subroutine

2002-06-05 Thread Janek Schleicher
Kevin Christopher wrote at Wed, 05 Jun 2002 04:58:38 +0200: Yes, you can call subroutines either way, with or without the . The only case when the subroutine must be prefixed with an ampersand is, I believe, when you're assigning a reference variable, eg: $reference_x = \subroutine_y

RE: subroutine or subroutine

2002-06-05 Thread Bob Showalter
-Original Message- From: Octavian Rasnita [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 04, 2002 2:06 PM To: [EMAIL PROTECTED] Subject: subroutine or subroutine Hi all, I've seen some subroutines are ran without the sign in front of the subroutine name, like

RE: subroutine or subroutine

2002-06-05 Thread Nikola Janceski
To: 'Octavian Rasnita'; [EMAIL PROTECTED] Subject: RE: subroutine or subroutine Here are my recommendations for new code (others may want to debate these): 1. Always use strict; 2. Don't use prototypes. 3. Don't use the foo or foo(args) calling styles. 4. To call a sub with no arguments

subroutine or subroutine

2002-06-04 Thread Octavian Rasnita
Hi all, I've seen some subroutines are ran without the sign in front of the subroutine name, like: subroutine_name; instead of subroutine_name; Is it the same thing or there is a difference? Thank you. Teddy, [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

Passing array to subroutine problem

2002-06-04 Thread Robert Thompson
Hello, I have a subroutine where I want to pass some paramaters to it, but assign default ones if a paramater is not passed. This is similar to CGI. mySub( -param1='my value', -param3='value' ); # -param2 would get a default value The problem I am running

RE: Passing array to subroutine problem

2002-06-04 Thread Bob Showalter
-Original Message- From: Robert Thompson [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 04, 2002 3:38 PM To: [EMAIL PROTECTED] Subject: Passing array to subroutine problem Hello, I have a subroutine where I want to pass some paramaters to it, but assign default ones

Subroutine

2002-05-31 Thread Anne . Webel
Hi, I'm having a very frustrating time with a small test program I'm trying to write. I'm using ActivePerl 5. I'm sure the answer is simple and I'll kick myself when someone clarifies the matter, but here goes anyway: The error message is: Undefined subroutine main::html_chars called at test2

Re: Subroutine

2002-05-31 Thread Sudarsan Raghavan
[EMAIL PROTECTED] wrote: Hi, I'm having a very frustrating time with a small test program I'm trying to write. I'm using ActivePerl 5. I'm sure the answer is simple and I'll kick myself when someone clarifies the matter, but here goes anyway: The error message is: Undefined subroutine

Re: Is there a good Perl way for a validation subroutine?

2002-05-29 Thread Janek Schleicher
Tagore Smith wrote at Wed, 29 May 2002 06:13:25 +0200: ... in pseudocode: my @failed; if (field fails validation){ push @failed, $fieldname; } } etc. Or in another pseudocode: my @failed = grep {field fails validation} @fields; Cheerio, Janek -- To unsubscribe, e-mail:

[Thanks] Re: Is there a good Perl way for a validation subroutine?

2002-05-29 Thread Leila Lappin
Thanks for the suggestions guys. - Original Message - From: Leila Lappin [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, May 28, 2002 11:55 PM Subject: Is there a good Perl way for a validation subroutine? Hello all, I need to write a subroutine that validates several fields

Is there a good Perl way for a validation subroutine?

2002-05-28 Thread Leila Lappin
Hello all, I need to write a subroutine that validates several fields and returns one summary field containing names of what failed. I was thinking of concatenating names of all fields that failed and return that string from the subroutine. Then check the string (return value) and if it's

Re: Is there a good Perl way for a validation subroutine?

2002-05-28 Thread Tagore Smith
Leila Lappin wrote: Hello all, I need to write a subroutine that validates several fields and returns one summary field containing names of what failed. I was thinking of concatenating names of all fields that failed and return that string from the subroutine. Then check the string (return

FILE to subroutine

2002-05-07 Thread Murzc
HI, Will someone please tell me how to send a filehandle to a subroutine, with the syntax. open(FILE, file.fil); $foo = FILE subro( )-How do I send down FILE sub subro { my = @_; - How do I pick it up? thank you -- To unsubscribe, e-mail: [EMAIL PROTECTED

RE: FILE to subroutine

2002-05-07 Thread Timothy Johnson
Here's a nice little article on that: http://www.rocketaware.com/perl/perlfaq5/How_can_I_make_a_filehandle_loca.ht m -Original Message- From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: 5/7/02 8:36 AM Subject: FILE to subroutine HI, Will someone please tell me how to send

RE: FILE to subroutine

2002-05-07 Thread Timothy Johnson
Oops! Looks like I forgot the 'm'. That should be http://www.rocketaware.com/perl/perlfaq5/How_can_I_make_a_filehandle_loc a.htm -Original Message- From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: 5/7/02 8:58 AM Subject: FILE to subroutine Sorry This was the message that came up

Re: FILE to subroutine

2002-05-07 Thread bob ackerman
by the email reader. unfortunately, the same thing happened on the second try. now with 'a.htm' .. -Original Message- From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: 5/7/02 8:58 AM Subject: FILE to subroutine Sorry This was the message that came up. for the URL: http

Re: FILE to subroutine

2002-05-07 Thread Felix Geerinckx
on Tue, 07 May 2002 15:58:50 GMT, wrote: The requested URL /perl/perlfaq5/How_can_I_make_a_filehandle_loca.ht was not found on this server. Can anyone get the text or provide the answer on paper? If you type perldoc -q filehandle local at a command prompt, the text will

Re: how to return an array reference from a subroutine

2002-04-18 Thread Felix Geerinckx
on Thu, 18 Apr 2002 12:56:43 GMT, [EMAIL PROTECTED] (Richard Noel Fell) wrote: However, I do not understand your comments about the return value of map. Does not map return a reference to an anonymous arrar, not a hash? 'map' returns a *list*. This list can be coerced into an array or into

Re: how to return an array reference from a subroutine

2002-04-18 Thread richard noel fell
Felix - Thanks for the very clear explanation. Dick Felix Geerinckx wrote: on Thu, 18 Apr 2002 12:56:43 GMT, [EMAIL PROTECTED] (Richard Noel Fell) wrote: However, I do not understand your comments about the return value of map. Does not map return a reference to an

Re: how to return an array reference from a subroutine

2002-04-18 Thread drieux
On Thursday, April 18, 2002, at 06:05 , Felix Geerinckx wrote: on Thu, 18 Apr 2002 12:56:43 GMT, [EMAIL PROTECTED] (Richard Noel Fell) wrote: However, I do not understand your comments about the return value of map. Does not map return a reference to an anonymous arrar, not a hash?

Re: how to return an array reference from a subroutine

2002-04-18 Thread Felix Geerinckx
on Thu, 18 Apr 2002 18:07:38 GMT, Drieux wrote: hence map {[ 'cascade', '~'.$_]} @sub_directories; as the last line of the sub should have returned a 'list' back to the caller just as the sub foo { qw/ 1 2 3 4 5 6 7 8 9 / } ; would return a 'list' ??? Yes or should

Re: how to return an array reference from a subroutine

2002-04-18 Thread drieux
On Thursday, April 18, 2002, at 11:21 , Felix Geerinckx wrote: [..] Personally, however, I prefer an explicit 'return' statement, as in return map { ($_ = 1) }, @array; (The () are optional). [..] Ok, I can go there... so my test code shows me [jeeves:~/tmp/perl/misc] drieux% perl

how to return an array reference from a subroutine

2002-04-17 Thread richard noel fell
. I get an error message : Not an ARRAY reference at /usr/local/ActivePerl-5.6/lib/site_perl/5.6.1/i686-linux-thread-multi/Tk/Menu.pm line 69. The cause of this is the subroutine sub_menu. As I understand things, the argument to -menuitems must be a reference to an anonymous array. Am I correct

Re: how to return an array reference from a subroutine

2002-04-17 Thread drieux
On Wednesday, April 17, 2002, at 02:09 , richard noel fell wrote: [..] sub create_menu_bar { my $mb = $MW-Menu(); $MW-configure(-menu=$mb); opendir DIR, ./ or die cannot open current directory: $!; my $current_directory = cwd; my @directories = grep { !/^\.\.?$/ -d

syb_err_handler subroutine question

2002-04-12 Thread Alain Savio
Hi all, Despite what the documentation says on this topic, I'm unable to have the 8th parameter of syb_err_handler even after having set syb_show_sql to true: use DBI; # --- # Errors handling # --- sub msg_handler_SYB { print join ( | , @_), \n; } $sth =

Re: anonymous subroutine problem

2002-03-29 Thread Paul Tremblay
} my $_incr_count = sub {++$_count};#create an anonymous subroutine sub new{ $_incr_count-();#call anonymous subroutine # # Instead I could put this code?: # my $_incr_count = sub {++$_count}; #$_incr_count

Re: anonymous subroutine problem

2002-03-29 Thread bob ackerman
in the entire collection? print The number of CDs is ,CD::Music-get_count, \n; package CD::Music; use strict; { my $_count = 0; sub get_count {$_count} my $_incr_count = sub {++$_count};#create an anonymous subroutine sub new

Re: anonymous subroutine problem

2002-03-29 Thread bob ackerman
, 5.0); # How many CDs in the entire collection? print The number of CDs is ,CD::Music-get_count, \n; package CD::Music; use strict; { my $_count = 0; sub get_count {$_count} my $_incr_count = sub {++$_count};#create an anonymous subroutine

How to run it without a subroutine

2002-03-27 Thread Octavian Rasnita
Hi all, I am fighting with the following short test script, and I can make it work only if I use a subroutine. I want to make it work without a subroutine. The script works as it is, but if I remove the line that runs the subroutine, and the first and last lines of the subroutine (sub up

anonymous subroutine problem

2002-03-27 Thread Paul Tremblay
an anonymous subroutine $_incr_count-();# it works if I call it here sub new{ $_incr_count-();#call the anonymous subroutine #this line above causes the error below #Isn't this where the anonymous subroutine should go? #my $_incr_count = sub {++$_count

Re: anonymous subroutine problem

2002-03-27 Thread bob ackerman
Perl* by Conway. (Error message is below.) package CD::Music; #use strict; # turn this off for testing purposes { my $_count = 0; sub get_count {$_count} my $_incr_count = sub {++$_count};#create an anonymous subroutine $_incr_count-();# it works if I

re: returning value from subroutine

2002-03-25 Thread J . Hourihane
1. I want to be able to create a hostname = user hash table like this %hosts = ( sun1 = bobby, sun2 + ronald, ) and a scalar like this $hostname = qx(/usr/ucb/hostname); 2. I want to be able to build a simple sub like this sub getname { print $getname{$hostname};

re: returning value from subroutine

2002-03-25 Thread Jeff 'japhy' Pinyan
On Mar 25, [EMAIL PROTECTED] said: and a scalar like this $hostname = qx(/usr/ucb/hostname); You'll want to chomp() $hostname! Output from the /usr/ucb/hostname command probably has a newline at the end of it; you'll need to remove it. 2. I want to be able to build a simple sub like this

Subroutine to write to file

2002-03-24 Thread Rafael Cotta
Hi all, As you can see, I am a newbie, and I don't have the time to write this from my own, so, I gotta ask. I need a sobroutine to append a string passed as parameter to a file. And this sobroutine has to lock and unlock the file, and wait if the file is locked when it tries to write. This

Re: Subroutine to write to file

2002-03-24 Thread fliptop
Rafael Cotta wrote: I need a sobroutine to append a string passed as parameter to a file. And this sobroutine has to lock and unlock the file, and wait if the file is locked when it tries to write. This may be a very simple thing. Could someone give me a sample? have you tried the faq?

Re: Undefined subroutine

2002-03-08 Thread Jonathan E. Paton
Greetings everyone, I have a script serving pages on our website, and every now and then it gives me an Internal Error and the logs say: [Thu Mar 7 15:19:33 2002] [error] Undefined subroutine pollstar::singleadvert called at /home/pollstar/tour/newsearchall.pl line 1026

Undefined subroutine

2002-03-07 Thread Agustin Rivera
Greetings everyone, I have a script serving pages on our website, and every now and then it gives me an Internal Error and the logs say: [Thu Mar 7 15:19:33 2002] [error] Undefined subroutine pollstar::singleadvert called at /home/pollstar/tour/newsearchall.pl line 1026. But the routine

forcing a script to finish in a subroutine

2002-03-05 Thread W P
i'm making my own (hopefully informative) error pages for my site. i have defined a subroutine pr_error which takes the error(s) as input and outputs an HTML page. how can i make it go to the end of the script ( __END__ ) on those errors (which will not necessarily be fatal). for example: my

Re: forcing a script to finish in a subroutine

2002-03-05 Thread fliptop
W P wrote: i'm making my own (hopefully informative) error pages for my site. i have defined a subroutine pr_error which takes the error(s) as input and outputs an HTML page. how can i make it go to the end of the script ( __END__ ) on those errors (which will not necessarily be fatal

SHIFT in a subroutine

2002-02-20 Thread Nestor Florez
I was wondering about the shift inside a subroutine. I have never used it. What is the purpose of it been there? Thanks in advance, Nestor :-) - Original Message - From: Stephen.Hurley [EMAIL PROTECTED] To: 'Bruce Ambraal' [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday

Re: SHIFT in a subroutine

2002-02-20 Thread Brett W. McCoy
On Wed, 20 Feb 2002, Nestor Florez wrote: I was wondering about the shift inside a subroutine. I have never used it. What is the purpose of it been there? It pulls off the first element of the array passed to it. Using shift with no arguments always pulls from @_ -- it returns $_[0

Re: SHIFT in a subroutine

2002-02-20 Thread Curtis Poe
--- Brett W. McCoy [EMAIL PROTECTED] wrote: On Wed, 20 Feb 2002, Nestor Florez wrote: I was wondering about the shift inside a subroutine. I have never used it. What is the purpose of it been there? It pulls off the first element of the array passed to it. Using shift

Re: SHIFT in a subroutine

2002-02-20 Thread Brett W. McCoy
On Wed, 20 Feb 2002, Curtis Poe wrote: Great description with one minor caveat: shift with no arguments will pull from @ARGV if not used in a subroutine. Yes, thanks for pointing that out. -- Brett http://www.chapelperilous.net

Error from a `cmd` sent to a subroutine?

2002-02-15 Thread Paul Farley
it to an error subroutine. Here's what I have now: SNIPPED sub subscription { ($passed_ep,$passed_pr$passed_sub,$passed_org,$passed_plat)=shift; #add error routine to handle if PR/PM doesn't exist -pass to exception_sub? `wsub \@ProfileManager:Staging \@Endpoint:$passed_ep`; `wln \@Endpoint

Re: Error from a `cmd` sent to a subroutine?

2002-02-15 Thread Brett W. McCoy
On Fri, 15 Feb 2002, Paul Farley wrote: I have an application that I am using a perl script to do pattern matching and then execute commands specific to that application. I need a way to handle an error in my script if one of the `cmd blah`; doesn't work and send it to an error subroutine

Re: Error from a `cmd` sent to a subroutine?

2002-02-15 Thread Farley Paul J Contr 78 CS/SCBN
it to an error subroutine. Here's what I have now: SNIPPED sub subscription { ($passed_ep,$passed_pr$passed_sub,$passed_org,$passed_plat)=shift; #add error routine to handle if PR/PM doesn't exist -pass to exception_sub? `wsub \@ProfileManager:Staging \@Endpoint

avoid Subroutine bits redefined

2002-02-12 Thread John
Is there any way to avoid these warnings if I have multiple libraries that use strict. BTW, I think all of mine use struct, I think the vendor's use Strict. Subroutine bits redefined at c:\iw-home\iw-perl\lib/Strict.pm line 88. Subroutine import redefined at c:\iw-home\iw-perl\lib/Strict.pm

Re: avoid Subroutine bits redefined

2002-02-12 Thread Jonathan E. Paton
--- John [EMAIL PROTECTED] wrote: Is there any way to avoid these warnings if I have multiple libraries that use strict. BTW, I think all of mine use strict, I think the vendor's use Strict. Perl looks for 'strict' and 'Strict' as different modules, but they install themselves into the same

Re: how to pass an object as an argument in a subroutine?

2002-01-30 Thread Michael Fowler
On Tue, Jan 29, 2002 at 08:55:31PM -0500, [EMAIL PROTECTED] wrote: $currency1-currency_object_math(\$currency2, '+'); In the above example, currency_object_math recognizes $currency2 as a simple reference, not a blessed reference. That's because it is a simple reference. You're

Re: how to pass an object as an argument in a subroutine?

2002-01-30 Thread Deen Hameed
$currency2 is already a reference (to the currency object). you can just pass it as: $currency1-currency_object_math($currency2, '+'); On Tue, 29 Jan 2002 [EMAIL PROTECTED] wrote: $currency1-currency_object_math(\$currency2, '+'); P.S. I'm not currently subscribed to the list,

how to get hash values returned from a subroutine?

2002-01-28 Thread Martin A. Hansen
hi there im trying to call a subroutine and get it to return some hash table values. however, i have two problems. 1. it does not work. theres something wrong with my foreach sentence, but i cant see what it is. however, the commented foreach sentence do work? 2. the @return_array

Re: how to get hash values returned from a subroutine?

2002-01-28 Thread Deen Hameed
On Mon, 28 Jan 2002, Martin A. Hansen wrote: $extract = qw (en tre ni); # foreach $number (qw en tre ni) { foreach $number ($extract) { ummm... shouldn't this be forwach $number (@extract) { ? ^ note the @ you're calling the for loop with a

Re: how to get hash values returned from a subroutine?

2002-01-28 Thread John W. Krahn
Martin A. Hansen wrote: hi there Hello, im trying to call a subroutine and get it to return some hash table values. however, i have two problems. 1. it does not work. theres something wrong with my foreach sentence, but i cant see what it is. however, the commented foreach

subroutine returning lines of text

2002-01-16 Thread Martin A. Hansen
hi im wondering how i can make a subroutine that will return all text lines between certain marks such as START and STOP: text file: START text is here and there is a lot of it STOP so i would like to call the subroutine with the arguments START and STOP (because i may need more starts

Re: subroutine returning lines of text

2002-01-16 Thread Briac Pilpré
Martin A. Hansen wrote: im wondering how i can make a subroutine that will return all text lines between certain marks such as START and STOP: Here's simple way to do it. It uses the '..' operator (see perldoc perlop for more info about it). Note that if START and STOP are in the same line

RE: subroutine returning lines of text

2002-01-16 Thread Gary Hawkins
im wondering how i can make a subroutine that will return all text lines between certain marks such as START and STOP: text file: START text is here and there is a lot of it STOP so i would like to call the subroutine with the arguments START and STOP (because i may need more

Re: SubRoutine Help

2002-01-07 Thread John W. Krahn
Michael R. Wolf wrote: # Readable. sub total { my $sum; foreach my $num (@_) { $sum += $num; } return $sum; } # Streamlined sub total { my $sum; $sum += $_ foreach (@_);# $_ implicitly set } # sum implicitly returned

<    5   6   7   8   9   10   11   >