![]() |
question on inverting text -> txet
Hello Group
I was wondering in anyone knew of or could generate a script that takes an input file which consists of one long line of charachters, and would output the file inverted (backwards) i.e. input file looks like: opkiltyo output file looks like: oytlikpo Thanks alot in advance for any help offered. |
Re: question on inverting text -> txet
arctan wrote:
> I was wondering in anyone knew of or could generate a script that > takes an input file which consists of one long line of charachters, > and would output the file inverted (backwards) > > i.e. input file looks like: opkiltyo > output file looks like: oytlikpo A hint: print scalar reverse split //, 'opkiltyo'; -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl |
Re: question on inverting text -> txet
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> arctan wrote: > > i.e. input file looks like: opkiltyo > > output file looks like: oytlikpo > > A hint: > > print scalar reverse split //, 'opkiltyo'; Kind of a confusing hint... :-) # in scalar context: reverses a string print scalar reverse 'opkiltyo'; # in list context: reverses a list print reverse split //, 'opkiltyo'; Not that your code doesn't work -- just that it works for an odd reason. After you split() the characters, reverse() concatentated them back together and treated them like a scalar. -- Steve |
Re: question on inverting text -> txet
Steve Grazzini wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote: >>arctan wrote: >> >>>i.e. input file looks like: opkiltyo >>> output file looks like: oytlikpo >> >>A hint: >> >> print scalar reverse split //, 'opkiltyo'; > > Kind of a confusing hint... :-) > > # in scalar context: reverses a string > print scalar reverse 'opkiltyo'; > > # in list context: reverses a list > print reverse split //, 'opkiltyo'; > > Not that your code doesn't work -- just that it works for an odd > reason. After you split() the characters, reverse() concatentated > them back together and treated them like a scalar. Hmm.. I think I misread the docs. Thanks for pointing it out. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl |
Re: question on inverting text -> txet
perl -lpe '$_ = reverse'
|
Re: question on inverting text -> txet
Oh, and this newsgroup doesn't exist. Please use comp.lang.perl.misc instead.
|
Re: question on inverting text -> txet
rjohnson@shell.com (Roy Johnson) wrote in message news:<3ee08638.0310150602.162c82ab@posting.google. com>...
> Oh, and this newsgroup doesn't exist. Please use comp.lang.perl.misc instead. Thanks alot to the members of this nonexistant group :) That was a big help. Ill post furthur questions to the suggested perl group. |
| All times are GMT. The time now is 06:47 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.