On 16/10/2011 00:08, JPH wrote:
I am passin a two-dimensional array to a sub and when the sub returns,
the original array has changed. Eventually I want to pass the array into
a recursive sub, so I want to find a way to circumvent this behaviour.
Notice how my global is "@a" and the sub local is
On 16/10/2011 23:18, Rob Dixon wrote:
On 16/10/2011 19:10, JPH wrote:
Every pass I only change a single character, then I run some tests and
so on.
I wonder if it is possible to write your subroutine by using a single
global array and remembering the change so that you can undo it before
the
On 16/10/2011 19:10, JPH wrote:
On 10/16/2011 04:05 AM, Shawn H Corey wrote:
On 11-10-15 07:44 PM, Rob Dixon wrote:
sub try {
my @b;
foreach my $row (@_) {
push @b, [@$row];
}
:
}
Or you could use dclone() from Storable:
use Storable qw( dclone );
sub try {
my @b = @{ dclone( \@_ ) };
..
Thanks! My script seems to work with dclone.
Though the (deep) recursion takes a lot of time ...
What is your opinion, would it pay off (in performance) when I rewrite the
script in such a way that I do not use dclone, but string manipulation routines
instead? So:
- passing a single dimension
You got me there, John. Indeed I do expect it to contain ' ' and not 0 like I
stated.
If you originally assign " " to $a[ 0 ][ 1 ] why would you now expect it to
contain 0?
John
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.
JPH wrote:
Hi all,
Hello,
I am passin a two-dimensional array to a sub and when the sub returns,
the original array has changed. Eventually I want to pass the array into
a recursive sub, so I want to find a way to circumvent this behaviour.
Notice how my global is "@a" and the sub local is "
On 11-10-15 07:44 PM, Rob Dixon wrote:
sub try {
my @b;
foreach my $row (@_) {
push @b, [@$row];
}
:
}
Or you could use dclone() from Storable:
use Storable qw( dclone );
sub try {
my @b = @{ dclone( \@_ ) };
...
}
Storable is a standard modul
On 16/10/2011 00:08, JPH wrote:
Hi all,
I am passin a two-dimensional array to a sub and when the sub returns,
the original array has changed. Eventually I want to pass the array into
a recursive sub, so I want to find a way to circumvent this behaviour.
Notice how my global is "@a" and the sub
On Sun, Oct 16, 2011 at 01:08:19AM +0200, JPH wrote:
> Hi all,
>
> I am passin a two-dimensional array to a sub and when the sub
This is your main problem. Perl doesn't have two-dimensional arrays. What it
does have is arrays of array references which, if you squint, can be used as
two-dimensio
Hi all,
I am passin a two-dimensional array to a sub and when the sub returns, the original array has changed. Eventually I want to pass the array into a recursive sub, so I want to find a way to circumvent
this behaviour. Notice how my global is "@a" and the sub local is "@b"
- Why is this hap
On 11-09-14 11:18 PM, Brandon McCaig wrote:
Personally I agree that it's very sloppy to write without capitals.
I find it sloppy for people whose first language is English not to do
their best. Many readers of this list do not have English as a their
first language and the best way to improv
> "BM" == Brandon McCaig writes:
BM> [1] I personally find it very petty when Uri mentions his work as a
BM> Perl "recruitment agent" (for lack of a better description right now)
BM> and implies that he'll never consider you as a potential candidate
BM> with regards to that because of
On Wed, Sep 14, 2011 at 8:57 PM, Uri Guttman wrote:
> it was topical as your (self admitted) blowup happened here. and it
> caused a small ruckus until you calmed down.
I'd say you're both out to lunch on this. I don't even recall this
subject so if I even read the affected threads then I obvious
> "RD" == Rob Dixon writes:
RD> On 14/09/2011 21:30, Uri Guttman wrote:
>>
>>> Uri we are all privileged with your thoughts on variable naming. My last
>>> attempt to say that perhaps you weren't always right wrong resulted in a
>>> personal attack saying "you had that blowup a few
On 14/09/2011 21:30, Uri Guttman wrote:
Uri we are all privileged with your thoughts on variable naming. My last
attempt to say that perhaps you weren't always right wrong resulted in a
personal attack saying "you had that blowup a few months ago. are you
doing that again?" Given that you choos
On 9/14/11 Wed Sep 14, 2011 5:04 AM, "William"
scribbled:
> On Sep 14, 5:39 am, chrisstinem...@gmail.com (Chris Stinemetz) wrote:
...For more information see:
>>
>>> #!/usr/local/bin/perl
>>> use strict;
>>> $a = 1;
>>> $b = 2;
>>> print qq($a, $b\n);
>
On Sep 14, 5:39 am, chrisstinem...@gmail.com (Chris Stinemetz) wrote:
> >> ...For more information see:
>
> >>http://perl.plover.com/FAQs/Namespaces.html
>
> > Useful article.
>
> > Now can you explain why I get no error with this little routine? -
>
> > #!/usr/local/bin/perl
> > use
> "RD" == Rob Dixon writes:
RD> On 14/09/2011 16:51, Uri Guttman wrote:
>>> "PJ" == Paul Johnson writes:
>>
PJ> On Tue, Sep 13, 2011 at 11:34:34PM -0400, Uri Guttman wrote:
>> >> here is another good reason to stay aways from single letter var
>> >> names. they are hard to
On 14/09/2011 16:51, Uri Guttman wrote:
"PJ" == Paul Johnson writes:
PJ> On Tue, Sep 13, 2011 at 11:34:34PM -0400, Uri Guttman wrote:
>> here is another good reason to stay aways from single letter var
>> names. they are hard to search for as other vars which start with those
>>
On 11-09-14 11:51 AM, Uri Guttman wrote:
show me a tool that can search for single letter names cleanly and with
little effort as compared to longer names. also this isn't the only
reason, just one of several.
ViM. Put the cursor on the variable and press *
Also: press # to search backward.
> "PJ" == Paul Johnson writes:
PJ> On Tue, Sep 13, 2011 at 11:34:34PM -0400, Uri Guttman wrote:
>> here is another good reason to stay aways from single letter var
>> names. they are hard to search for as other vars which start with those
>> letters will also be found.
PJ> This may
On Tue, Sep 13, 2011 at 11:34:34PM -0400, Uri Guttman wrote:
> here is another good reason to stay aways from single letter var
> names. they are hard to search for as other vars which start with those
> letters will also be found.
This may be the worst argument I have ever heard against using si
On 9月13日, 下午8时33分, shlo...@shlomifish.org (Shlomi Fish) wrote:
> Hello William,
>
> On Mon, 12 Sep 2011 20:05:38 -0700 (PDT)
>
> William wrote:
> > My Code:
> > use strict ;
> > use warnings ;
>
> > chomp($input = ) ;
>
> > I compile this but has a error. say:Globla symbol "@input" requires
> > ex
> "JD" == John Delacour writes:
JD> At 16:39 -0500 13/09/2011, Chris Stinemetz wrote:
>>> From Learning Perl book:
>>
>> In some circumstances, $a and $b won't need to be declared, because
>> they're used internally by sort. So if you're testing this feature,
>> use other variabl
At 16:39 -0500 13/09/2011, Chris Stinemetz wrote:
From Learning Perl book:
In some circumstances, $a and $b won't need to be declared, because
they're used internally by sort. So if you're testing this feature,
use other variable names than those two. The fact that use strict
doesn't forbid the
>
>> ...For more information see:
>>
>> http://perl.plover.com/FAQs/Namespaces.html
>
> Useful article.
>
> Now can you explain why I get no error with this little routine? -
>
> #!/usr/local/bin/perl
> use strict;
> $a = 1;
> $b = 2;
> print qq($a, $b\n);
>
>Fro
At 15:33 +0300 13/09/2011, Shlomi Fish wrote:
...For more information see:
http://perl.plover.com/FAQs/Namespaces.html
Useful article.
Now can you explain why I get no error with this little routine? -
#!/usr/local/bin/perl
use strict;
$a = 1;
$b = 2;
Hello William,
On Mon, 12 Sep 2011 20:05:38 -0700 (PDT)
William wrote:
> My Code:
> use strict ;
> use warnings ;
>
> chomp($input = ) ;
>
> I compile this but has a error. say:Globla symbol "@input" requires
> explicit package name at...
Well, you didn't copy-and-paste the error correctly, b
My Code:
use strict ;
use warnings ;
chomp($input = ) ;
I compile this but has a error. say:Globla symbol "@input" requires
explicit package name at...
What should i do?
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://le
I am using perlcc to compile perl script
On Thu, Nov 20, 2008 at 8:25 PM, Chas. Owens <[EMAIL PROTECTED]> wrote:
> On Thu, Nov 20, 2008 at 00:05, ashish nainwal <[EMAIL PROTECTED]>
> wrote:
> > Thanks for the info. I will be using my perl script for AIX but I am not
> > able to find a supporting
On Fri, Nov 21, 2008 at 01:55, ashish nainwal <[EMAIL PROTECTED]> wrote:
> I am using perlcc to compile perl script
Yeah, that is a bad idea.
from http://search.cpan.org/~nwclark/perl-5.8.8/utils/perlcc.PL:
The code generated in this way is not guaranteed to work. The whole
codegen suite (perlcc
On Thu, Nov 20, 2008 at 00:05, ashish nainwal <[EMAIL PROTECTED]> wrote:
> do u have any such doc..please provide it to me!
>
> On Thu, Nov 20, 2008 at 10:35 AM, ashish nainwal
> <[EMAIL PROTECTED]>wrote:
>
>> Thanks for the info. I will be using my perl script for AIX but I am not
>> able to find
On Thu, Nov 20, 2008 at 00:05, ashish nainwal <[EMAIL PROTECTED]> wrote:
> Thanks for the info. I will be using my perl script for AIX but I am not
> able to find a supporting IBM official doc which says that AIX comes with
> perl by default.
snip
What are you using to create the binary? PAR::Pack
Thanks for the info. I will be using my perl script for AIX but I am not
able to find a supporting IBM official doc which says that AIX comes with
perl by default.
On Thu, Nov 20, 2008 at 10:32 AM, Mr. Shawn H. Corey
<[EMAIL PROTECTED]>wrote:
> On Thu, 2008-11-20 at 10:23 +0530, ashish nainwal wr
do u have any such doc..please provide it to me!
On Thu, Nov 20, 2008 at 10:35 AM, ashish nainwal
<[EMAIL PROTECTED]>wrote:
> Thanks for the info. I will be using my perl script for AIX but I am not
> able to find a supporting IBM official doc which says that AIX comes with
> perl by default.
>
>
I want to compile a perl script because I want to run it on systems which
dont have perl installed.
Does creating an executable solve this purpose? If yes, then how can I do
that?
On Wed, Nov 19, 2008 at 10:38 PM, Mr. Shawn H. Corey
<[EMAIL PROTECTED]>wrote:
> On Wed, 2008-11-19 at 04:03 -0800, a
On Thu, 2008-11-20 at 10:23 +0530, ashish nainwal wrote:
> I want to compile a perl script because I want to run it on systems
> which
> dont have perl installed.
> Does creating an executable solve this purpose? If yes, then how can I
> do
> that?
All versions of Linux, BSD and UNIX come with Per
On Wed, 2008-11-19 at 04:03 -0800, ashish wrote:
> Can someone please tell me how to compile a perl script which is
> calling global variables and then how should the executable be used?
>
There is no need to compile a Perl script. To run it, call it with
perl:
perl ftp.pl
Or you can make it
t;$loc")) { print "Changed to the directory $loc without
any trouble \n"; } else { print "Could not change to $loc directory
\n"; }
if ($ftp->put("/home/ashish/perl/touch.tst","$ftploc/touch.test"))
{print "file transferred properly \n"; }
Dr.Ruud wrote:
"Mr. Shawn H. Corey" schreef:
2) Perl does not have true constants. When you `use constant` you
actually create a sub that returns a value. This:
use constant VAR => "someval";
is the same as:
sub VAR {
return "someval";
}
Perl has true constants.
"use constant" isn't t
"Mr. Shawn H. Corey" schreef:
> 2) Perl does not have true constants. When you `use constant` you
> actually create a sub that returns a value. This:
>
> use constant VAR => "someval";
>
> is the same as:
>
> sub VAR {
> return "someval";
> }
Perl has true constants.
"use constant" isn't
> -Original Message-
> From: Rob Dixon [mailto:[EMAIL PROTECTED]
> Sent: 31 October 2008 11:51
> To: Perl Beginners
> Cc: Stewart Anderson
> Subject: Re: How to put a global variable in a package, accessible to
> users of that package?
>
> Stewart Anderson wro
Stewart Anderson wrote:
>> From: mrstevegross [mailto:[EMAIL PROTECTED]
>>
>> I have a package named "Foo" in which I want to define some package-
>> level constants (such as $VAR="soemval"). I want those constants
>> available to users of package Foo, so the following code would work:
>>
>> === fo
> -Original Message-
> From: Jeff Pang [mailto:[EMAIL PROTECTED]
> Sent: 31 October 2008 09:38
> To: Perl Beginners [Beginners Perl]
> Subject: RE: How to put a global variable in a package, accessible to
> users of that package?
>
>
> > Message du 31
> Message du 31/10/08 10:25
> De : "Stewart Anderson"
> A : "mrstevegross" , beginners@perl.org
> > === foo.pl ===
> > package foo;
> > use constant VAR => "someval";
> >
> > === bar.pl ===
> > use foo;
> > print $foo::VAR;
> >
> > It doesn't appear to be working; it compiles ok, but it prints
>
> From: mrstevegross [mailto:[EMAIL PROTECTED]
> Sent: 30 October 2008 18:43
> To: beginners@perl.org
> Subject: How to put a global variable in a package, accessible to
users of
> that package?
>
> I have a package named "Foo" in which I want to define some pack
On Thu, 2008-10-30 at 23:43 +, Rob Dixon wrote:
> mrstevegross wrote:
> >
> > I have a package named "Foo" in which I want to define some package-
> > level constants (such as $VAR="soemval"). I want those constants
> > available to users of package Foo, so the following code would work:
> >
>
mrstevegross wrote:
>
> I have a package named "Foo" in which I want to define some package-
> level constants (such as $VAR="soemval"). I want those constants
> available to users of package Foo, so the following code would work:
>
> === foo.pl ===
> package foo;
> use constant VAR => "someval";
I have a package named "Foo" in which I want to define some package-
level constants (such as $VAR="soemval"). I want those constants
available to users of package Foo, so the following code would work:
=== foo.pl ===
package foo;
use constant VAR => "someval";
=== bar.pl ===
use foo;
print $foo:
Hello Ray,
Thanks for your response. I could already solve the problem. It was caused by
a syntax error in a different line within the same sub.:-) I read my source
code over and over and finally find the error.
Best Regards,
Oliver Block
Am Donnerstag, 11. September 2008 16:30:49 schrieb Ra
Oliver Block wrote:
hello everybody,
Hello,
what may cause perl to give the following command line output
Global symbol "$form" requires explicit package name at /.../Address.pm line
44.
even if the variable $form is declared in line 16 as follows
my $form = $self->formbuilder;
Hi Oliver,
You have to show more of the source code -- but it sounds like you've
declared $form with "my" within a function/subroutine and it is not
visible outside the function? Could that be the problem?
Ray
Oliver Block wrote:
hello everybody,
what may cause perl to give the followin
hello everybody,
what may cause perl to give the following command line output
Global symbol "$form" requires explicit package name at /.../Address.pm line
44.
even if the variable $form is declared in line 16 as follows
my $form = $self->formbuilder;
within a sub of a class definit
2007/10/10, dinesh <[EMAIL PROTECTED]>:
>
> Issue here is: The global associative array is not getting updated in
> the child process. Please suggest me how to do this.
childs and parent are separte,things changed on each process can't
affect another.
Say you have @global in parent,after forking,
dinesh wrote:
Hi,
Hello,
Subject: How to update value of global variable from child process (fork)
The child and parent are separate processes so you have to use some type of
InterProcess Communication to update values between them.
perldoc perlipc
John
--
Perl isn't a toolbox,
Hi,
We need to run test in multiple test cycles and in each test cycle
multiple operations need to be performed. Currently one test cycle is
taking 10 seconds and we need to reduce the time to 4 seconds. I have
used fork() to do this as follows (only one operation is given here).
I will update the
On 01/22/2007 04:17 PM, tom tom wrote:
Can I know how to pass parameters from the CRON job
e.g
cleanup folder and delta time in seconds and
thereafter retreive that from the perl.
My cleanup rountine currently hardcoded with these
values
[...]
Why not just make it a regular, non-CGI, Perl sc
ome/lalitha/mod_cas/sessions',delta=>120, verbose
=> 0) -> expire_file_sessions();
--- "Mumia W." <[EMAIL PROTECTED]>
wrote:
> On 01/21/2007 04:55 PM, tom tom wrote:
> > Hi,
> >
> > In my mod_perl (Authentication module). I have
On 01/21/2007 04:55 PM, tom tom wrote:
Hi,
In my mod_perl (Authentication module). I have global
variable defined as follows
use vars qw( $SESSION_CLEANUP_COUNTER);
$SESSION_CLEANUP_COUNTER=0;
my intention is to count no of times it is getting
executed by clients (no of hits). I am
Hi,
In my mod_perl (Authentication module). I have global
variable defined as follows
use vars qw( $SESSION_CLEANUP_COUNTER);
$SESSION_CLEANUP_COUNTER=0;
my intention is to count no of times it is getting
executed by clients (no of hits). I am incrementing it
within Authenticate method as
> From: John W. Krahn wrote:
> Jason Corbett wrote:
> >
> > Hello. I am using variables that are local in my scripts by doing the my
> > $variable_name technique.
> >
> > Can someone tell me if there is an official way to define a global variable?
&
Jason Corbett wrote:
>
> Hello. I am using variables that are local in my scripts by doing the my
> $variable_name technique.
>
> Can someone tell me if there is an official way to define a global variable?
Perl doesn't really have "global" variables (like BASIC
Jason Corbett wrote:
Can someone tell me if there is an official way to define a global
variable?
use vars qw($global1 $global2);
or
our ($global1, $global2);
The latter cannot be used in Perl versions previous than 5.6.0. Note
that the two methods do not do exactly the same thing; see
Hello. I am using variables that are local in my scripts by doing the my
$variable_name technique.
Can someone tell me if there is an official way to define a global variable?
iFiles;
$main::CFG = new Config::IniFiles( -file => "/path/configfile.ini" );
...
Uppercasing a global variable is a good idea to indicate that it is global.
Now, if you want to access this variable from a module (that is, another
namespace/package), all you have to know is in whi
Hi,
i have a script with my modules.
i.e
#!/usr/bin/perl
use strict;
use warnings;
use Config::IniFiles;
my $cfg = new Config::IniFiles( -file => "/path/configfile.ini" );
use lib '/path/tomy/Module';
use MyModule;
use TestModule;
now i would like $cfg to be global , so that all module can use th
On Wed, Dec 12, 2001 at 05:42:11PM +0100, Jorge Goncalvez wrote:
> Hi I have this code:
> ...
> sub MakeEth()
> {
> unless ($_Globals{NICIP_ADRESS}==$IPREAL[0])
> {
> $_Globals{ETH_NETIF} eq "eth0";
You must have meant "=", not "eq", as in:
$_Globals{ETH_NETIF}
Hi I have this code:
...
sub MakeEth()
{
unless ($_Globals{NICIP_ADRESS}==$IPREAL[0])
{
$_Globals{ETH_NETIF} eq "eth0";
}
else{
$_Globals{ETH_NETIF} eq "eth0:1";
}
}
...
sub StartDhcp()
{
my $_cmd = $_Os{$_Globa
Kailash wrote:
[snip]
Start each of your scripts with the following, it will
save you many hours of debugging:
#!/usr/bin/perl -w
use strict;
> $input = ;
Declaring your variables with 'my' will help you keep
track of their scope:
my $input = ;
> # I process the input here
> # If the output
the variables, which
are declared earlier (outside the sub routine), it is not working, obviously.
Is there a way to declare a global variable so that I can refer to that variable
inside a if loop or a sub-routine. I am sure there is a way.
snippet of the code
$input = ;
# I process the input
70 matches
Mail list logo