473,794 Members | 2,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parsing escape characters in @ARGV

1 New Member
Hello,

This is my first post to this forum, because until now Perl has been one of the most convenient and intuitive programming languages I know. However, now I have an issue that I cannot resolve. I want to pass a string as a command line argument, and (for the purposes of this question) print the string. This works fine, except for the fact that escape characters are not parsed.

The code:
Expand|Select|Wrap|Line Numbers
  1. $output1 = $ARGV[0];
  2. $output2 = "line 1\nline 2";
  3.  
  4. print $output1;
  5. print "\n";
  6. print $output2;
  7.  
The call:
Expand|Select|Wrap|Line Numbers
  1. perl lines.pl "line 1\nline 2"
  2.  
The output:
Expand|Select|Wrap|Line Numbers
  1. line 1\nline 2
  2. line 1
  3. line 2
  4.  
I'm running Perl 5.10.0 on the Command Prompt of WinXP.

Does anyone know how to parse the escape characters in @ARGV? Thanks in advance.
Nov 13 '08 #1
0 1755

Sign in to post your reply or Sign up for a free account.

Similar topics

16
6000
by: Luis P. Mendes | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I only know a little bit of xml and I'm trying to parse a xml document in order to save its elements in a file (dictionaries inside a list). When I access a url from python 2.3.3 running in Linux with the following lines:
2
8565
by: BTnews | last post by:
Hi, Can anyone here point me at a definitive guide or tutorial about using escape characters when building SQL queries from user entered data? I'm especially interested in info on this in regard to Access databases and (classic) ASP. I've been writing ASP for just over a year now, and I've usually found very comprehensive answers to other problems on one of the many excellent website resources out there. The coverage of this...
5
7976
by: KathyB | last post by:
Hi, not sure this is the right group, but hoping someone may have experienced this. I'm passing html text as a parameter to a javascript. When it has an apostrophe in it, of course it does parse correctly. BTW, using IE6 and msxml3/4. Even if I manually escape the ' with \' or '' the browser just sees it as \' or '' and not as an escaped apostrophe.
0
847
by: Chris | last post by:
I have a friend who's asked me to help him find information leading to the creation of escape characters other than Windows defined ones in C/C++ he is trying to program his own text editor and needs to define escape sequences. If anyone knows the general setup of an escape sequence in code please let me know. Thanks, Chris
2
43826
by: Matthew Wieder | last post by:
In my previous post, I asked about a routine which prepares a string for an XPath query by taking care of escape characters. Unable to find a list, I'm now wondering assumign I enclose the attribute value in quotes in my XPath query, what other escape characters need to be handled aside from a quotation mark? As I understand it, an apostrophe wouldn't be a problem since I'm enclosing the string in quotes. thanks!
3
2249
by: Guadala Harry | last post by:
I'd like to know the answer to the following question so I can know what to expect with regard to other similar uses of escape characters and strings. While everything works fine - I'd like to know specifically why: I am building a simple HTML table in my C# code-behind by concatenating strings that contain different parts of the table and table content... something like this: string myTable = "<table width=\"100%\" border=\"0\"...
0
1479
by: Mike Cooper | last post by:
Hi everyone, I am accessing several binary (PCL) files sequentially using a for loop. For each file I am using the fileget() command to populate the contents of the file into a string. I use the following commands to do so: LengthofOverlay = FileLen(PCLOven_Burn_Directory & OverlayForm) OverlayContent = StrDup(LengthofOverlay, "x") Seek(OverlayInteger, 1)
3
1412
by: JJ | last post by:
Does anyone know if there is any difference in the excape characters on a Mac (compared to a PC). I am parsing some text that is pasted into a textbox, and splitting it based on the position of \t or \r escape characters. Works fine on a PC, but it may not be working as expected on a Mac. Whether this is because of differences in the text file format I have yet to ascertain. Thanks in advance,
2
2759
by: sklett | last post by:
I'm having some trouble storing a string in my settings file that contains escape characters. If I enter "This is the first line\r\nand this is the second line." When I retrieve the string from the settings file I get: "This is the first line\\r\\nand this is the second line." It seems to think it's a path or something? Anyone else dealt with this before? I googled the problem but didn't find anything (so far).
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10161
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6777
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4112
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.