User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » incrementing a character in perl? Page [1]  
Excoriator
Suspended
10214 Posts
user info
edit post

I have a one character string that i want to increment through the alphabet - how can I do that?

11/10/2006 10:20:22 PM

skokiaan
All American
26447 Posts
user info
edit post

use magic. Since I don't know any perl, I would do


@letters = {'a','b',.....'z'};

foreach $letter ( @letters )
{
print $letter;
}


you get the idea. I have absolutely no doubt that there is a way to do this in perl in one short line.


[Edited on November 10, 2006 at 10:38 PM. Reason : or use chr: http://tyby.bke.hu/perl/cookbook/ch01_05.htm]

11/10/2006 10:33:54 PM

Excoriator
Suspended
10214 Posts
user info
edit post

nah too much code

I have a string var that I want to increment by one character only

at first it looked like $char++ would work but now it doesn't any more

[Edited on November 10, 2006 at 10:44 PM. Reason : s]

11/10/2006 10:44:02 PM

skokiaan
All American
26447 Posts
user info
edit post

^Did you even follow that link?

11/10/2006 11:13:14 PM

Excoriator
Suspended
10214 Posts
user info
edit post

good point - i just figured the link was describing the code you posted

got it. thanks.

11/10/2006 11:23:06 PM

 Message Boards » Tech Talk » incrementing a character in perl? Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.38 - our disclaimer.