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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:54:40+00:00 2026-05-15T19:54:40+00:00

I have a string containing lots of text with white-spaces like: String str =

  • 0

I have a string containing lots of text with white-spaces like:

String str = "abc xyz def";

I am now passing this string as a command line argument to a perl file using C# as in:

Process p = new Process();
p.StartInfo.FileName = "c:\\perl\\bin\\perl.exe";
p.StartInfo.Arguments = "c:\\root\\run_cmd.pl " + str + " " + text_file;

In the run_cmd.pl file, I have the follwing:

open FILE, ">$ARGV[1]" or die "Failed opening file";
print FILE $ARGV[0];
close FILE;

On printing, I am able to copy only part of the string i.e. “abc” into text_file since Perl interprets it as a single argument.

My question is, is it possible for me to copy the entire string into the text file including the white spaces?

  • 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-05-15T19:54:41+00:00Added an answer on May 15, 2026 at 7:54 pm

    If you want a white space separated argument treated as a single argument, with most programs, you need to surround it with " "

    e.g run_cmd.pl "abc xyz def" filename

    Try

    p.StartInfo.Arguments = "c:\\root\\run_cmd.pl \"" + str + "\" " + text_file;
    

    Side note:

    I don’t know about windows, but in Linux there’s a number of arguments and maximum length of one argument limit so you might want to consider passing the string some other way, reading it from a tmp file for example.

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

Sidebar

Related Questions

I have string like this /c SomeText\MoreText Some Text\More Text\Lol SomeText I want to
I have a string containing a date, and another string containing the date format
I have a string containing byte data. How can I perform an in-place conversion
In a Python package, I have a string containing (presumably) the name of a
If I have an f# function that takes a string containing a sentence, what
I have an Excel spreadsheet containing a list of strings. Each string is made
In C++, I have a map<string, string> , containing an unknown number of entries.
Suppose I have the following two strings containing regular expressions. How do I coalesce
I have a column containing the strings 'Operator (1)' and so on until 'Operator
If I have a database containing only varchar columns, with strings encoded in Latin-1

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.