1)join():
This function is used to join the elements using some specific character which has been passed as argument in this function. So the first character is used to join the elements and then after that we can pass as many arguments as possible.These arguments can be either strings,numbers or array.
This function is used to split an string on the basis of some character which is passed as the first argument in this method.
This function is used to join the elements using some specific character which has been passed as argument in this function. So the first character is used to join the elements and then after that we can pass as many arguments as possible.These arguments can be either strings,numbers or array.
#! /Perl/bin/perl
@array=(I,am,a,good,boy);
$str=join(":",@array,1,2,"no","its");
print($str);
Output:@array=(I,am,a,good,boy);
$str=join(":",@array,1,2,"no","its");
print($str);
I:am:a:good:boy:1:2:no:its
2)split():This function is used to split an string on the basis of some character which is passed as the first argument in this method.
#! /Perl/bin/perl
$str="I:am:good";
@array=split(":",$str);
print("@array");
Output:$str="I:am:good";
@array=split(":",$str);
print("@array");
I am good
0 comments:
Post a Comment