On Friday 16 November 2007 17:24, AndrewMcHorney wrote: > Hello Hello,
> I now got my directory listing into an array of strings. I would like > to now split up the string into a an array of strings from the > original string. For example, I might have a string of "a b c d" > and I now want a 4 element array containing "a", "b", "c", 'd". > > I did the following but it did not work. > > @new_dir = @string_array[$index]; Found in /usr/lib/perl5/5.6.0/pod/perlfaq4.pod What is the difference between $array[1] and @array[1]? The former is a scalar value, the latter an array slice, which makes it a list with one (scalar) value. You should use $ when you want a scalar value (most of the time) and @ when you want a list with one scalar value in it (very, very rarely; nearly never, in fact). Sometimes it doesn't make a difference, but sometimes it does. For example, compare: $good[0] = `some program that outputs several lines`; with @bad[0] = `same program that outputs several lines`; The `use warnings' pragma and the -w flag will warn you about these matters. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/