CoolInterview.com - World's Largest Collection of Interview Questions
Start Your Own website Now
Sponsored Links

Interview Questions
Our Services

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!



    Send your Resume to 6000 Companies


  • INTERVIEW QUESTIONS LANGUAGES PERL DETAILS
    Question :
    Sort a word "system" in perl/shell without using built in functions output should be emssty?
    Category Perl Interview Questions
    Rating (0.3) By 14 users
    Added on 8/6/2012
    Views 155
    Rate it!
    Answers:

    #!/usr/bin/perl

    my $word = $ARGV[0];
    $sortword = "";
    $lastchar = "";

    while($word =~ /(.)/g)
    {
    $lastchar = $1;
    if( $sortword ) {
    $flag = "";
    $newsortword = "";
    while($sortword =~ /(.)/g) {
    if( $lastchar gt $1 || $flag
    eq "charcovered") {

    $newsortword =
    $newsortword.$1;
    $flag = "greater" if($flag
    ne "charcovered")
    }
    else {
    $newsortword =
    $newsortword.$lastchar.$1;
    $flag = "charcovered";
    }
    }
    if( $flag ne "charcovered" ) {
    $newsortword =
    $newsortword.$lastchar;
    }

    $sortword = $newsortword;
    }
    else {
    $sortword = $lastchar;
    }
    }

    print $sortword." ";



    If you have the better answer, then send it to us. We will display your answer after the approval.
    Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       
    Related Questions
    View Answer
    How to sort dates in Perl?
    View Answer
    Packing and Unpacking.

    Hi, I want to get output as 0x23400000345....
    in the below example How to get?
    i tried out, but unable to get the answer

    $r=0x234;
    $t=0x345;
    $y=pack(L L,$t,$r);
    $x1=unpack(L!,pack(P,$y));
    printf(" The value is $x1");

    I didnt get constant output?
    View Answer
    Write an expression or Perl script to identify the entered IP address is valid or not?
    View Answer
    Write a script to reverse a string without using Perl's built in functions?
    View Answer
    What is the easiest way to download the contents of a URL with Perl?
    View Answer
    How to concatenate strings with Perl?
    View Answer
    How do I read command-line arguments with Perl?
    View Answer
    When would `local $_' in a function ruin your day?
    View Answer
    What happens to objects lost in "unreachable" memory..... ?
    View Answer
    How do you match one letter in the current locale?
    View Answer
    How do I print the entire contents of an array with Perl?
    View Answer
    Perl uses single or double quotes to surround a zero or more characters. Are the single(' ') or double quotes (" ") identical?
    View Answer
    How many ways can we express string in Perl?
    View Answer
    How do you give functions private variables that retain their values between calls?
    View Answer
    Describe about the security vulnerability of PHP?
    View Answer
    Explain about returning values from subroutines (functions)?
    View Answer
    Determine the difference between my and local?
    View Answer
    What are the different types of eval statements?
    View Answer
    What are the different forms of goto in perl? Explain?
    View Answer
    What is a short circuit operator?
    View Answer


    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL Perl Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2014 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes


    Cache = 0.015625 Seconds