Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find missing letters

Status
Not open for further replies.

vpalag

Programmer
Apr 28, 2002
11
IN
Hi,

I need to generate a list of letters that are missing between to alphabets. let's say my list should look like

B,C,D,E,F,G if I pass A and H.

Any ideas please let me know.
I appreciate the help.

alag
 
$_ = ...
if (! /A/) { # no A do something }
if (! /H/) { # no H do something }
# ... ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Is this what you want?
Code:
@List = &List("A", "H");
print "@List\n";

sub List($$) {
    my ($Start, $End) = @_;
    # ord - converts character to its ascii value
    my @Nums = ord($Start) + 1 .. ord($End) - 1;
    @RetChars = map(chr, @Nums); # Convert ascii list to character list
}
 
This would be the easiest way (opinion of course):

#===== CODE =====

$start = "A"; #test data
$end = "H"; #test data

(undef, @letters) = ($start .. $end) and pop @letters;

print @letters;

#================

Hope this helps.

--jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top