From: christoph.kie...@snb.ch
> What is the precise difference between the two ways of generating an
> inside-out-object?
>
> 1/
> my $node = bless \do { my $anonymous }, ref($class) || $class;
>
>
> 2/
> my $a;
> my $node = bless \$a, ref($class) || $class;
>
> In other words, why is it sugge
On Wed, Dec 10, 2008 at 07:55, Christoph Kiefer
<[EMAIL PROTECTED]> wrote:
> Dear all
>
> What is the precise difference between the two ways of generating an
> inside-out-object?
>
> 1/
> my $node = bless \do { my $anonymous }, ref($class) || $class;
>
> 2/
> my $a;
> my $node = bless \$a, ref($c
Dear all
What is the precise difference between the two ways of generating an
inside-out-object?
1/
my $node = bless \do { my $anonymous }, ref($class) || $class;
2/
my $a;
my $node = bless \$a, ref($class) || $class;
In other words, why is it suggested in most books, web to have an
/anonymous
Dear all
What is the precise difference between the two ways of generating an
inside-out-object?
1/
my $node = bless \do { my $anonymous }, ref($class) || $class;
2/
my $a;
my $node = bless \$a, ref($class) || $class;
In other words, why is it suggested in most books, web to have an
/anonymo
Perl references (like the Perl language itself) are higher level than
their C counterparts. Pointers expose the memory address wheres
references (to my knowledge and at least not normally) do not. This
opens the door to pointer arithmetic and some of the black magic
possible with pointers (includ
m aware that Perl has pointers/references, as I mentioned, but the
> > > question is not /about/ pointers, but variables.
> >
> > Then why did you start about C pointers? Why the C at the all? The
> > int variables in C work exactly the same scalars work in Perl and the
&g
s, but variables.
Then why did you start about C pointers? Why the C at the all? The
int variables in C work exactly the same scalars work in Perl and the
C pointers work (almost) exactly the same as the references in Perl.
Did you take a look at what you wrote Jenada?
Jenda Krynicky
On 10/10/07, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
>
> And BTW ... you are aware of the fact that if you do
>
> int *b;
> *b = 5;
>
> you cause the program to crash, right?
> You did not start by assigning a variable to a reference to
> something, you assigned to the thing already referenced by
e an attempt to help out.
> I am aware that Perl has pointers/references, as I mentioned, but the
> > question is not /about/ pointers, but variables.
>
> Then why did you start about C pointers? Why the C at the all? The
> int variables in C work exactly the same scalars work in
t /about/ pointers, but variables.
Then why did you start about C pointers? Why the C at the all? The
int variables in C work exactly the same scalars work in Perl and the
C pointers work (almost) exactly the same as the references in Perl.
And BTW ... you are aware of the fact that if you do
int
On 10/10/07, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
>
> From: yitzle <[EMAIL PROTECTED]>
> > On 10/10/07, Kaushal Shriyan <[EMAIL PROTECTED]> wrote:
> > >
> > > Can you please explain me with a sample code. If I understand it
> correctly
> > > does the below code holds true for your explanation
It may be easier to understand outside of computer context and delving
into pointers/references/memory addresses. I'm sure there are some good
tried and true analogies that I can't think of so I'll try to come of up
with one that fits well into computers without getting too far from
reality or too
From: yitzle <[EMAIL PROTECTED]>
> On 10/10/07, Kaushal Shriyan <[EMAIL PROTECTED]> wrote:
> >
> > Can you please explain me with a sample code. If I understand it correctly
> > does the below code holds true for your explanation
>
> Lets put it this way.
> I the world of C/C++, there's something
From: Rob Dixon <[EMAIL PROTECTED]>
> Kaushal Shriyan wrote:
> > Hi,
> >
> > I am referring to http://www.gnulamp.com/perlscalars.html
> >
> > $a = $b; # Assign $b to $a
> >
> > Note that when Perl assigns a value with *$a = $b* it makes a copy of $b and
> > then assigns that to $a. Therefore th
On 10/10/07, Kaushal Shriyan <[EMAIL PROTECTED]> wrote:
>
> Can you please explain me with a sample code. If I understand it correctly
> does the below code holds true for your explanation
>
Lets put it this way.
I the world of C/C++, there's something called a pointer.
The syntax of Perl and C/
Kaushal Shriyan wrote:
Thanks Rob
All they're saying is that $a = $b doesn't tie $a and $b together in any
way, it just copies the value of $b to $a. If you change $b after that
it won't alter $a again.
Can you please explain me with a sample code. If I understand it
correctly does the bel
On 10/10/07, Rob Dixon <[EMAIL PROTECTED]> wrote:
>
> Kaushal Shriyan wrote:
> > Hi,
> >
> > I am referring to http://www.gnulamp.com/perlscalars.html
> >
> > $a = $b; # Assign $b to $a
> >
> > Note that when Perl assigns a value with *$a = $b* it makes a copy of $b
> and
> > then assigns that to $
Kaushal Shriyan wrote:
Hi,
I am referring to http://www.gnulamp.com/perlscalars.html
$a = $b; # Assign $b to $a
Note that when Perl assigns a value with *$a = $b* it makes a copy of $b and
then assigns that to $a. Therefore the next time you change $b it will not
alter $a.
I did not understan
Hi,
I am referring to http://www.gnulamp.com/perlscalars.html
$a = $b; # Assign $b to $a
Note that when Perl assigns a value with *$a = $b* it makes a copy of $b and
then assigns that to $a. Therefore the next time you change $b it will not
alter $a.
I did not understand the Note:- Can some one
yitzle wrote:
> What would be the 'correct' way to deal with a function that takes eg
> 2 scalars and an array?
>
> Something like this?
>
> sub mySub($$@) {
> my $first = shift;
> my $last = shift;
> my @list = @_;
>
> }
>
> or
>
On 5/8/07, yitzle <[EMAIL PROTECTED]> wrote:
What would be the 'correct' way to deal with a function that takes eg
2 scalars and an array?
snip
There are many methods. I would do this:
foo($first, $last, [EMAIL PROTECTED]);
sub foo {
croak "foo expects three argument
What would be the 'correct' way to deal with a function that takes eg
2 scalars and an array?
Something like this?
sub mySub($$@) {
my $first = shift;
my $last = shift;
my @list = @_;
}
or
sub mySub($$@) {
my $first = $_[0];
my $last = $_[1];
my @list = @_[2.. (sca
se of the world you find yourself in. There
are rules. Try to understand why things are happening, not just that
they are happening.
$ is for scalars. Even with $hash{some_key} and $array[0] we're
talking about one entry of the group, a scalar.
...
% is similar, for the hash as a who
On Jul 18, 2004, at 7:59 PM, gohaku wrote:
Hi everyone,
Howdy.
after writing perl scripts for about 3 years now, I still have trouble
with the
basic datatypes.
I know that variables that start with '$' are scalars.
This covers Hashes ($HASH{$key}), Arrays ( $_[0] ), and
regular sca
make sense.
Rob
-Original Message-
From: gohaku [mailto:[EMAIL PROTECTED]
Sent: Sunday, July 18, 2004 8:59 PM
To: Perl Beginners
Subject: Another Perl datatype headache ( scalars $, hashes %, and
arrays @ )
Hi everyone,
after writing perl scripts for about 3 years now, I still have trouble
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On Mon, 19 Jul 2004 12:59, gohaku wrote:
> To get the length of an array, it's $#array, not [EMAIL PROTECTED] or #$array.
> Usually, I use scalar @array;
They do different things, afaik. $#array gives you the index of the last entry
in the array, scal
Hi everyone,
after writing perl scripts for about 3 years now, I still have trouble
with the
basic datatypes.
I know that variables that start with '$' are scalars.
This covers Hashes ($HASH{$key}), Arrays ( $_[0] ), and
regular scalar values ( $foobar );
The code I write as well other
uot;
my %rows;
while ()
{
chomp;
my @fields = split( /,/, $_);
$rows{$fields[2]} = [ ($fields[3]..$fields[-1]) ];
print "array: ";
print "@{$rows{$fields[2]}}\n";
}
close IN;
===
This prints nothing for the
> ===
>
> This prints nothing for the array. If I replace the scalars inside [
> () ] with literal strings or numbers it works. What the correct way
> to do what I'm attempting. Am I just quoting wrong?
The value in $fie
Rob Benton wrote:
$rows{$fields[2]} = [ ($fields[3]..$fields[-1]) ];
Depending on what the fourth and last elements in @fields contain,
that range can be very, very long...
I think this is what you mean:
$rows{$fields[2]} = [ @fields[3..$#fields] ];
--
Gunnar Hjalmarsson
Email: http://www
Rob Benton <[EMAIL PROTECTED]> wrote:
: I'm looking for a little help here. I'm not understanding exactly
: what's wrong with this code:
:
: ===
: #!/usr/bin/perl -w
:
: use strict;
:
: open IN, ")
: {
: chomp;
: my @field
On Jul 1, Rob Benton said:
> $rows{$fields[2]} = [ ($fields[3]..$fields[-1]) ];
You're doing two things wrong: the '..' operator needs to be INSIDE the
subscript.
@fields[$lower .. $upper]
The other thing is that you can't do a range like that. If you want to
get the elements from [3] t
$rows{$fields[2]} = [ ($fields[3]..$fields[-1]) ];
print "array: ";
print "@{$rows{$fields[2]}}\n";
}
close IN;
===
This prints nothing for the array. If I replace the scalars inside [ ()
] with literal strings or nu
On Nov 30, 2003, at 12:33 PM, B. Rothstein wrote:
If I have a scalar variable that itslef is a list of names and
numbers, for
example
$names = 'john 35, jack 18, albert 24, timmy 42'; is it possible, and
if
so how can it be done to separate the individual names and ages from
the
list in their
"B. Rothstein" wrote:
> If I have a scalar variable that itslef is a list of names and numbers, for
> example
> > $names = 'john 35, jack 18, albert 24, timmy 42'; is it possible, and if
> so how can it be done to separate the individual names and ages from the
> list in their scalar form in orde
If I have a scalar variable that itslef is a list of names and numbers, for
example
> $names = 'john 35, jack 18, albert 24, timmy 42'; is it possible, and if
so how can it be done to separate the individual names and ages from the
list in their scalar form in order to create new lists sorted by n
Keep your replies on the list and you won't have to wait for me to wake
up again for an answer. ;)
On Nov 30, 2003, at 4:33 AM, B. Rothstein wrote:
thanks for the functions, but for some reason the sort does not seem
to be
coming out correctly, any idea why?
By default, sort() works ASCIIbetic
On Nov 30, 2003, at 1:45 AM, B. Rothstein wrote:
If I have a scalar variable that itslef is a list of names, for example
$names = 'john, jack, albert, timmy"; is it possible, and if so how
can it
be done to separate the individual names from the list in their scalar
form
in order to create a new
If I have a scalar variable that itslef is a list of names, for example
$names = 'john, jack, albert, timmy"; is it possible, and if so how can it
be done to separate the individual names from the list in their scalar form
in order to create a new list of sorted names. thanks for any suggestions.
r, David ---
> > > > Senior Programmer Analyst --- WGO wrote:
> > > >
> > > > > Jeff Westman wrote:
> > > > > > This may sound trivial, but I am trying to declare and
> > > > > > assign multiple scalars to the same variable in the same
> &g
> >
> > > > Jeff Westman wrote:
> > > > > This may sound trivial, but I am trying to declare and assign
> > > > > multiple scalars to the same variable in the same statement.
> > > > > This is what I have:
> > > > &g
y sound trivial, but I am trying to declare and assign
> > > > multiple scalars to the same variable in the same statement.
> > > > This is what I have:
> > > >
> > > > #!/bin/perl -w
> > > > $a = $b = "apple";# works
> >
try
my ($a,$b)=("apples","apples");
In the other example it was pulling values from an array of scalars.
In your example you are only providing 1 scalar for 2 scalar variables to
share.
Royce
"The right word may be effective, but no word was ever as effective
sound trivial, but I am trying to declare and assign multiple
> >> scalars to the same variable in the same statement. This is what I
> >> have:
> >>
> >> #!/bin/perl -w
> >> $a = $b = "apple";# works
> >> use strict;
>
y ($a, $b);
> $a = $b = 'apple';
>
>
> --- Jeff Westman <[EMAIL PROTECTED]> wrote:
> > This may sound trivial, but I am trying to declare
> > and assign multiple
> > scalars to the same variable in the same statement.
> > This is what I have:
Would declaring all your variables with one my
suffice? then your first line before use strict;
should work. Like this:
my ($a, $b);
$a = $b = 'apple';
--- Jeff Westman <[EMAIL PROTECTED]> wrote:
> This may sound trivial, but I am trying to declare
> and assign multiple
On Wednesday, June 4, 2003, at 02:40 PM, Wagner, David --- Senior
Programmer Analyst --- WGO wrote:
Jeff Westman wrote:
This may sound trivial, but I am trying to declare and assign multiple
scalars to the same variable in the same statement. This is what I
have:
#!/bin/perl -w
$a = $b
Jeff Westman wrote:
> This may sound trivial, but I am trying to declare and assign multiple
> scalars to the same variable in the same statement. This is what I
> have:
>
> #!/bin/perl -w
> $a = $b = "apple";# works
> use strict;
> my ($a = $b) =
This may sound trivial, but I am trying to declare and assign multiple
scalars to the same variable in the same statement. This is what I have:
#!/bin/perl -w
$a = $b = "apple";# works
use strict;
my ($a = $b) = "apple"; # does not works
my $a = my $b = &quo
In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Michael Hooten) writes:
>Simpler and easier to read:
>@combined = map { ref $_ eq 'ARRAY' ? @$_ : $_ } values %{$hash{family}};
>
>Either dereference the array or return the scalar.
Yes, I'm aware of the 'either' in the posting. However, the exa
D]
Subject: Re: using 'map' with mixture of scalars and array refs...
In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Michael Kavanagh) writes:
>Hi there,
>
>I've got a hash that has keys which contain either
>- array references
>- scalar values
>
&
s;
> $hashofarrays{'family'}{'scalar'} = 12938712938;
It would be simpler if you stored all the values as arrays instead of
scalars.
$hashofarrays{'family'}{'arrayref'} = [ 12398712984, 19286192879 ];
$hashofarrays{'family'}{'scalar
ay ref, like this:
> map { push @items, $_ } ( @{$hashofarrays{'family'}{'arrayref'} }
>);
That doesn't look like code that's iterating through the keys. You have a
single hardcoded key.
>But that ignores all the scalar values...it only gets the keys
work for all the array references by mapping on the
de-referenced array ref, like this:
map { push @items, $_ } ( @{$hashofarrays{'family'}{'arrayref'} }
);
But that ignores all the scalar values...it only gets the keys that contain
array references.
To get the sca
Thanks to John W Krahn and Shishir for your replys, need to learn about
push
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Steven Massey wrote:
>
> Hi any help appreciated...
Hello,
> I am reading a file consisting of lines with upto 2 sets if data seperated
> by : ie
>
> 13:fred
> 12:nancy
> lional:
>
> each line is split into @a1 and @a2, here is my problem - if line does not
> have @a2 as in example line 3
PM
To: [EMAIL PROTECTED]
Subject: manipulating arrays/scalars
Hi any help appreciated...
I am reading a file consisting of lines with upto 2 sets if data seperated
by : ie
13:fred
12:nancy
lional:
each line is split into @a1 and @a2, here is my problem - if line does not
have @a2 as in example
Hi any help appreciated...
I am reading a file consisting of lines with upto 2 sets if data seperated
by : ie
13:fred
12:nancy
lional:
each line is split into @a1 and @a2, here is my problem - if line does not
have @a2 as in example line 3 above, I want it to take the value from line
2
ie - 1
looks like '$login = print $hosts{$hostname};'
is not what you want.
'print' function returns '1' -- not the string it prints.
you want:
$login = $hosts{$hostname};
and if you really want to print the value:
print $login;
On Monday, April 1, 2002, at 08:30 AM, [EMAIL PROTECTED] wrote:
> The pro
The problem I am having is with $full
How do I get $login to return its value when I try to assign this scalar
$full
Thanks in advance
#!/util/perl5.static
$hostname = qx(/usr/ucb/hostname);
chomp $hostname;
%hosts = (
crane => "hourihj",
runner => "paulg",
ice => "roo
would use for something like the undef value.
I believe all scalars take up the same amount of memory -- they are
represented by a very specific structure. (See perlguts for the full
details.)
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~jap
Indeed, but assigning a list like this:
($first, $second) = qw/ blabla /
or what ever is equivalent with a array assignment, would make $second
undef, right?
If this happens like a thousand times, I might get currious how much memory
perl would use for something like the undef value.
kind regar
On Feb 9, filson said:
>This might sound silly, but how much memory is allocated for a undef
>scalar? Is any set aside for some sort of indexing or what?
Perhaps you should consider scoping your variables more precisely.
Declare your variables where you need them to exist, not at the very top
of
This might sound silly, but how much memory is allocated for a undef scalar? Is any
set aside for some sort of indexing or what?
Filip
the seond char must be a letter and you can't have a . in a variable name
-Original Message-
From: Naveen Parmar [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 24, 2002 3:06 PM
To: [EMAIL PROTECTED]
Subject: Scalars
Why are the following 2 invalid scalar assignments?
B. $17
* Naveen Parmar ([EMAIL PROTECTED]) wrote:
> Why are the following 2 invalid scalar assignments?
>
> B. $17april = $dayDay 2;
> C. $april.17 = $dayDay 2;
>
> TIA,
> - NP
Looks like homework to me :)
--
___vvz __
(_, ` ) ( )Jeff Bisbee#!/usr/bin/perl -w
`~~~) )/\ [EMAIL
On Jan 24, Naveen Parmar said:
>Why are the following 2 invalid scalar assignments?
>
>B. $17april = $dayDay 2;
>C. $april.17 = $dayDay 2;
I'm not sure what it is you're trying to do here at all.
$17april is an invalid variable name, because:
a) if a variable name starts with digits, it must
Why are the following 2 invalid scalar assignments?
B. $17april = $dayDay 2;
C. $april.17 = $dayDay 2;
TIA,
- NP
_
Send and receive Hotmail on your mobile device: http://mobile.msn.com
--
To unsubscribe, e-mail: [EMAIL PROTECT
Hello Craig,
Saturday, December 08, 2001, Craig Inman <[EMAIL PROTECTED]> wrote:
CI> As I'm new to perl, I'm more or less trying to write a 'nested while
CI> read' loop (atleast that is what my attempts come out to look like so
CI> far).
CI> trying something like
CI> open (A, $list1) or di
Hello all.
I'm trying to find an easy way to 'diff' two files and print what is
missing from each file. Let me start by saying that the system I'm
working on does not seem to like File::compare or &main::compare_text.
As I'm new to perl, I'm more or less trying to write a 'nested while
read' loo
[EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote on 15 Nov 2001:
> i am having a problem reading from an array. i wrote this script to
> query a database, get a certain record and based on the number of
> records returned write to a file 1.the unixtime, 2.the number of
> records in asteriks (ex. *** f
Hi all
i am having a problem reading from an array. i wrote this script to query
a database, get a certain record and based on the number of
records returned write to a file 1.the unixtime, 2.the number of records
in asteriks (ex. *** for 3 records) and 3.the number of records in digit
form.
i ha
[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, August 14, 2001 8:38 PM
Subject: Re: automatically naming scalars
> Hi Jos:
>
> Thanks for the reply.
>
> At 05:44 PM 8/14/01 +0100, [EMAIL PROTECTED] wrote:
> >I must agree with Jos on this ... I read
On Tue, Aug 14, 2001 at 02:38:54PM -0400, Ron Woodall wrote:
> Ok here's my original problem. I have 166 HTML tag pages that I'm
> processing one at a time. Each tag page can have 197 attributes and
> potentially more arguments. Once I process the tag section of the page, I
> have to a
Hi Jos:
Thanks for the reply.
At 05:44 PM 8/14/01 +0100, [EMAIL PROTECTED] wrote:
>I must agree with Jos on this ... I read the email and I saw that what Ron was
>asking for was soft reference ... like I mentioned before a lot of the
>situations (like I mentioned my experience) .. where
gt; > >
> > > >How exactly is the data in the file organized?
> > >
> > > Here's the problem. Go to the Compendium of HTML Elements,
> > > www.htmlcompendium.org --> Main Menu --> HTML --> Attribute Pages and
> click
> > &
> > The right frame will open up into a list of the tag and all
> > attributes/arguments documented to work with that tag. I'm in the
process
> > of completely restructuring the site and using a perl script. This is,
in
> > part a learning exercise for me.
> &g
me will open up into a list of the tag and all
> attributes/arguments documented to work with that tag. I'm in the process
> of completely restructuring the site and using a perl script. This is, in
> part a learning exercise for me.
>
> Here's the problem. One
es plus
> additional arguments for each attribute. The next tag will potentially have
> none. No two tags share all of the same attributes. I need to create a
> series of scalars for each attribute such that each variable can be
> directly addressed and decisions drawn from them and the
f completely restructuring the site and using a perl script. This is, in
part a learning exercise for me.
Here's the problem. One tag will have 166 attributes plus
additional arguments for each attribute. The next tag will potentially have
none. No two tags share all of the same at
On Tue, 31 Jul 2001, Ron Woodall wrote:
> I'm trying to take a word from a file and naming a scalar with
> that word. i.e. I find the word "target" in a file. I then need to
> create $target = "xxx" and various other variables related to target.
> Any suggestions?
Create a hash containing
Hi:
I'm trying to take a word from a file and naming a scalar with that word.
i.e. I find the word "target" in a file. I then need to create $target =
"xxx" and various other variables related to target. Any suggestions?
Thanks for the help.
Ron
--
To unsubscribe, e
We have Perl substitute like this on many of our web queries into our Oracle
db.
-Original Message-
From: Greg Jetter [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 25, 2001 11:31
To: Francesco Scaglioni; [EMAIL PROTECTED]
Subject: Re: ? embed scalars in the sql
On Monday 25 June 2001
83 matches
Mail list logo