CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Escape a vertical tab

 



YankeeFan
New User

May 20, 2009, 6:25 AM

Post #1 of 3 (602 views)
Escape a vertical tab Can't Post

Greetings
I've found many sites that say \v is for a vertical tab. I found one that says it is not recognized as an escape character. I'm using perl v5.8.8 on a windows machine. In my script I cannot use \v, as it doesn't work. Sigh!

$foo =~ s/\v/' - '/g;

>> Unrecognized escape \v passed through at csodata-csv.pl line 668.

Is there any simple work around for this? One site says use s/\\v/' - '/g, but that doesn't work either.

Thanks for any tips.


jjp
New User

May 28, 2009, 4:40 AM

Post #2 of 3 (581 views)
Re: [YankeeFan] Escape a vertical tab [In reply to] Can't Post

Vertical tab:
HTML Entity (hex) 

how about:
$foo =~ s//' - '/g;


FishMonger
Veteran / Moderator

May 28, 2009, 6:21 AM

Post #3 of 3 (578 views)
Re: [YankeeFan] Escape a vertical tab [In reply to] Can't Post

Extracted from the "Quote and Quote-like Operators" in perlop

Quote
NOTE: Unlike C and other languages, Perl has no \v escape sequence for the vertical tab (VT - ASCII 11), but you may use \ck or \x0b .


Here's a test script that I ran on both Windows and Linux.

Code
#!/usr/bin/perl 

use strict;
use warnings;

my $foo = "does this line have a \x0b vertical tab\n";
print $foo;

$foo =~ s/\013/' - '/; # octal 013 eq ascii 11 eq vertical tab
print $foo;

Linux

Code
[root@rkb-2 ~]# ./test.pl 
does this line have a
vertical tab
does this line have a ' - ' vertical tab


Windows

Code
C:\TEMP>test.pl 
does this line have a ♂ vertical tab
does this line have a ' - ' vertical tab



(This post was edited by FishMonger on May 28, 2009, 6:22 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives