To solve a problem of subsequence check I am trying to take two string input in two different array and access them by array indexs ?
In C i did it like below..
char text[25000],pattern[25000];
scanf("%s %s",text,pattern);
and i can access each character through array index.
How can i do the same in perl??
In perl i haven't found anything specific to access array indexes. All i got is to use the perl split function..
my @pattern = split(" ",<>);
This splits the input based on space and assigns to array indexes, if the input is like canada nad split will assign canada to $pattern[0] and nad to $pattern[1]
but i want them in two separate array?
i found another user of split like..
my @pattern = split(undef,<>);
foreach my $val (@pattern){
print $val."\n";
}
this can access all the character of the string but the problem is i can't assign them in two different arrays.
Thanks in advance of any idea/suggestion.
Got it, i was looking for something like this..
my ($text,$pattern) = split(' ',<>);
my @textarr= split //,$text;
my @patterarr= split //,$pattern;
substrto access a single character in a stringperl -E'my $text = "text"; say substr($text,2,1)'(printsx)