how to find a substring in a string without using substr
built in functions, and print the substring found
Answers were Sorted based on User's Feedback
Answer / yashwanth
$r="YASHWANTH";
@n=split (//,$r);
print "@n\n";
@t=splice(@n,0,3);
print "@t\n";
$r=join("",@t);
print "$r\n";
~
~
| Is This Answer Correct ? | 10 Yes | 2 No |
Answer / lucky
#!/usr/bin/perl
print"enter string
";
$str=<stdin>;
print"enter substring
";
$substr=<stdin>;
if($str=~$substr){
print"valid
";
}
else
{
print"invalid
";
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / garg
#! /user/bin/perl
$str="Yashwanth";
$n="wan";
if ($str=~ $n)
{
print $n;
}
| Is This Answer Correct ? | 4 Yes | 6 No |
How are parameters passed to subroutines in perl?
Explain the difference between use and require?
How many ways can we express string in Perl?
How can the user execute a long command repeatedly without typing it again and again?
How do I generate a list of all .html files in a directory?
What is the difference between use and require in perl programming?
Which guidelines by Perl modules must be followed?
How to merge two arrays in perl?
What is confess function in perl?
What is the different between array and hash in perl programming?
What is the use of now constructor in perl?
How can we create perl programs in unix, windows nt, macintosh and os/2 ?