I tried to split one string and assign an array, and then add http at the start using unshift.
But, I am not getting the desired output. What am I doing wrong here?
use strict;
my $str = 'script.spoken-tutorial.org/index.php/Perl';
my @arr = split (/\//,$str);
print "chekcing the split function:\n @arr\n";
my @newarr = unshift(@arr, 'http://');
print "printing new array: @newarr\n";
the output is:
checking the split function:
script.spoken-tutorial.org index.php Perl
printing new array: 4
Why instead of adding http is it giving number 4 (which is array length)?
unshiftadds an element to the front of the array in its first argument, so after its use that@arrhas that new element in its beginning. More importantly: you must read perldoc pages for functions as you are learning to use them! At least scan through for basics and important stuff if some are too tough to read all and understand.