Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8126105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:02:51+00:00 2026-06-06T07:02:51+00:00

Recently, I was asked in an interview question to reverse a string in perl.

  • 0

Recently, I was asked in an interview question to reverse a string in perl. I wrote the code and they wanted me to give some example strings to test it. I gave them examples like a string with few characters, lot of characters, invalid characters etc etc. But they also asked what is the longest string I will test with. I was not sure what to tell.
Hence this question.
What is the longest string I can test in a perl code ? What does it depend on ? Memory on the machine ?
Is there any limitation from perl stand point ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T07:02:52+00:00Added an answer on June 6, 2026 at 7:02 am

    I was looking to see if I can find any official documentation on the longest string. I found one at http://perltutorial.org talking about Strings:

    Perl defines string as a sequence of characters. The shortest string contains no character or null string. The longest string can contain unlimited characters which is only limited to available memory of your computer.

    I don’t know if this is official enough for you. It’d be nice to see something in the FAQ or Perldoc.

    By the way, to officially reverse a string in Perl:

    my $rev_string = reverse $string;
    

    This is in the Perl FAQ #4 which has a bunch of string handling stuff in it. The reverse a string question is an old trick interview question to see if someone knows their arcane Perl stuff. Sure almost everyone knows reverse will reverse an array, but do they also know it will reverse a string? Noobies will work out some sort of complex algorithm and the interviewer will have a reason to feel smug and not hire that person.

    Personally, if I was interviewing someone, I asked this question, and someone came up on the spot with an elegant algorithm and showed me how it would work with short, long, and invalid characters, I’d hire them. You can always learn new stupid Perl tricks, but quick-on-your-feet type of thinking is something that’s hard to find.

    I learned the reverse string trick a long time ago when someone asked me the same question in an interview. I looked it up and found it in the FAQ and realized I did it wrong. I’ve been using Perl for almost 20 years and I can’t think of a time I had ever had to reverse a Perl string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was asked recently in an interview to give an example of a simple
I recently attended an interview and they asked me the question Why Interfaces are
Recently, I was asked in a interview to implement a string reverse function using
Recently I have been asked an interview question What are the events order in
I was recently asked this question in an interview. Lets suppose I have 2000
Recently I was asked the following question at interview. What are the different way
Recently I was asked this question in an interview. I gave an answer in
Here one more basic question asked in MS interview recently class A { public
Recently I faced few interview questions.The interviewer asked the to give the detailed answer.
I was recently asked a weird question in an interview here it is; Private

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.