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

Which guidelines by Perl modules must be followed?

0 Answers  


What is the difference between use and require in perl?

0 Answers  


Explain the difference between my and local?

2 Answers  


what is Perl one liner?

0 Answers  


You want to open and read data files with perl. How would you do that?

0 Answers  






Explain gmtime() function in perl?

0 Answers  


Explain regular expression in perl?

0 Answers  


Can we load binary extension dynamically?

0 Answers  


How can you call a subroutine and identify a subroutine?

0 Answers  


How interpreter is used in perl?

0 Answers  


what is CPAN?

0 Answers  


When would `local $_' in a function ruin your day?

0 Answers  


Categories