ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Scripts  >>  CGI Perl
 
 


 

 
 PHP interview questions  PHP Interview Questions
 ASP interview questions  ASP Interview Questions
 CGI Perl interview questions  CGI Perl Interview Questions
 JavaScript interview questions  JavaScript Interview Questions
 VB Script interview questions  VB Script Interview Questions
 JSP interview questions  JSP Interview Questions
 Shell Script interview questions  Shell Script Interview Questions
 Python interview questions  Python Interview Questions
 Tcl interview questions  Tcl Interview Questions
 Awk interview questions  Awk Interview Questions
 AJAX interview questions  AJAX Interview Questions
 Ruby on Rails interview questions  Ruby on Rails Interview Questions
 Scripts AllOther interview questions  Scripts AllOther Interview Questions
Question
How to count no of occurrence of a unique patterns in perl?
 Question Submitted By :: Hema
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How to count no of occurrence of a unique patterns in perl?
Answer
# 1
while ($string =~ /<pattern>/g) { $count++ }
 
Is This Answer Correct ?    5 Yes 1 No
Ramya
 
  Re: How to count no of occurrence of a unique patterns in perl?
Answer
# 2
if we are looking for occurrences of single character in a
string then we can use TR command
syntax: tr///
example: 
$string="The lion group will meet me after lunch";
and we are looking for the occurrences of character 'l' in
the given string. then we can write tr like
$count = ($string=~tr/l//);
print "l is coming $count time(s)";

but for multiple characters look up we have to use:

$string = "-9 55 48 -2 23 -76 4 14 -44";
while ($string =~ /-\d+/g) { $count++ }
print "There are $count negative numbers in the string";


Donated by :- Kuldip singh behal
 
Is This Answer Correct ?    3 Yes 0 No
Kuldip Singh Behal
 
 
 
  Re: How to count no of occurrence of a unique patterns in perl?
Answer
# 3
($count)=$string =~ s/<pattern>/<pattern>/g;
 
Is This Answer Correct ?    2 Yes 0 No
Shah Faisal
 

 
 
 
Other CGI Perl Interview Questions
 
  Question Asked @ Answers
 
How do you debug a Perl scripting ( at the compile time error or run time error) in Unix environment ?  4
i have a folder called 'error' and in that, i have error log files which are generated by the build, now i want to findout the string 'error' from each log file and that error has to be copied into the another file called 'analysis'. how do you do this in perl? HP5
What arguments do you frequently use for the Perl interpreter and what do they mean?  2
what r the different type of function in perl ??? Symphony1
what is the procedure to define a user define module in your perl application? IBM1
What elements of the Perl language could you use to structure your code to allow for maximum re-use and maximum readability?  1
how to install a package in perl ????  2
How to count no of occurrence of a unique patterns in perl? Ness-Technologies3
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
Difference between Perl and Mod_perl?  2
What is the difference between for & foreach, exec & system? Photon5
Explain the difference between my and local?  2
write a script to generate n prime no.s? Persistent2
What is caller function in perl?  1
What?s your favorite module and why?  2
Write a script for 'count the no.of digits using regular expressions in perl.. AppLabs5
Which web site will help the student to download the Java mini Project ?  1
what is the difference between require and use in perl? IBM3
Can any1 tell me 2 write the script using perl script 2 looking at a log file 2 see wheather the test has passed or not. TCS2
How would you trap error occurred in the perl program/file? IBM3
 
For more CGI Perl Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com