Hi Dejian, On Mon, 16 Jul 2012 14:35:33 +0800 De-Jian Zhao <dejian.z...@gmail.com> wrote:
> 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 ). You need to do sprintf("%o", ord(">")) instead: $ perl -E 'say sprintf("%o", ord(">"))' 76 oct and hex convert FROM octal or hexadecimal. sprintf("%o") converts TO octal. And ">" is a string, and you need http://perldoc.perl.org/functions/ord.html to return its first character's numeric value. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ "The Human Hacking Field Guide" - http://shlom.in/hhfg CPAN thrives *because* of the unfettered uploading of shit, not in spite of it. — Andy Lester Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/