Question: I am completely new to the Perl programming.
I am trying the split function.
Here is my code: 

```
#!perl;
use strict;
use warnings;
use Data::Dumper;

my @sections = ("Hard Drive", "Multi Drive");
foreach my $secname (sort @sections) 
{
    my $file_name=split / /, $secname;
    print $file_name;
}

```

so I am trying to get the output like only second word only.

output is 
`22`

The expected output is:

```
drive
drive

```

Here I am trying to get second word but it is not giving the expected output.

Please anyone suggest and help me.

Answer: 
Split returns a list of strings in list context only.

As mentioned in the comments above, you can thus get the strings by using list context.

For example, store them all in an array:

```
my @split_string = split / /, $secname;
my $wanted = $split_string[1]; # get the string you want (here, second)

```

If you do not need them later, you can also use an anonymous array for this,
saving yourself a variable:

```
my $wanted = (split / /,$secname)[1];

```

Most functions in perl are context-sensitive, i.e. return different values whether called in list or in scalar context, the return values are usually quite sensible when you think about it, but it takes some getting used to.
split converts scalar to list. You tried to split the each values of an list. 

The output `22` results because, it displays the total number of scalar in an list.

For example 

```
@ar = qw(1 4);
$aa = @ar;
print $aa;

```

It results `2`. The same think was rises in your problem.

So you store the splitting value into an array. And the print the expected output by the index key of array.

Try this

```
use strict;
use warnings;
use Data::Dumper;

my @sections = ("Hard Drive", "Multi Drive");
foreach my $secname (sort @sections) 
{
    my @file_name=split / /, $secname;
    print $file_name[1],"\n";
}

```