display unique number


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting display unique number
# 1  
Old 06-02-2008
display unique number

Hi,

how i can display all the unique number from my random number script below;

Code:
#!/usr/bin/perl
use strict;

my @alphanum = ( 'A' .. 'Z', 'a' .. 'z', 0 .. 9);
my $random = join('', map($alphanum[rand($#alphanum)],(1..5)));

print "$random\n";

Thank You.
# 2  
Old 06-02-2008
Looks like a homework, but still - what have you done so far, did you write this script ? Hint : check for existence of digit, then extract the unique ones. Look for perl regex, there are many examples in the forum.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Unique Number Identifying

I'm trying to solve the below problem for a number: Enter a number and if it has all unique digits print unique number else non-unique number. Eg: Input=123; Output=unique number Input=112; Output=Non-unique number The thing i tried is splitting the number into digits by using % operator... (2 Replies)
Discussion started by: Gautham
2 Replies

2. Shell Programming and Scripting

display unique words.

I am having a file with duplicate words how can I eliminate them ant,bat bat,cat cat a.txt | grep -bat | awk '{print $1}' expecting o/p as ant,bat,cat How can I display the output as ant,bat,cat in a single line and no duplicates exists. (2 Replies)
Discussion started by: shikshavarma
2 Replies

3. Shell Programming and Scripting

Concatenate lines with unique string AND number

In Bash using AWK or sed I need to convert the following file: ... numitem_tab0 =<p>1 KEYWORD</p><p>2 KEYWORD</p><p>3 KEYWORD</p><p>4 KEYWORD</p><p>5 KEYWORD</p>...<p>25 KEYWORD</p> subitem_tab0 =<p></p><p></p> ... numitem_tab6 =<p>1 KEYWORD</p><p>2 KEYWORD</p><p>3 KEYWORD</p><p>4 KEYWORD</p>... (2 Replies)
Discussion started by: pioavi
2 Replies

4. UNIX for Advanced & Expert Users

Count number of unique patterns from a log file

Hello Everyone I need your help in fixing this issue., I have a log file which has data of users logging in to an application. I want to search for a particular pattern in the log ISSessionValidated=N If this key word is found , the above 8 lines will contain the name of the user who's... (12 Replies)
Discussion started by: xtechkid
12 Replies

5. Programming

To display unique lines in a Program

I am new to C programming. I have been trying to display unique lines in a file from past two days. The problem is here, I have a file whose contents are, ras.beamtele.net ras.beamtele.net ras.beamtele.net ras.beamtele.net ras.beamtele.net ras.beamtele.net ras.beamtele.net... (1 Reply)
Discussion started by: Teju88
1 Replies

6. Shell Programming and Scripting

Finding the number of unique words in a file

find the number of unique words in a file using sort com- mand. (7 Replies)
Discussion started by: abhikamune
7 Replies

7. Shell Programming and Scripting

minimum number of unique key

input a 1 a 2 a -1 b 1 b 2 b 3 output a -1 b 1 Thanx ---------- Post updated at 09:42 PM ---------- Previous update was at 09:10 PM ---------- Ok I managed it (7 Replies)
Discussion started by: repinementer
7 Replies

8. Shell Programming and Scripting

Need to find Unique not used Number

Wrote a script to create a hidden account in OS X. It works perfect but I need to check if the UID is already in use before I tried to create the account. dscl . list /Users UniqueID | awk '{print $2}' | while read UIDS do if ; then echo "UID Is Already in USE" i=`expr "$2" - 1` echo... (4 Replies)
Discussion started by: elbombillo
4 Replies

9. Shell Programming and Scripting

unique number for a date

Hello, In korn-shell, how can I do to have an unique number for a date done. I want to use it to have the number of days between two dates. Thanks in advance. (4 Replies)
Discussion started by: madmat
4 Replies

10. UNIX for Dummies Questions & Answers

Directory Inode Number Not Unique

Hi, I know that inode for each file is unique, but is it the for the directory? So far I found different directories has the same inode nubmer when you do ls -i, could some one explain why? Thanks a lot. (9 Replies)
Discussion started by: nj302
9 Replies
Login or Register to Ask a Question