On Sun, Jul 29, 2012 at 11:19 PM, Andy Bach wrote:
> On Sun, Jul 29, 2012 at 10:01 AM, lina wrote:
>> Strangely, it only substituted once, but not for the later once.
>> Thanks ahead for your suggestions, I don't know why,
>
> Not exactly sure what you're up to - but you only open fh1 once - so
>
On Sun, Jul 29, 2012 at 10:01 AM, lina wrote:
> Strangely, it only substituted once, but not for the later once.
> Thanks ahead for your suggestions, I don't know why,
Not exactly sure what you're up to - but you only open fh1 once - so
the inner while in your sub is going to read until eof and c
On 11/1/11 Tue Nov 1, 2011 12:02 PM, "rent0n" scribbled:
> Hi all,
>
> Can somebody please explain what is the difference between:
>
> sub subroutine {
> my $var = @_;
> ...
> return 1;
> }
>
> and:
>
> sub subroutine {
> my ($var) = @_;
> ...
> return 1;
> }
>
> I think it's something rel
On 11/01/2011 03:02 PM, rent0n wrote:
Hi all,
Can somebody please explain what is the difference between:
sub subroutine {
my $var = @_;
that puts @_ in a scalar context which returns the number of elements in
an array.
...
return 1;
}
and:
sub subroutine {
my ($var) = @_;
...
that puts
From: Shlomi Fish [mailto:shlo...@iglu.org.il]
> On Friday 26 Mar 2010 18:39:30 Shawn H Corey wrote:
>> It's nice to be brief but only providing it does interfere with
>> understanding. Remember: Hard to understand code is costly to
>> maintain code.
>
> I don't believe in programming in an id
Hi Shawn,
On Friday 26 Mar 2010 18:39:30 Shawn H Corey wrote:
> On Fri, 26 Mar 2010 16:06:04 +0300
>
> Shlomi Fish wrote:
> > One thing hackers like is brevity.
>
> I got a better idea. Let's assume that the person who maintains your
> code is a recent graduate that doesn't have any experience
On Fri, 26 Mar 2010 16:06:04 +0300
Shlomi Fish wrote:
> One thing hackers like is brevity.
I got a better idea. Let's assume that the person who maintains your
code is a recent graduate that doesn't have any experience with Perl.
How would he know that shift does two different things?
It's nic
Hi Shawn!
On Thursday 25 Mar 2010 20:38:59 Shawn H Corey wrote:
> On Thu, 25 Mar 2010 19:54:48 +0200
>
> Shlomi Fish wrote:
> > Well, this is a bike shed argument. I find using "shift;" instead of
> > "shift(@_);" when inside subroutines to be faster to write, more
> > concise and more idiomatic
On Thu, 25 Mar 2010 19:54:48 +0200
Shlomi Fish wrote:
> Well, this is a bike shed argument. I find using "shift;" instead of
> "shift(@_);" when inside subroutines to be faster to write, more
> concise and more idiomatic. shift has this magic for a reason. I'm
> unlikely to use shift the other wa
On Thursday 25 Mar 2010 18:52:09 Shawn H Corey wrote:
> On Thu, 25 Mar 2010 17:13:53 +0200
>
> Shlomi Fish wrote:
> > sub display_page
> > {
> >
> > my $a_server = shift;
> > my $a_pass = shift;
> > .
> > .
> > .
> >
> > }
> > }}}
> >
> > (shift is short for << shift(@_) >>
On Thu, 25 Mar 2010 17:13:53 +0200
Shlomi Fish wrote:
> sub display_page
> {
> my $a_server = shift;
> my $a_pass = shift;
> .
> .
> .
> }
> }}}
>
> (shift is short for << shift(@_) >> )
If you're going to use shift, name the array.
my $var;
sub foo {
$var = shi
AM
> To: Pry, Jeffrey
> Subject: RE: Subroutines With Multiple Parameters
>
> Jeffery
>
> When you call your subroutine make sure you have the '&' in front of
> your subroutine name:
>
> Like this
>
> &displayPage($servername, $password);
On Thu, Mar 25, 2010 at 1:54 PM, Pry, Jeffrey wrote:
> sub displayPage($) {
>
>my($server) = shift;
>print $server;
> }
>
Hi,
I'd repeat the advice about staying away from prototypes, i.e. the
'($)' business after your subroutine name. Perl is very good at
figuring out wh
On Thu, 25 Mar 2010 09:54:13 -0400
"Pry, Jeffrey" wrote:
> Hey,
>
> I have a subroutine
>
> sub displayPage($) {
>
> my($server) = shift;
> print $server;
> }
>
> Which I can call using displayPage("servername");
>
> My question is lets say I wanted to pass a password
That was exactly what I was looking for! Thank you so much!
- Jeffrey Kevin Pry
-Original Message-
From: Gorrebeeck, Robert [mailto:gorrebeec...@cvty.com]
Sent: Thursday, March 25, 2010 10:01 AM
To: Pry, Jeffrey
Subject: RE: Subroutines With Multiple Parameters
Jeffery
When you call
Stuart White <[EMAIL PROTECTED]> wrote:
:
: Couple things:
:
: About declaring variables in while loops and if
: constructs. I don't do that because it's messy and
: disorganized for me. I prefer to declare all the
: variables I will use in a subroutine at the top of the
: subroutine, before I
Couple things:
About the subroutine declaration, and the declaration
of the parameters I want to pass to it, I do it
because that's how I understood the book to tell me.
Besides, I'm comfortable with it that way as it helps
me organize my thoughts.
About declaring variables in while loops and if
Stuart White <[EMAIL PROTECTED]> wrote:
:
:
: HEre is the code:
:
: Note: Though I have been told twice, maybe 3x that I
: do not need to declare the number of variables that I
: am passing, my book, Perl for Beginners, says I do,
: and, the program doesn't print anything when I leave
: the decl
thanks for the help so far. the program is much
closer to what I want it to be now. the last thing is
to count the total number of fouls committed, send
them back to the 'main' program, and print them there.
I can do the sending back and printing, I'm not sure
how to do the counting. Essentially
On Jul 21, Stuart White said:
>I tried reading the perldoc, but it came up all screwy
>on my screen. Lines ran over the end. I'm having
Then you can read them online at http://www.perldoc.com/.
>trouble passing variables into a subroutine.Also,
>once I get it passed, I want to pass it from
I tried reading the perldoc, but it came up all screwy
on my screen. Lines ran over the end. I'm having
trouble passing variables into a subroutine.Also,
once I get it passed, I want to pass it from there
back to the main function. Can someone help me figure
this out? This is the code that
Stuart White wrote:
>
> Hello all,
Hello,
> I seem to be stuck on subroutines. I've read the Perl
> for Beginners Wrox chapter on them, and I'm still a
> bit lost.
The first thing that you should read is the documentation supplied with
Perl. The document describing subroutines is perlsub.pod.
On Wed, Jul 16, 2003 at 07:50:56AM -0700, Stuart White wrote:
> I seem to be stuck on subroutines.
Okay, let's have a look;
> #
> # Subroutine prototypes
>
>
> sub FoulParser($);
>
> #
> # Main Program
On Wed, 3 Oct 2001, Pascal wrote:
> as you could see, i'm a beginner
> how is it possible to write sub routines in a perl file and to call them
> from an other one
> thanks
You'll want to study how to create modules in Perl (described quite well
in the Camel Book). If you don't have any books t
create them in format of filename.pm and place in the
perl/site/lib/filename.pm Depending on what is happening, you can have a subfolder
by the name of the called subroutine, etc. Others can provide more specifics, but
should give a starting place.
Wags ;)
-Original Message
PM
To: Morse, Loretta; '[EMAIL PROTECTED]'
Cc: [EMAIL PROTECTED]
Subject: Re: subroutines in .pm
--- "Morse, Loretta" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Does anybody know how to call a subroutine that is in a .pm file from
> another .pm file.
Given A.pm
--- "Morse, Loretta" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Does anybody know how to call a subroutine that is in a .pm file from
> another .pm file.
Given A.pm
===
package A;
sub a { return "a!\n"; }
1;
===
and B.pm
===
package B;
use A;
sub b { print A::a(); }
1;
===
Try throwing this into file2.pm:
sub AUTOLOAD {
print "What hath god wrought?\n"
}
And then call:
file2->any_function_name;
That is if you have a:
use file2;
AUTOLOAD is a catch all function, method really, but this should work
considering how Perl blurs the line b
Morse, Loretta ([EMAIL PROTECTED]) wrote:
> Thanks for the suggestions however I think I need to clarify
> what I'm trying to do.
>
> I am using a WinNT system and I'm running a script that calls
> a subroutine in file1.pm. Then file1.pm calls a subroutine
> from file2.pm. The script can't seem
seem to find the subroutine
> that in is in file2.pm.
>
> Neither suggestion has worked so far, any other ideas out there?
>
> Thanks.
>
> -Original Message-
> From: Michael Lamertz [mailto:[EMAIL PROTECTED]]
> Sent: Friday, April 27, 2001 4:06 PM
> To: M
: I am using a WinNT system and I'm running a script that calls
: a subroutine in file1.pm. Then file1.pm calls a subroutine
: from file2.pm. The script can't seem to find the subroutine
: that in is in file2.pm.
Does your file1.pm have "use file2" in it?
-- tdk
is in file2.pm.
Neither suggestion has worked so far, any other ideas out there?
Thanks.
-Original Message-
From: Michael Lamertz [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 27, 2001 4:06 PM
To: Morse, Loretta
Cc: '[EMAIL PROTECTED]'
Subject: Re: subroutines in .pm
Morse, Loretta
Morse, Loretta ([EMAIL PROTECTED]) wrote:
>
> Hello,
>
> Does anybody know how to call a subroutine that is in a .pm file from
> another .pm file.
That depends:
First you have to load the file via 'require' or 'use' - perldoc them.
If your other .pm creates its own namespace, you need to addre
>Does anybody know how to call a subroutine that is in a .pm file from
>another .pm file.
Welp, if &subroutine_1 is in Library1.pm,
then within Library2.pm, you could do something like:
sub subroutine_2 {
require "/path/to/Library1.pm";
&subroutine_1;
}
Morbus Iff
.sig on other
34 matches
Mail list logo