Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

360 degree Twiddle (Re: Twiddle)

by E-Bitch (Pilgrim)
on Aug 15, 2001 at 00:26 UTC ( [id://104869]=note: print w/replies, xml ) Need Help??


in reply to Twiddle

okay, so lets print the thing in a square, and make it readable in several directions (theoretically)
#!/usr/bin/perl -w use strict; print 'What string would you like to twiddle? '; chomp(my $twiddle = <STDIN>); my $string; my $oldString = ""; my $totallen = length($twiddle); my @t = split(//, $twiddle); for (0..$#t) { $string = shift(@t); print $oldString; for(my $i = 0; $i < (2*($totallen - length($oldString))-1); $i++) { print $string; } print (scalar reverse $oldString); print "\n"; # up $oldString .=$string; } while ($oldString) { chop($oldString); $string = substr($oldString, (length($oldString)-1)); print $oldString; # print the first part o' the string (minus the +last character) for(my $i = 0; $i < (2*($totallen - length($oldString))-1); $i++) { print $string; #print each 'last' character up there enough ti +mes to make the square } print (scalar reverse $oldString);# print the last part o' the str +ing (minus the first character) print "\n"; }
hhhhhhhhh
heeeeeeeh
hellllleh
hellllleh
hellolleh
hellllleh
hellllleh
heeeeeeeh
hhhhhhhhh
I know the code is hacky, but it works...
_________________________________________
E-Bitch
Tempora Mutantur Nos et Mutamur in Illis
"The Times are Changed Even as We are Changed in Them"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://104869]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-25 08:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found