develooper Front page | perl.beginners | Postings from July 2012

How to set ">" as record separator in a Perl one liner?

Thread Next
From:
De-Jian Zhao
Date:
July 15, 2012 23:35
Subject:
How to set ">" as record separator in a Perl one liner?
Message ID:
5003B635.4090904@gmail.com
Hi,

I want to change the record separator in a Perl one liner with ">" as 
the separator. However, I tried without success.

The perlrun document 
(http://perldoc.perl.org/perlrun.html#Command-Switches) says that*
"***-0*[/octal/hexadecimal/] * specifies the input record separator 
(|$/| ) as an octal or hexadecimal number. *"
*When I tried to get the octal/hexadecimal code of ">" with oct(">") and 
hex(">"), I got "0". I used this number and it did not work the way I 
wanted (perl -00 -ne 'print if /AAAA/' test.seq ).

Do the functions (oct and hex) return the octal and hexadecimal value of 
the inputted character? The document on the web seems to give different 
answers.

http://perldoc.perl.org/index-functions-by-cat.html#Functions-for-SCALARs-or-strings
hex <http://perldoc.perl.org/functions/hex.html> - convert a string to a 
hexadecimal number
oct <http://perldoc.perl.org/functions/oct.html> - convert a string to 
an octal number

http://perldoc.perl.org/functions/hex.html
*hex EXPR **hex* Interprets EXPR as a hex string and returns the 
corresponding value.

http://perldoc.perl.org/functions/oct.html
*oct EXPR **oct* Interprets EXPR as an octal string and returns the 
corresponding value.

I tested the functions. The first description is possibly wrong. If I am 
right, which functions could be used to get the octal and hexadecimal 
number of a string? How should the Perl one liner be written to change 
the record sepatator to ">"? Thanks for your attention.

Dejian



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About