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 |
What's the difference between /^Foo/s and /^Foo/?
How to turn on Perl warnings? Why is that important?
Explain use of ‘my’ keyword in perl?
What is perl programming?
What are the steps involved in configuring a server using cgi programming?
What is confess function in perl?
What is the closure in PERL?
What is perl push array function?
How can arrays be tied?
Explain tk?
You want to print the contents of an entire array. How would you do that?
What does last statement do in perl?