Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Re: Substitute ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 12 of 12 Topic 10952 of 12261
Post > Topic >>

Re: Substitute Variably hort string into long string at Right Justified possition

by chas.owens@[EMAIL PROTECTED] (Chas. Owens) Apr 20, 2008 at 10:18 AM

On Sun, Apr 20, 2008 at 7:38 AM, Rob Dixon <rob.dixon@[EMAIL PROTECTED]
> wrote:
>
> Chas. Owens wrote:
>  > On Sat, Apr 19, 2008 at 1:57 PM, Rob Dixon <rob.dixon@[EMAIL PROTECTED]
> wrote:
>  >> Chas. Owens wrote:
>  >>  > On Sat, Apr 19, 2008 at 1:03 PM, Rob Dixon <rob.dixon@[EMAIL PROTECTED]
>
wrote:
>  >>  > snip
>  >>  >>  foreach my $i (1 .. 9999) {
>  >>  >>   my $zfill = substr("0000$i", -4);
>  >>  >>   my $longer = "dbt${zfill}dsfg";
>  >>  >>   print $longer, "\n";
>  >>  >>  }
>  >>  >>
>  >>  >>  Rob
>  >>  > snip
>  >>  >
>  >>  > TIMTOWTDI fight!
>  >>  >
>  >>  > for my $i (1 .. 9999) {
>  >>  >     my $longer = "0" x (4 - length $i) . $i;
>  >>  >    print "$longer\n";
>  >>  > }
>  >>
>  >>  You're on!
>  >>
>  >>
>  >>  foreach my $i (1 .. 9999) {
>  >>   (my $longer = $i + 10000) =~ s/1(....)$/dbt$1dsfg/;
>  >>   print $longer, "\n";
>  >>  }
>  >>
>  >
>  > #!/usr/bin/perl
>  >
>  > use strict;
>  > use warnings;
>  >
>  > for my $i (1, 10, 100, 1000) {
>  >         chop(my $longer = reverse(10000 + $i));
>  >         print scalar reverse($longer), "\n";
>  > }
>
>  You've changed the problem! If we're allowed to solve that one instead,
>  then I submit

I have not:

10000 + 1 = 10001, reverse(10001) = 10001, chop(10001) = a return of 1
and $longer holding 1000, scalar reverse(1000) = 0001
10000 + 10 = 10010, reverse(10010) = 01001, chop(01001) = a return of
1 and $longer holding 0100, scalar reverse(0100) = 0010
10000 + 100 = 10100, reverse(10100) = 00101, chop(00101) = a return of
1 and $longer holding 0010, scalar reverse(0010) = 0100
10000 + 1000 = 11000, reverse(11000) = 00011, chop(00011) = a return
of 1 and $longer holding 0001, scalar reverse(0001) = 1000

>
>   my $longer = reverse '0000' | reverse "$i";
>
>  Rob
>

for my $i (1, 10, 100, 1000) {
        print "000$i" =~ /(....)$/, "\n";
}


-- 
Chas. Owens
wonkden.net
The most im****tant skill a programmer can have is the ability to read.
 




 12 Posts in Topic:
Substitute Variably hort string into long string at Right Justif
pgn674@[EMAIL PROTECTED]   2008-04-17 01:14:31 
Re: Substitute Variably hort string into long string at Right Ju
chas.owens@[EMAIL PROTECT  2008-04-17 07:48:18 
Re: Substitute Variably hort string into long string at Right Ju
Jenda@[EMAIL PROTECTED]   2008-04-17 15:07:51 
Re: Substitute Variably hort string into long string at Right
pgn674@[EMAIL PROTECTED]   2008-04-17 16:51:10 
Re: Substitute Variably hort string into long string at Right Ju
rob.dixon@[EMAIL PROTECTE  2008-04-18 18:38:32 
Re: Substitute Variably hort string into long string at Right Ju
chas.owens@[EMAIL PROTECT  2008-04-19 13:12:16 
Re: Substitute Variably hort string into long string at Right Ju
rob.dixon@[EMAIL PROTECTE  2008-04-19 18:57:16 
Re: Substitute Variably hort string into long string at Right Ju
rob.dixon@[EMAIL PROTECTE  2008-04-19 18:03:45 
Re: Substitute Variably hort string into long string at Right
Uri Guttman <uri@[EMAI  2008-04-19 17:49:16 
Re: Substitute Variably hort string into long string at Right Ju
chas.owens@[EMAIL PROTECT  2008-04-19 14:53:06 
Re: Substitute Variably hort string into long string at Right Ju
rob.dixon@[EMAIL PROTECTE  2008-04-20 12:38:03 
Re: Substitute Variably hort string into long string at Right Ju
chas.owens@[EMAIL PROTECT  2008-04-20 10:18:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 17:50:32 CST 2008.