On Wed, Nov 30, 2011 at 10:21:19AM -0500, Brandon McCaig wrote:
> You can use subroutines to split functionality into multiple
> pieces and store them each in a different file.
Oops. xD That sounds like I suggest for you to use a different
file for every subroutine. Of course I meant that you shou
On Tue, Nov 29, 2011 at 06:19:59PM -0500, Nemana, Satya wrote:
> Hi Brandon, Igor, Shawn
Hello (not sure if it's proper to call you Nemana or Satya or if
both names are necessary):
> The horror was that the perl compiler pointed at a code some
> 1000s of lines below this line for the error which
On Tue, 29 Nov 2011 18:19:59 -0500, Nemana, Satya wrote:
> P.S : unfortunately, I cant provide more details due to the IP
> restrictions, sorry about that, hope you understand, otherwise would
> have posted the code in the first go.
This is a common constraint. You can always post a version of th
tions, sorry about that, hope you understand, otherwise would
have posted the code in the first go.
-Original Message-
From: Brandon McCaig [mailto:bamcc...@gmail.com]
Sent: 29 November 2011 15:15
To: Nemana, Satya
Cc: beginners@perl.org
Subject: Re: passing arguments to perl function with
On Tue, Nov 29, 2011 at 08:12:29AM -0500, Nemana, Satya wrote:
> Hi
Hello:
> I need to pass argument to a function like this -chan_range =>
> "$chs-$che"
>
> Normally when this used which works -chan_range => "1-24"
>
> However, when I try to put variable values instead of a scalar string, I
On 11-11-29 08:12 AM, Nemana, Satya wrote:
However, when I try to put variable values instead of a scalar string, I
get compilation errors (the errors are in different part of the code
which is completely clueless)
Could you post the code that fails and its error message?
--
Just my 0.000
Hi Satya,
Might I suggest to look up a bit into the function's source code?
Because it's, well, pretty normal to call subs like that:
...
some_func_call(-chan_range => "$beg-$end")
...
Of course, $beg and $end variables should be defined already (and contain
numeric values, as I see).
If not, war
Hi
Sorry for the silly question, but thought someone might help here.(tried
googling but this may too silly a beginners question for anyone to have
answered previously)
I need to pass argument to a function like this -chan_range =>
"$chs-$che"
Normally when this used which works -chan_range
HACKER Nora wrote:
If you do:
my ($var1) = @_;
You're doing list assignment and, as a result, you assign $var1 to the
$_[0]
and don't make use of $_[1], $_[2], $_[3], etc., which may or may not
exist.
Thanks, perfectly clear now.
In 'perldoc perlsub' I read that I only have to use
parenthe
Hi Shlomi,
> Because the lack of parenthesis signifies that the right-hand-side
will
> be
> done in scalar context. As a result it is equivalent to:
>
> my $var1 = scalar(@_);
>
> Which is the length of the @_ array (which sometimes have some valid
> uses if
> you're checking for optional argum
Hi Nora,
On Friday 30 Apr 2010 09:55:33 HACKER Nora wrote:
> Hi,
>
> For calling subroutines and passing arguments on I use e.g.
>
> my ( $var1, $var2 ) = @_;
>
> If I have only one argument, this is also ok:
>
> my ( $var1) = @_;
>
> But why does
>
>
Hi,
For calling subroutines and passing arguments on I use e.g.
my ( $var1, $var2 ) = @_;
If I have only one argument, this is also ok:
my ( $var1) = @_;
But why does
my $var1 = @_;
not work? In 'perldoc perlsub' I read that I only have to use
parentheses when defining mor
On 6/5/07, Brad Baxter <[EMAIL PROTECTED]> wrote:
snip
Apparently, unlike with named subs, both &$anon()
and $anon->() ignore prototypes. However, like named
subs &$anon gets the caller's @_. But that is almost
never mentioned afaict at the places in the docs where
the &$anon style call is used
On Jun 1, 9:58 am, [EMAIL PROTECTED] (Chas Owens) wrote:
> On 31 May 2007 10:58:54 -0700, Paul Lalli <[EMAIL PROTECTED]> wrote:
>
> > On May 31, 10:15 am, [EMAIL PROTECTED] (Yitzle) wrote:
> > > I suspect one of the tutorials that Google or Perl.org points to has
> > > something in it that needs co
On Jun 2, 9:18 am, [EMAIL PROTECTED] (Steve Bertrand) wrote:
> > testsub(35);
>
> You call the sub with one parameter, integer 35. However, this won't
> work as calling the sub before the sub is defined with a prototype will
> barf with an error.
No it won't. It will print a warning, if and only
On 6/2/07, Alma <[EMAIL PROTECTED]> wrote:
Hi,
I need to pass id as parameters to a subroutine
testsub(35);
sub testsub($)
{
my $self = shift;
my $id = @_;
print "$id";
}
Its printing 3 . am i going wrong in prototype .
First off, don't use prototypes until you know exactly what
> testsub(35);
You call the sub with one parameter, integer 35. However, this won't
work as calling the sub before the sub is defined with a prototype will
barf with an error. Let's assume had the sub call beneath the definition
from the start.
> sub testsub($)
Above, your prototype says testsub
On Jun 2, 3:54 am, [EMAIL PROTECTED] (Alma) wrote:
> Hi,
>
> I need to pass id as parameters to a subroutine
>
> testsub(35);
>
> sub testsub($)
>{
>my $self = shift;
>my $id = @_;
>print "$id";
>
> }
>
> Its printing 3
That's just a lie. Why are you lying to us? Why are you not
Hi,
I need to pass id as parameters to a subroutine
testsub(35);
sub testsub($)
{
my $self = shift;
my $id = @_;
print "$id";
}
Its printing 3 . am i going wrong in prototype .
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://
On 31 May 2007 10:58:54 -0700, Paul Lalli <[EMAIL PROTECTED]> wrote:
On May 31, 10:15 am, [EMAIL PROTECTED] (Yitzle) wrote:
> I suspect one of the tutorials that Google or Perl.org points to has
> something in it that needs correcting.
Actually, it's an unfortunate truth that up until Edition 3,
Paul Lalli wrote:
On May 31, 9:35 am, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote:
On May 31, 9:27 am, [EMAIL PROTECTED] (Alma) wrote:
# extract the file name
# my @parts = split('\/',$file_path);
Your split statement seems to be wrong. split uses a regex to match so
it should be:
s
On May 31, 9:35 am, [EMAIL PROTECTED] ([EMAIL PROTECTED])
wrote:
> On May 31, 9:27 am, [EMAIL PROTECTED] (Alma) wrote:
>
> > # extract the file name
> > # my @parts = split('\/',$file_path);
> Your split statement seems to be wrong. split uses a regex to match so
> it should be:
>
> split /\
On May 31, 9:27 am, [EMAIL PROTECTED] (Alma) wrote:
> Hi All,
>
> I need to pass the result of prepare statement as an argument to the
> subroutine.
>
> sub abc()
> {
> my $self= shift;
> my($id,$title) = @_;
> my $sth1= $databasehandle->prepare("select file_path from xyz
>
On May 31, 9:27 am, [EMAIL PROTECTED] (Alma) wrote:
> sub delete_file()
> {
> my $self = shift;
> my $file_path = @_;
That sets $file_path to the number of arguments in the call to the
method delete_file().
To set $file_path to the first of the arguments in the call to the
method
On May 31, 10:15 am, [EMAIL PROTECTED] (Yitzle) wrote:
> I suspect one of the tutorials that Google or Perl.org points to has
> something in it that needs correcting.
Actually, it's an unfortunate truth that up until Edition 3, the Llama
itself recommended that you use the & to call subroutines...
On 5/31/07, yitzle <[EMAIL PROTECTED]> wrote:
snip
I suspect one of the tutorials that Google or Perl.org points to has
something in it that needs correcting.
snip
Probably more than one thing. I would suggest reading the following
books to learn Perl and to only use random tutorials on the In
On 31 May 2007 01:27:26 -0700, Alma <[EMAIL PROTECTED]> wrote:
-- snip --
unlink($file_path);
-- snip --
I'm aware that the question was already answered, but a generic tip
for the future.
You could try adding a statement like:
print "Deleting $file_path\n";
to help debug and ensure t
On 31 May 2007 01:27:26 -0700, Alma <[EMAIL PROTECTED]> wrote:
snip
&deleteposter_file(@row);
snip
sub delete_file()
snip
This would seem to be the problem, also where did you learn that you
should put & on the front of your subroutine calls? I am curious
because I keep seeing people
On May 31, 4:27 am, [EMAIL PROTECTED] (Alma) wrote:
> I need to pass the result of prepare statement as an argument to the
> subroutine.
>
> sub abc()
The () there very specifically say "This subroutine takes no
arguments".
> {
> my $self= shift;
> my($id,$title) = @_;
... and y
Alma wrote:
Hi All,
I need to pass the result of prepare statement as an argument to the
subroutine.
-snip-
abc is calling delete_file() . where it need to delete the file stored
at the location mentioned in file_path.
Its not giving me an error but its not deleting the files from the
locatio
Hi All,
I need to pass the result of prepare statement as an argument to the
subroutine.
sub abc()
{
my $self= shift;
my($id,$title) = @_;
my $sth1= $databasehandle->prepare("select file_path from xyz
where id='$id' and title like '$title'");
my $res = $sth1->exec
lohit [l], on Monday, July 4, 2005 at 13:21 (+0530) contributed this
to our collective wisdom:
l> lets assume I call the function as show below
l> func("arg1","arg2","this is arg 3", "this is arg 4");
l> now inside func function how do I retrieve my arguments
l> sub func()
l> {
l> foreach $arg
lohit am Montag, 4. Juli 2005 09.51:
> lets assume I call the function as show below
> func("arg1","arg2","this is arg 3", "this is arg 4");
> now inside func function how do I retrieve my arguments
> sub func()
> {
> foreach $arg in (@ARGV) {
> print "$arg\n";
> }
> }
> this would print
> arg1
lets assume I call the function as show below
func("arg1","arg2","this is arg 3", "this is arg 4");
now inside func function how do I retrieve my arguments
sub func()
{
foreach $arg in (@ARGV) {
print "$arg\n";
}
}
this would print
arg1
arg2
this
is
arg3
this
is
arg4
On 7/4/05, John Doe <[E
lohit am Montag, 4. Juli 2005 09.17:
> Hi there,
> how do i pass arguments with spaces in it.
> exaple if i pass fun("abc is not bcd");
indicates that you pass the string to a _subroutine_
> @ARGV
is normally used to get arguments to the _script_
> would store this as 4 words. how do i retrie
Hi there,
how do i pass arguments with spaces in it.
exaple if i pass fun("abc is not bcd");
@ARGV would store this as 4 words. how do i retrieve it as $var = "abc is
not bcd";
thanks!!
OTECTED]
Sent: Monday, January 19, 2004 8:15 PM
To: [EMAIL PROTECTED]
Subject: passing arguments to functions
Hi all
Problem:
I want to send 2 arguments to a subroutine in the form of arrays and want to
use their result which is also in the form of an array.
Explanation:
suppose i have 2
Hi all
Problem:
I want to send 2 arguments to a subroutine in the form of arrays and want to use their
result which is also in the form of an array.
Explanation:
suppose i have 2 arrays
@a=`/bin/cat /some/file` ; # A file that has a list of users
@b=`/bin/cat /another/file` ; # Another
you could do something like
open SCRIPT, "| /path/to/script" || die("$!");
select(SCRIPT);
$|=1;
print "argument\n";
select(STDOUT);
close(SCRIPT);
perldoc perlipc
--
___
Get your free email from http://www.hackermail.com
Powered by Outblaze
--
To u
Hello All,
I have a very basic question. I need to launch a Bourne shell script using
PERL and automate the responses required by the script. I have shown the
sample shell script below:
#!/bin/sh
echo "Welcome to my script"
echo "Do you want to continue"
read ans
if [ $ans = "n" ] then
exit
Le Blanc wrote:
> I made some changes. Now I get an error message.
>
> The message says "Can't use string ("") as an ARRAY ref while "strict
> refs" in use"
>
> Here is the code as it stands now, with changes.
>
> #!/usr/bin/perl -w
> use strict;
> use Data::Dumper;
> use diagnostics -verbose;
>
>
I made some changes. Now I get an error message.
The message says "Can't use string ("") as an ARRAY ref while "strict refs" in use"
Here is the code as it stands now, with changes.
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use diagnostics -verbose;
print "Enter the Part Number you w
[EMAIL PROTECTED] wrote:
>> open (FH, './fai.txt') || die "Cannot open file: ($!)";
>> my @parts = ;
>> my @rev = ;
>
> This stores two copies of the file in memory, do you need two copies?
>
It doesn't actually. The first assignment leaves you at end-of-file so
subsequent reads fail. @parts wi
See inline.
On Fri, 17 Jan 2003 11:01:58 -0500, "Le Blanc, Kerry (Kerry)" <[EMAIL PROTECTED]>
wrote:
> I think I am getting close. With much help I have been able to tweek my original
>code down quite a bit. For the most part, everything is worki
I think I am getting close. With much help I have been able to tweek my original code
down quite a bit. For the most part, everything is working as it should. What is
stumping me right now is, how do I make sure that both the part number and the rev
match before printing out the record. The part
On Thursday, April 11, 2002, at 01:53 , Mike wrote:
> If a program calls a perl script as follows: /tmp/perltest.pl abc def ghi
> jkl mno
>
> Is there a variable which would contain the arguments?
yes @ARGV - in your case you would be able to play something like
my $count=1;
f
@ARGV
in your example
$ARGV[0] will be abc
$ARGV[1] will be def
...etc
Tor.
Mike wrote:
>
> If a program calls a perl script as follows: /tmp/perltest.pl abc def ghi
> jkl mno
>
> Is there a variable which would contain the arguments?
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> F
@ARGV is the variable ur looking for ;
here is how to assign args to vars;
while(@ARGV)
{
$var1=shift(@ARGV);
$var2=shift(@ARGV);
}
Adios
Mandar
On Thu, 11 Apr 2002, Mike wrote:
> If a program calls a perl script as follows: /tmp/perltest.pl abc def ghi
> jkl mno
>
> Is there a va
If a program calls a perl script as follows: /tmp/perltest.pl abc def ghi
jkl mno
Is there a variable which would contain the arguments?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--- "P. Schaub" <[EMAIL PROTECTED]> wrote:
> I am calling a perl script within another perl script.
Have you looked into require() and do()?
> What is the best way to pass arguments to the second one ?
Depends on what you want, what it does, and how it's written.
> Is it possible to pass arra
On 10 Jul 2001 20:24:45 +0200, P. Schaub wrote:
> Hi List,
>
> I am calling a perl script within another perl script.
> What is the best way to pass arguments to the second one ?
> Is it possible to pass arrays and hashs (or at least refs) ?
> So far I am calling the second script like
> @result=
Hi List,
I am calling a perl script within another perl script.
What is the best way to pass arguments to the second one ?
Is it possible to pass arrays and hashs (or at least refs) ?
So far I am calling the second script like
@result=`script2.pl $arg1 $arg2 $arg3`
but I guess this is quite ugly.
Hi,
How to pass arguments to a (method=post) CGI script and how to access them? Please
give an example.
Thanks in advance.
53 matches
Mail list logo