Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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 perl scripting?

0 Answers  


you are required to replace a char in a string and store the number of replacements. How would you do that?

0 Answers  


How to convert strings into an array in perl?

0 Answers  


my @array=('data1','data2'); my @array1=('data1','data2'); my ($i,$k); $i=7; $k=7; while($i){ $array [++$#array] = 'ree'; $i--; print "@array"; } while($k){ push(@array1,'ree'); $k--; print "@array1"; } Are these two while loop are doing the same functionality ? What may be the difference?

1 Answers   A1 Technology,


Why -w argument is used with perl programs?

0 Answers  






What is goto statement in perl?

0 Answers  


What does length(%HASH) produce if you have thirty-seven random keys in a newly created hash?

0 Answers  


What are the logical operators used for small scale operations?

0 Answers  


What are some of the key features of objects in perl?

0 Answers  


How and what are closures implemented in perl?

0 Answers  


How to print escaping characters inside a string in perl?

0 Answers  


What are hashes?

0 Answers  






Categories