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 do I replace every character in a file with a comma?
How many ways can we express string in Perl?
How can you create an object of a class in a package?
What is the tk module?
Assuming both a local($var) and a my($var) exist, what's the difference between ${var} and ${"var"}?
Why to use perl scripting?
What is the importance of perl warnings?
What is the difference between use and require in perl?
Hi, I am a accountant. I am preparing a balance sheet but because of staff shortage and time pressures I cant complete it on time. There is lot of common data with last years which I need not retype and I can manage by editing last year’s balance sheet ? Is their any software on net where I can do this easily??
How will you access an element of a perl array?
How to get help for perl?
How do you match one letter in the current locale?