in reply to Re^2: Question on File Handler and Subroutines in Perl
in thread Question on File Handler and Subroutines in Perl

Just wondering, does that statement convert an array "stream" into a scalar quantity, e.g. a string?

Yes, but not the scalar quantity you might imagine. Running scalar on an array or list argument returns the number of elements in the array or list as this is what happens when an array a list is evaluated in scalar context. Conversely, if you wanted a string which was a concatenation of all the elements in the array then you might use join.

#!/usr/bin/env perl use strict; use warnings; my @foo = ('dog', 'bites', 'man', 'bites', 'dog'); printf "scalar = '%s'\n", scalar @foo; printf "join = '%s'\n", join ' ', @foo;

Update: removed erroneous mentions of lists as their behaviour in scalar context differs from arrays (returns the last item). Thanks choroba for reminding me of this.