Ask a Question related to PERL Miscellaneous, Design and Development.
-
Tad McClellan #1
Re: Variable reference
Par <paer_nystroem@hotmail.com> wrote:
> I have a lot of variables in the form of
> $var{$something} = "Some text";
>
> $something consists of two parts though. Ideally I would have liked it
> to be in the form of $var{$part1$part2}, but that doesn't work...
> So the really nasty looking part I've had to add is
> $something = $part1 . $part2;
>
> So my question is basically how I avoid having the above line?!
$var{ $part1 . $part2 }
or
$var{ "$part1$part2" }
--
Tad McClellan SGML consulting
[email]tadmc@augustmail.com[/email] Perl programming
Fort Worth, Texas
Tad McClellan Guest
-
Reference Items in a Session Variable
I am attempting to reference specific items in a session variable. I can access the "Session.Basket.CurrentRow" of any particular ROW , e.g. (... -
Reference a variable in a repeater
I have some code that worked fine until a created a repeater. I get an error (BC30451) that I've researched on Google groups, etc., to no avail. ... -
Help with variable reference in perl OOD
I need to be able to set a variable equal to the value of an OOD reference such that when the reference changes, the the variable changes as well... -
passing global variable by reference?
I'm trying to stick my frequently used subroutines into a Sysadmin.pm module. Of course the first one I tried uses global variables and I wondering... -
Reference a VBScript Variable in ASP
This is my VBScript function: <script language="JavaScript" type="text/JavaScript"> Dim UN Set objNet = CreateObject("WScript.NetWork") Set... -
Jeff 'japhy' Pinyan #2
Re: Variable reference
On 21 Jul 2003, Par wrote:
Just do>$var{$something} = "Some text";
>
>$something consists of two parts though. Ideally I would have liked it
>to be in the form of $var{$part1$part2}, but that doesn't work...
>So the really nasty looking part I've had to add is
>$something = $part1 . $part2;
>
>So my question is basically how I avoid having the above line?!
$var{$part1 . $part2}
or
$var{"$part1$part2"}
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
Jeff 'japhy' Pinyan Guest
-
Shawn Corey #3
Re: Variable reference
Hi,
You should use $var{ $a, $b } = "Some text";
The key would be $a . $; . $b
$; is set to \034 but you can change it to any character you like.
This is an example to print the keys and values.
for my $key ( keys %var ){
my ( $a, $b ) split /$;/, $key;
print "key $a, $b has value $var{ $key }\n"
}
Jeff 'japhy' Pinyan wrote:
> On 21 Jul 2003, Par wrote:
>
>>>>$var{$something} = "Some text";
>>
>>$something consists of two parts though. Ideally I would have liked it
>>to be in the form of $var{$part1$part2}, but that doesn't work...
>>So the really nasty looking part I've had to add is
>>$something = $part1 . $part2;
>>
>>So my question is basically how I avoid having the above line?!
>
> Just do
>
> $var{$part1 . $part2}
>
> or
>
> $var{"$part1$part2"}
>Shawn Corey Guest
-
Tassilo v. Parseval #4
Re: Variable reference
[ Please don't top-post;
your reply should come after the original text ]
Also sprach Shawn Corey:
While the above is certainly right from a technical standpoint, I> You should use $var{ $a, $b } = "Some text";
> The key would be $a . $; . $b
> $; is set to \034 but you can change it to any character you like.
>
> This is an example to print the keys and values.
> for my $key ( keys %var ){
> my ( $a, $b ) split /$;/, $key;
> print "key $a, $b has value $var{ $key }\n"
> }
stumbled over your first sentence:
I think this misses the point of the OP. He was essentially just asking> You should use $var{ $a, $b } = "Some text";
how to concatenate two strings to one hash-key. Using $hash{ LIST }
however is a Perl4ism. In a time when references weren't yet there, Perl
needed a way to work with multidimensional data-structures. Joining the
elements of the list together with $; was therefore just a work-around.
Nowadays fortunately perl knows about references and thus the
multidimensional array emulation is no longer needed.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus}) !JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexi ixesixeseg;y~\n~~dddd;eval
Tassilo v. Parseval Guest
-
Jeff 'japhy' Pinyan #5
Re: Variable reference
On 21 Jul 2003, Tassilo v. Parseval wrote:
Although, as was stated, you could set $; to "", and thereby make it work>>> You should use $var{ $a, $b } = "Some text";
>> The key would be $a . $; . $b
>> $; is set to \034 but you can change it to any character you like.
>I think this misses the point of the OP. He was essentially just asking
>how to concatenate two strings to one hash-key. Using $hash{ LIST }
>however is a Perl4ism. In a time when references weren't yet there, Perl
>needed a way to work with multidimensional data-structures. Joining the
>elements of the list together with $; was therefore just a work-around.
>Nowadays fortunately perl knows about references and thus the
>multidimensional array emulation is no longer needed.
like the OP wanted. ;)
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
Jeff 'japhy' Pinyan Guest



Reply With Quote

