Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 13th, 2012, 12:19 PM
Hanxiang Hanxiang is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 1 Hanxiang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 3 sec
Reputation Power: 0
Help, For the rndpass.pl

I want to have Usage:
rndpassword [-v] [-t <type>] [-n <length>]

Options:
-v version
-t set character type (default: num)
-n set length (default: 8 byte)

Types: (output sample)
alnum 0xaVbi3O2Lz8E69s # 0..9 a..z A..Z
num 12378654 # 0..9

Examples:
shell> rndpassword <CR>
Password: 01234567
shell>

shell> rndpassword -n 16 <CR>
Password: 0123456789012345
shell>

shell> rndpassword -t alnum -n 4 <CR>
Password: abcd
shell>

shell> rndpassword -v <CR>
Version: 0.1
Password: 01234567
shell>

shell> rndpassword -n 3 -v <CR>
Version: 0.1
Password: 012
shell>

shell> rndpassword -n 3 -v -n 4 <CR>
Version: 0.1
Password: 0123
shell>
but my code just doesnt work perfectlty
Quote:
#!/usr/bin/perl # password generator client (PROTOTYPE)
# Peter Walsh csci 265
use warnings "all";
use Getopt::Std;
use IO::Socket; $sock = new IO::Socket::INET (
PeerAddr => '192.168.18.21',
PeerPort => '7071',
Proto => 'tcp' );
die "Could not create socket: $!\n" unless $sock;

Getopt::Std::getopts 'v:t:n' => my $opt = {};

if( defined $opt->{n} and defined $opt->{t} )
{ printf STDERR "notice: -n and -t options are exclusive.\n";
exit 1; }
# length my $n = 8;
if (defined $opt->{v} || 'default')
{ print "version:0.1\n"; }

if( defined $opt->{n} )

{ print $sock "1:x&num:8\n" }
if (defined $opt->{t} ) {
print $sock "1:num:6\n"; }
while (1) { $pass = <$sock>;
chop $pass;
last if $pass eq "CLOSE";
print "$pass \n"; }

Last edited by Hanxiang : October 13th, 2012 at 12:21 PM. Reason: fix code

Reply With Quote
  #2  
Old October 13th, 2012, 01:32 PM
FishMonger FishMonger is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2009
Posts: 1,645 FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 21 h 53 m 52 sec
Reputation Power: 1170
Quote:
my code just doesnt work perfectlty

That's a very poor problem statement.

In what way does it not "work perfectlty"?

What is it doing which it shouldn't?

What is it not doing which it should be doing?

Please add the strict pragma
Code:
use strict;
and fix the problems that it points out.

IMO, Getopt::Long would be a better choice than Getopt::Std.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Help, For the rndpass.pl

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap