<?xml version="1.0" encoding="windows-1252"?>
<node id="301713" title="Re: Puzzled over 'my'" created="2003-10-23 16:47:09" updated="2005-07-27 05:14:09">
<type id="11">
note</type>
<author id="49599">
tadman</author>
<data>
<field name="doctext">
You must've not only removed the &lt;TT&gt;my&lt;/TT&gt;, but the brackets as well. It was the brackets, mind you, that are the key here.
&lt;BR&gt;
&lt;BR&gt;
Including brackets means that you're assigning a list to a list, in this case, the result of the &lt;TT&gt;grep&lt;/TT&gt; operation into a list containing the variable &lt;TT&gt;$ok&lt;/TT&gt;. Thus, the first thing grepped goes into the first variable, and you get "Some String".
&lt;BR&gt;
&lt;BR&gt;
If you want to know how many things you got, you need to force a list to scalar conversion. That might sound fancy, but it's just a way of saying you want to assign the list directly to the variable instead of to a list of variables. No brackets. If you're a bit fuzzy, here's some examples;
&lt;BLOCKQUOTE&gt;&lt;CODE&gt;my @list = ("A","B","C");

my ($var) = @list;    # $var becomes "A"
my $var = @list; # $var becomes 3
my ($var) = scalar(@list); # $var becomes 3
my $var = scalar(@list); # $var becomes 3 (same idea)
&lt;/CODE&gt;&lt;/BLOCKQUOTE&gt;</field>
<field name="root_node">
301561</field>
<field name="parent_node">
301561</field>
</data>
</node>
