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



how to find a substring in a string without using substr built in functions, and print the substrin..

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

how to find a substring in a string without using substr built in functions, and print the substrin..

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

how to find a substring in a string without using substr built in functions, and print the substrin..

Answer / garg

#! /user/bin/perl
$str="Yashwanth";
$n="wan";
if ($str=~ $n)
{
print $n;
}

Is This Answer Correct ?    4 Yes 6 No

Post New Answer

More CGI Perl Interview Questions

What is 'commit' command in perl?

0 Answers  


How many data types are there in perl?

0 Answers  


What is q (single q) operator in perl?

0 Answers  


Why we use "use lib $path"?

1 Answers  


What is qq (double q)operator in perl?

0 Answers  






what is the main function of fork() in cgi programming?

0 Answers  


How to read a directory in perl?

0 Answers  


Explain grooving and shortening of arrays and splicing of arrays?

0 Answers  


How can you create an object of a class in a package?

4 Answers   IBM,


What is the function of virtual documents in cgi programs?

0 Answers  


What is a chomp() function in perl?

0 Answers  


How to deleting an existing file in perl programming?

0 Answers  


Categories