<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v =
"urn:schemas-microsoft-com:vml" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word" xmlns:m =
"http://schemas.microsoft.com/office/2004/12/omml"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16640" name=GENERATOR>
<STYLE>@font-face {
        font-family: Calibri;
}
@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.0in 1.0in 1.0in; }
P.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Calibri","sans-serif"
}
LI.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Calibri","sans-serif"
}
DIV.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Calibri","sans-serif"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
P.MsoListParagraph {
        FONT-SIZE: 11pt; MARGIN: 0in 0in 0pt 0.5in; FONT-FAMILY: "Calibri","sans-serif"; mso-style-priority: 34
}
LI.MsoListParagraph {
        FONT-SIZE: 11pt; MARGIN: 0in 0in 0pt 0.5in; FONT-FAMILY: "Calibri","sans-serif"; mso-style-priority: 34
}
DIV.MsoListParagraph {
        FONT-SIZE: 11pt; MARGIN: 0in 0in 0pt 0.5in; FONT-FAMILY: "Calibri","sans-serif"; mso-style-priority: 34
}
SPAN.EmailStyle17 {
        COLOR: windowtext; FONT-FAMILY: "Calibri","sans-serif"; mso-style-type: personal-compose
}
.MsoChpDefault {
        mso-style-type: export-only
}
DIV.Section1 {
        page: Section1
}
OL {
        MARGIN-BOTTOM: 0in
}
UL {
        MARGIN-BOTTOM: 0in
}
</STYLE>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></HEAD>
<BODY lang=EN-US vLink=purple link=blue>
<DIV dir=ltr align=left>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><SPAN
class=843571518-27052008><FONT face=Tahoma size=2>Hi,</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><SPAN
class=843571518-27052008><FONT face=Tahoma size=2>The next works too:<BR>push
@$a1ref, ["Seattle", "Olympia", "Tacoma"];<BR>print $a1ref->[0][0] .
"\n";</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><SPAN
class=843571518-27052008><FONT face=Tahoma size=2>But $alref->[0] is array
and you can not push a scalar (e.g. "Washington") there.<BR>I think the next
structure fits better to your goal:</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><SPAN
class=843571518-27052008><FONT face=Tahoma size=2>push
@{$a1ref->{Washington}}, ("Seattle", "Olympia", "Tacoma");<BR>print
$a1ref->{Washington}[0] . "\n";</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV><SPAN
class=843571518-27052008><FONT face=Tahoma size=2>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><BR>--
Sergey</DIV>
<DIV></FONT><FONT face=Tahoma size=2></FONT></SPAN> </DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
</DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT face=Tahoma
size=2><B>From:</B> sanfrancisco-pm-bounces+sergey.fetisov=ask.com@pm.org
[mailto:sanfrancisco-pm-bounces+sergey.fetisov=ask.com@pm.org] <B>On Behalf Of
</B>Dan Boger<BR><B>Sent:</B> Tuesday, May 27, 2008 10:11 AM<BR><B>To:</B> San
Francisco Perl Mongers User Group<BR><B>Subject:</B> Re: [sf-perl] Pushing and
Popping an array on the heap<BR></FONT><BR></DIV>
<DIV></DIV><BR>
<DIV class=gmail_quote>On Tue, May 27, 2008 at 9:52 AM, Neil Heller <<A
href="blocked::mailto:nheller@silcon.com">nheller@silcon.com</A>> wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV lang=EN-US link="blue" vlink="purple">
<DIV>
<P>The problem is that I don't have a clue (nor am I able to find) how to use
(or the syntax involved to) "push" (or unshift) and "pop" (or shift) values
into and out of this described data
structure.</P></DIV></DIV></BLOCKQUOTE></DIV>I think (but can't be sure since
you didn't post what you tried) that you're running into a precedence
issue. If you type:<BR><BR> push $a1ref[0]->[0],
"value";<BR><BR>Push will complain since it wants an array as it's first
argument, not an array reference. The way to get around it is to
dereference the array:<BR><BR> push @{$a1ref[0]->[0]},
"value";<BR><BR>Same will work for any of the array manipulation commands
(shift, pop, unshift, splice, etc).<BR><BR>HTH!<BR><BR>Dan<BR><BR>-- <BR>Dan
Boger </DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B>
sanfrancisco-pm-bounces+sergey.fetisov=ask.com@pm.org
[mailto:sanfrancisco-pm-bounces+sergey.fetisov=ask.com@pm.org] <B>On Behalf Of
</B>Neil Heller<BR><B>Sent:</B> Tuesday, May 27, 2008 9:53 AM<BR><B>To:</B> 'San
Francisco Perl Mongers User Group'<BR><B>Subject:</B> [sf-perl] Pushing and
Popping an array on the heap<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV class=Section1>
<P class=MsoNormal>Some of the advantages of using an array are the push and pop
functions.<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>The following instantiates a reference on the stack that
points to an (anonymous) empty array on the heap:<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>What I would like to do is:<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoListParagraph
style="MARGIN-LEFT: 38.25pt; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><![if !supportLists]><SPAN
style="mso-list: Ignore">1.<SPAN
style="FONT: 7pt 'Times New Roman'">
</SPAN></SPAN><![endif]>Instantiate a reference on the stack that points to an
empty, anonymous array on the heap.<o:p></o:p></P>
<P class=MsoListParagraph
style="MARGIN-LEFT: 38.25pt; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><![if !supportLists]><SPAN
style="mso-list: Ignore">2.<SPAN
style="FONT: 7pt 'Times New Roman'">
</SPAN></SPAN><![endif]>“push” a reference ($a2ref) into the original anonymous
array that points to a secondary, anonymous array<o:p></o:p></P>
<P class=MsoListParagraph
style="MARGIN-LEFT: 38.25pt; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><![if !supportLists]><SPAN
style="mso-list: Ignore">3.<SPAN
style="FONT: 7pt 'Times New Roman'">
</SPAN></SPAN><![endif]>“push” a series of references into the array referenced
by $a2ref<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>An example might look something like the
following:<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'">$a1ref =
[undef];<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'">(The values to be
pushed are as follows);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'">
Washington
$a1ref->[0]<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'">
Seattle
$a1ref[0]->[0]<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'">
Olympia
$a1ref[0]->[1]<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'">
Tacoma
$a1ref[0]->[2]<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'">
Oregon
$a1ref->[1]<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'">
Portland<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'">
Salem<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'">
Beaverton <o:p></o:p></SPAN></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>Finally, I would like to pop (or shift) values from $a1ref
followed by the individual members of the secondary array (such as
$a1ref[0]->[0]).<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>The problem is that I don’t have a clue (nor am I able to
find) how to use (or the syntax involved to) “push” (or unshift) and “pop” (or
shift) values into and out of this described data structure.<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>I appreciate any help I can get.<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>Neil Heller<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P></DIV></BODY></HTML>