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 8435135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:50:26+00:00 2026-06-10T06:50:26+00:00

I have a perl variable that is being read in from another script’s STDOUT:

  • 0

I have a perl variable that is being read in from another script’s STDOUT:

$var = `someScript.sh`
print $var    <---- Prints "somestring"

However, the variable contains more than “somestring”. There are 15 more characters on the front of the variable (special and not-special but hidden) that don’t show when I print.

length($var)  <--- Returns a number 10-15 larger than "somestring" has chars

I can eliminate the special characters like so:

$var =~ s/[^[:print:]]+//g

But it appears that there are also non-special characters that are revealed once the special characters have been removed:

print $var   <---- Displays "0;<hostname>somestring" 
            (where <hostname> is the system hostname)

Is there a way to eliminate both the special characters AND the non-special characters that were being hidden? I want to be able to use $var as the key of a hash, and then reference it by “somestring”

$hash{$var} = 123
print $hash{'somestring'} 

Thoughts?

  • 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-10T06:50:27+00:00Added an answer on June 10, 2026 at 6:50 am

    Can we assume that the characters you want to remove are before the non-printable characters ?

    If so, maybe something like

    $var =~ s/.*[^[:print:]]+//;
    

    could work ?

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

Sidebar

Related Questions

I have a Perl script that uses WWW::Mechanize to read from a file and
I have a Perl script that takes user input and creates another script that
I have a plain perl script that can be run from the command-line via
For example, I have a perl script p.pl that writes 5 to stdout. I'd
I have this Perl script: #!/usr/bin/perl $var = `ls -l \$ddd` ; print $var,
I have a perl variable $results that gets returned from a service. The value
I have a Perl class that contains a hash instance variable for storing other
I have a Perl script and I am trying to make it print out
I have a Perl script that is getting big, so I want to break
Is there a built-in Perl variable that keeps track of how many records have

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.