random string

2002-11-22 Thread rpayal
Hi,
I am not at all familar to perl. I want to write a small perl script
which will print a random string of atleast 8 characters. This string I
intend to use as password for my application.
I don't know perl at all. perl is in /usr/local/bin/perl
The script when invovked like should print,

#perl randon_string.pl
AQs1QsaL

etc.
Can please someone help in this?
Thanks a lot and bye.
With regards.

-Payal
-- 
---
Contact :-  Linux Success Stories : -
   www.geocities.com/rpayal99
---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: random string

2002-11-22 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
> 
> Hi,

Hello,

> I am not at all familar to perl. I want to write a small perl script
> which will print a random string of atleast 8 characters. This string I
> intend to use as password for my application.
> I don't know perl at all. perl is in /usr/local/bin/perl
> The script when invovked like should print,
> 
> #perl randon_string.pl
> AQs1QsaL
> 
> etc.
> Can please someone help in this?


# character set to choose from as per your example
my @chars = ( 'a' .. 'z', 'A' .. 'Z', 0 .. 9 );
# pick eight random characters from the array
my $string = join '', map $chars[ rand @chars ], 1 .. 8;



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: random string

2002-11-22 Thread rpayal
Hi,
Thanks for the mails all.
But I haven't got a sentence or even a word.
Please, I am looking for a *script* which will print a random string.
Please someone take trouble of putting the info. in a file so that I can
cut-paste it.
As, I said I know *nothing* of perl, nothing at all so all those
my @chars = ( 'a' .. 'z', 'A' .. 'Z', 0 .. 9 );
etc. are pretty useless to me, unless they are in a script form.

Thanks a lot in advance and bye.
With regards.
-Payal
p.s someone please mark a Cc to rpayal99 @ yahoo.com. This present email
address is having problems since last 4-5 hours.
-- 
---
Contact :-  Linux Success Stories : -
   www.geocities.com/rpayal99
---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: random string

2002-11-22 Thread david
[EMAIL PROTECTED] wrote:

> Hi,
> Thanks for the mails all.
> But I haven't got a sentence or even a word.
> Please, I am looking for a *script* which will print a random string.
> Please someone take trouble of putting the info. in a file so that I can
> cut-paste it.
> As, I said I know *nothing* of perl, nothing at all so all those
> my @chars = ( 'a' .. 'z', 'A' .. 'Z', 0 .. 9 );
> etc. are pretty useless to me, unless they are in a script form.
> 

why would you want to use Perl in the first place? no other alternatives?
your problem is straight forward and if you are not familiar with Perl, you 
might want to go with another language. i don't think it will be that hard 
right? c/c++? java? shell script?

david

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: random string

2002-11-22 Thread rpayal
Hi,
> why would you want to use Perl in the first place? no other alternatives?
Maybe, But I am not a coder at all.
> your problem is straight forward and if you are not familiar with Perl, you 
> might want to go with another language. i don't think it will be that hard 
> right? c/c++? java? shell script?
hehehehee, if I knew that then i would have made it myself. I know a bit
of shell scripting, but I never knew that one can generate random string
in shell.
Can you help me do it in perl?
My requirement is very very simple. To write a program which will
generate *just* a random string of say 8 characters. Characters allowed
will be - [a-z] [A-Z] [0-9]. Can it be done?
Thanks and bye.
-Payal

-- 
---
Contact :-  Linux Success Stories : -
   www.geocities.com/rpayal99
---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: random string

2002-11-22 Thread Tanton Gibbs
You should look at the rand function

perldoc -f rand

also,

perldoc perlop

and look for the . operator and .= operator as well as the .. range
operator.

If that doesn't work, try asking your professor for help.

Tanton
- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 22, 2002 9:32 PM
Subject: Re: random string


> Hi,
> > why would you want to use Perl in the first place? no other
alternatives?
> Maybe, But I am not a coder at all.
> > your problem is straight forward and if you are not familiar with Perl,
you
> > might want to go with another language. i don't think it will be that
hard
> > right? c/c++? java? shell script?
> hehehehee, if I knew that then i would have made it myself. I know a bit
> of shell scripting, but I never knew that one can generate random string
> in shell.
> Can you help me do it in perl?
> My requirement is very very simple. To write a program which will
> generate *just* a random string of say 8 characters. Characters allowed
> will be - [a-z] [A-Z] [0-9]. Can it be done?
> Thanks and bye.
> -Payal
>
> --
> ---
> Contact :- Linux Success Stories : -
>  www.geocities.com/rpayal99
> ---
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: random string

2002-11-23 Thread Paul Johnson
On Sat, Nov 23, 2002 at 08:02:00AM +0530, [EMAIL PROTECTED] wrote:
> Hi,
> > why would you want to use Perl in the first place? no other alternatives?
> Maybe, But I am not a coder at all.
> > your problem is straight forward and if you are not familiar with Perl, you 
> > might want to go with another language. i don't think it will be that hard 
> > right? c/c++? java? shell script?
> hehehehee, if I knew that then i would have made it myself. I know a bit
> of shell scripting, but I never knew that one can generate random string
> in shell.
> Can you help me do it in perl?
> My requirement is very very simple. To write a program which will
> generate *just* a random string of say 8 characters. Characters allowed
> will be - [a-z] [A-Z] [0-9]. Can it be done?

By now you will probably have worked out that this community is very
happy to help people of any ability to improve their Perl skills, but is
rather reluctant just to hand out ready-made solutions.  This is as it
should be - if you want someone to do work for you you generally pay
them in some way.  Most of the regular posters on this list could
probably knock up a simple solution and post it with very little effort.
I could certainly do so in a fraction of the time it will take to write
this mail.  So why hasn't anyone just done that?

Well, I suppose it comes down to the payment aspect.  Perl is free, as
are all the modules on CPAN.  For many of us Perl has made our lives
considerably easier and more fun.  How do we repay the people who have
created Perl?  Some pay money - https://donate.perl-foundation.org/
Some help to work on Perl development.  Some contribute to CPAN.  Some
help others to learn in fora such as this.  Some don't.

In your particular situation things started off well.

On Fri, Nov 22, 2002 at 04:01:39PM +0530, [EMAIL PROTECTED] wrote:
> I am not at all familar to perl. I want to write a small perl script

That's great.  You want to write the script, but need help.  You'll find
plenty here.  And you got a reply:

On Fri, Nov 22, 2002 at 03:10:47AM -0800, John W. Krahn wrote:
> # character set to choose from as per your example
> my @chars = ( 'a' .. 'z', 'A' .. 'Z', 0 .. 9 );
> # pick eight random characters from the array
> my $string = join '', map $chars[ rand @chars ], 1 .. 8;

But then things took a turn for the worse.  You told us that you didn't
know what to do with the advice and just wanted a solution.  I decided
to ignore your request, but since you were persistent I poked around
your web site, and that's what has prompted me to reply.

It looks as though you have already taught yourself a number of skills,
including the ability to set up and maintain linux systems, networking,
mail, vi and others.  It seems that Perl could be a useful tool for you,
and that you are willing and have the ability to work things out for
yourself.

It's been a while since I learnt Perl, and the resources now available
weren't then, so I thought I'd see how easy it is for a determined
beginner to learn Perl.  Based on the name of this list, my first stop
was www.perl.org.  Right at the top is a like to learn.perl.org, and the
first line there points us to perlintro.  This is a nice document which
will get you started.

This document, along with John's reply will get you to where you want to
be, at least for now.  After a brief introduction you will learn how to
run a Perl program, the basics of syntax, variable types and a little
more.

So, read that document, and make sure you know how to run a Perl
program, if you don't already.

Then look at John's reply.  This will form the bulk of your program.  It
would be good to understand it, especially if you are using it to
generate passwords, but for now you might just want to cut-and-paste it.

After those two lines, you will have the password in $string.  Now you
just need to print it.  You will find how to do that near the top of
perlintro.

If all goes well, you should have written your first Perl program.  This
might be the start of a wonderful journey for you.  There is a lot to
learn, but it doesn't have to be learnt all at once - or even at all.
There are plenty of resources available, and this list will be happy to
help if you can show that you are willing to help yourself.  With any
luck you will improve yourself and will later be able to contribute back
to the community in some way.

Come back to the list with any questions, or let us know of your
success.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: random string

2002-11-23 Thread rpayal
Hi,
> By now you will probably have worked out that this community is very
> happy to help people of any ability to improve their Perl skills, but is
> rather reluctant just to hand out ready-made solutions.  This is as it
*please read the mail in full before commenting on *anything*. *
Yep, but this time I needed a ready made solution. This random string
generation program is a part of a big program written in bash by me. I
just couldn't spend time learning perl for this. I had to get this ready
ASAP. I asked if someone knew how to do this in bash and had any
pointers, but no one responded.
> I could certainly do so in a fraction of the time it will take to write
> this mail.  So why hasn't anyone just done that?
I have 3 solutions mailed privately. I will explain why they mailed me
privately in a article I intend to put on web.
> Some help to work on Perl development.  Some contribute to CPAN.  Some
> help others to learn in fora such as this.  Some don't.
Many, many more give unwanted advice. Believe me, I am not saying about
this list. This list is unusually friendly, but this is an attitude I
found in many people. 
Some people say that I have to pay for writing the script. Well, I don't
have that kind of money. Even $50 they ask for is big amount in India.
I mean a odd-job man can support a family of 3 for 3 months easily here
on that money. And I am also going to utilize this script for a school
project here which will be done free of cost.
> But then things took a turn for the worse.  You told us that you didn't
> know what to do with the advice and just wanted a solution.  I decided
Yes, I spoke the truth. I couldn't make heads and tails out of this. If
you had given only John's solution and a mail in Hebrew, 
I would have not able to make out the difference ;-)
> It looks as though you have already taught yourself a number of skills,
> including the ability to set up and maintain linux systems, networking,
> mail, vi and others.  It seems that Perl could be a useful tool for you,
yes, I *love* perl. Infact, I was inspired to learn Linux when i read a
perl success story by Chris Benson. (btw, did you sign the guest-book
:):):))
> and that you are willing and have the ability to work things out for
> yourself.
But python guys are insisting I start with Python which they say have
more systematic approach. Now, i am caught in a situation where I like
perl but cannot muster courage to learn it and and don't know if
there are people around to help Vs. python without any particular fondness,
yet am asked to learn it by people over the globe who have helped me a lot.
A Catch-22 case :)
To boil it down. I know Gurus in python and no one in perl. Whether they
will help me or not is a different question. But their mere presence
assures me. Forgive me for saying so, but your mail would have a more
impact if you had given me the solution along with the mail. Only this
advice leads a newbie to believe that perl is difficult
What I was asking was simple according to me
and when I didn't receive any concrete answers I was led to believe that
it cannot be accomplished in perl easily even by advanced users.

> was www.perl.org.  Right at the top is a like to learn.perl.org, and the
> first line there points us to perlintro.  This is a nice document which
> will get you started.
Ok. Now, in my TODO list.
> If all goes well, you should have written your first Perl program.  This
> might be the start of a wonderful journey for you.  There is a lot to
amen!!! I wish I can write col perl programs. I will be instant hit
here, especially with guys ;-)

Now for some shameless self promotion. 
Please visit the site www.geocities.com/rpayal99 and sign the
guest-book. I promised myself I will make it public once I have atleast
10 signs there or 1 sign of Linus Thorwalds whichever is earlier.

Thanks a lot for the help and bye.
-Payal

-- 
---
Contact :-  Linux Success Stories : -
   www.geocities.com/rpayal99
---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: random string

2002-11-23 Thread rpayal
Hi,
Thanks for the mail.
> perldoc -f rand
> also,
> perldoc perlop
Thanks, I will.
> If that doesn't work, try asking your professor for help.
hehehehehee, I don't have any professor. I am not a student and I never
was a computer student. I am just a artist in fashion designing who does
Linux as a hobby.
Visit www.geocities.com/rpayal99 to know more.
Thanks a lot again and bye.
With regards.
-Payal

-- 
---
Contact :-  Linux Success Stories : -
   www.geocities.com/rpayal99
---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: random string

2002-11-25 Thread Aman Thind

Miss P > Some people say that I have to pay for writing the script. 

Me > ???what are such ppl doing here anyway??? we're
all here to help each other out aren't we ?
 these ppl are requested to put their hoardings elsewhere...
 pay and that too for a beginner exercise...hilarious :D
 
   
Miss P > I couldn't make heads and tails out of this. If you had given only
John's solution and a mail in Hebrew, 
I would have not able to make out the difference ;-)

Me > hmmm. I personally believe John's solution was as elegant
as they come.
 Probably your predicament is you don't know how to use it.

Just copy-paste the following in a file and save it with the extension .pl

#---

open PASWDFILE , ">pswdfile" # you may want to replace what's in the quotes 
 #with the exact path of the pswd file you want
to generate

# character set to choose from as per your example
my @chars = ( 'a' .. 'z', 'A' .. 'Z', 0 .. 9 );

# pick eight random characters from the array
my $string = join '', map $chars[ rand @chars ], 1 .. 8;#don't bother with
the howz and whyz of this line...just use it ;)

print $string; #just so that you know what is being written into
the file...comment it out later.
print PASWDFILE , $string; #write the random string of length 8 in the file
#---


Your application could then read this generated file and use the
randomstring as you desire.
Once it's contents have been read , do unlink(delete) this file using your
bash program.


Miss P > and when I didn't receive any concrete answers I was led to believe
that
 it cannot be accomplished in perl easily even by advanced users.

Me > hope your belief has been belied :)


Miss P >I wish I can write col perl programs. I will be instant hit
here, especially with guys ;-)

Me > ... only if you write real *beautiful* code and have read the perl
*Cook*book  :D  


-aman
---
Nishkaam Sevabhaav
---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: random string

2002-11-25 Thread '[EMAIL PROTECTED]'
Hi,
Thanks for the mail.
> Just copy-paste the following in a file and save it with the extension .pl
I am giving the script I put in my file. I have removed all comments and
adjusted the lines. The script now reads,

#!/usr/local/bin/perl
open PASWDFILE , ">pswdfile"
my @chars = ( 'a' .. 'z', 'A' .. 'Z', 0 .. 9 );
my $string = join '', map $chars[ rand @chars ], 1 .. 8;
print $string;
print PASWDFILE , $string;

#perl random1.pl
syntax error at random1.pl line 3, near "my "
No comma allowed after filehandle at random1.pl line 6.

> Miss P > and when I didn't receive any concrete answers I was led to believe
> that it cannot be accomplished in perl easily even by advanced users.
> Me > hope your belief has been belied :)
Not really. I still cannot get the above solution working. (though I have 2 
working solutions)

> Me > ... only if you write real *beautiful* code and have read the perl
> *Cook*book  :D  
Perl Cookbook? What is that?

Thanks and bye.
-Payal
-- 
---
Contact :-  Linux Success Stories : -
   www.geocities.com/rpayal99
---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: random string

2002-11-25 Thread Halkyard, Jim


You are missing a semi-colon at the end of line 2, and remove the comma
between the filehandle and $string in line 6.

That should sort your problems.

The Perl Cookbook is one of series of books on Perl published by O'Reilly.
www.oreilly.com, generally well respected and very popular. If you start
with Learning Perl you can't go far wrong IMHO.


Jim

-Original Message-
From: '[EMAIL PROTECTED]' [mailto:[EMAIL PROTECTED]]
Sent: 25 November 2002 16:58
To: [EMAIL PROTECTED]
Subject: Re: random string


Hi,
Thanks for the mail.
> Just copy-paste the following in a file and save it with the extension .pl
I am giving the script I put in my file. I have removed all comments and
adjusted the lines. The script now reads,

#!/usr/local/bin/perl
open PASWDFILE , ">pswdfile"
my @chars = ( 'a' .. 'z', 'A' .. 'Z', 0 .. 9 );
my $string = join '', map $chars[ rand @chars ], 1 .. 8;
print $string;
print PASWDFILE , $string;

#perl random1.pl
syntax error at random1.pl line 3, near "my "
No comma allowed after filehandle at random1.pl line 6.

> Miss P > and when I didn't receive any concrete answers I was led to
believe
> that it cannot be accomplished in perl easily even by advanced users.
> Me > hope your belief has been belied :)
Not really. I still cannot get the above solution working. (though I have 2 
working solutions)

> Me > ... only if you write real *beautiful* code and have read the perl
> *Cook*book  :D  
Perl Cookbook? What is that?

Thanks and bye.
-Payal
-- 
---
Contact :-  Linux Success Stories : -
   www.geocities.com/rpayal99
---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: random string

2002-11-25 Thread '[EMAIL PROTECTED]'
> You are missing a semi-colon at the end of line 2, and remove the comma
> between the filehandle and $string in line 6.
Thanks it works now.
> The Perl Cookbook is one of series of books on Perl published by O'Reilly.
> www.oreilly.com, generally well respected and very popular. If you start
Is it recommended for TOTAL newbies?

Thanks and bye.
-Payal

-- 
---
Contact :-  Linux Success Stories : -
   www.geocities.com/rpayal99
---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: random string

2002-11-25 Thread Halkyard, Jim


Yes, I started with 'Learning Perl' as a complete novice as I'm sure many
other people have.

There are lots of well explained examples, a test yourself questions section
at the end of each chapter. Sample answers are provided and discussed in
Appendix A.

Jim

-Original Message-
From: '[EMAIL PROTECTED]' [mailto:[EMAIL PROTECTED]]
Sent: 25 November 2002 17:58
To: [EMAIL PROTECTED]
Subject: Re: random string


> You are missing a semi-colon at the end of line 2, and remove the comma
> between the filehandle and $string in line 6.
Thanks it works now.
> The Perl Cookbook is one of series of books on Perl published by O'Reilly.
> www.oreilly.com, generally well respected and very popular. If you start
Is it recommended for TOTAL newbies?

Thanks and bye.
-Payal

-- 
---
Contact :-  Linux Success Stories : -
   www.geocities.com/rpayal99
---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: random string

2002-11-26 Thread Paul Johnson
On Sat, Nov 23, 2002 at 07:46:57PM +0530, [EMAIL PROTECTED] wrote:
> Hi,
> > By now you will probably have worked out that this community is very
> > happy to help people of any ability to improve their Perl skills, but is
> > rather reluctant just to hand out ready-made solutions.  This is as it
> *please read the mail in full before commenting on *anything*. *

Of course.  And re-read, and thought about for quite a while ;-)

> Yep, but this time I needed a ready made solution. This random string
> generation program is a part of a big program written in bash by me. I
> just couldn't spend time learning perl for this. I had to get this ready
> ASAP. I asked if someone knew how to do this in bash and had any
> pointers, but no one responded.
> > I could certainly do so in a fraction of the time it will take to write
> > this mail.  So why hasn't anyone just done that?
> I have 3 solutions mailed privately. I will explain why they mailed me
> privately in a article I intend to put on web.

I will be interested to read it.

> > Some help to work on Perl development.  Some contribute to CPAN.  Some
> > help others to learn in fora such as this.  Some don't.
> Many, many more give unwanted advice. Believe me, I am not saying about
> this list. This list is unusually friendly, but this is an attitude I
> found in many people. 
> Some people say that I have to pay for writing the script. Well, I don't
> have that kind of money. Even $50 they ask for is big amount in India.
> I mean a odd-job man can support a family of 3 for 3 months easily here
> on that money. And I am also going to utilize this script for a school
> project here which will be done free of cost.

I think that if you had been able to explain your situation a little
more, telling us why you needed the program, then there might have been
a little less confusion.  People here are very helpful, but don't like
to feel taken advantage of.  Part of this might be a language problem.
I'm assuming English is not your first language, but you write it well
enough that I am not sure about this ;-)

> > But then things took a turn for the worse.  You told us that you didn't
> > know what to do with the advice and just wanted a solution.  I decided
> Yes, I spoke the truth. I couldn't make heads and tails out of this. If
> you had given only John's solution and a mail in Hebrew, 
> I would have not able to make out the difference ;-)
> > It looks as though you have already taught yourself a number of skills,
> > including the ability to set up and maintain linux systems, networking,
> > mail, vi and others.  It seems that Perl could be a useful tool for you,
> yes, I *love* perl. Infact, I was inspired to learn Linux when i read a
> perl success story by Chris Benson. (btw, did you sign the guest-book
> :):):))

I don't normally do that, but on this occasion I have made an exception :-)

> > and that you are willing and have the ability to work things out for
> > yourself.
> But python guys are insisting I start with Python which they say have
> more systematic approach. Now, i am caught in a situation where I like
> perl but cannot muster courage to learn it and and don't know if
> there are people around to help Vs. python without any particular fondness,
> yet am asked to learn it by people over the globe who have helped me a lot.
> A Catch-22 case :)

I won't try to dissuade you from learning Python.  Perl, Python and Ruby
are all nice languages occupying a similar problem space.  Different
people prefer one over the others.  Some people like more than one.
Language wars are unproductive.

> To boil it down. I know Gurus in python and no one in perl. Whether they
> will help me or not is a different question. But their mere presence
> assures me. Forgive me for saying so, but your mail would have a more
> impact if you had given me the solution along with the mail. Only this

I seriously considered tacking the solution on to the end.  I wrote it
and tested it to make sure I hadn't made any mistakes in my advice.  In
the end I decided not to send it because it was only four lines long.

The first line is the shebang line.  I thought that since you could
write a shell script this wouldn't be a problem for you.  Also, what was
required was descibed in the link I sent.

The next two lines John had already sent you, and they were correct.

The final line was just to print out the results.  I thought this would
not be too hard for you to figure out, and was also described early in
the link I sent.  I also thought it might give you satisfaction to be
able to do a little research, put the pieces together and solve the
problem.

Had you explained some of the things you did in this mail, I would have
added t

Re: random string

2002-11-27 Thread Payal Rathod
On Wed, Nov 27, 2002 at 12:18:06AM +0100, Paul Johnson wrote:
> > privately in a article I intend to put on web.
> I will be interested to read it.
I will mail the URL to the list when it is ready ;-)
> I think that if you had been able to explain your situation a little
> more, telling us why you needed the program, then there might have been
oh sorry! But I had a reason. I was and I am going to use that script
with a pack of scripts on qmail, getmail and few other utilities. I
assumed that not all people here knew about these softwares in detail. So as
not to confuse them, I purposely didn't give more info. I just said I
want to generate a random string of 8 character (or more). 
> to feel taken advantage of.  Part of this might be a language problem.
> I'm assuming English is not your first language, but you write it well
> enough that I am not sure about this ;-)
No it is not. But I can write it OK. Studied it for 5 years. Btw, I know
7 languages and 10 dialects :):):)
> are all nice languages occupying a similar problem space.  Different
> people prefer one over the others.  Some people like more than one.
best answered later.

> added the solution at the end.  If you still want it, please ask, but it
> sounds as though you have the problem solved now.
yes, but it does not bother me to have one more solution. The more the
merrier :)
> 
> > it cannot be accomplished in perl easily even by advanced users.
> 
> I hope you see now that that is not the case.
Somewhat yes, but frankly not exactly.

> I think that learning Perl, or even Python or Ruby, would be a great
Someone please answer this in one word. Which language do I start with,
Choices are C, Python, Perl?

> search engines will pick it up.  I think you've already made it public :-)
I am really shameless nah? :)
> 
> http://www.pjcj.net
This does not work since last 12 hours atleast.

-- 
---
Contact :-  Linux Success Stories : -
   www.geocities.com/rpayal99
---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: random string

2002-11-27 Thread wiggins

> Someone please answer this in one word. Which language do I start with,
> Choices are C, Python, Perl?
> 

"Can't." That is one word :-), aka there is no way to answer your question in one word.

Besides you are posting on a perl list, so of course the answer is: Perl.

Honestly it totally depends on your purposes, goals, resources, etc. If you are young 
and have the time, and don't need to get something done, C will be invaluable and will 
show you the low level that you can abstract to Perl later. Python is a whole other 
ball game, but once you cover OOP it shouldn't be a problem.

I started my 2nd year in college programming as an economics major, which is late by 
most standards here in the US. I was working at the time and saw Perl as my way to 
advance in the web app area in which my company was working. If I had the time and had 
been able to get the training and resources I would love to hack in C, it is still my 
goal to make more of the transition. My low level knowledge comes from having run 
Linux for 5 years, and having the desire to learn as much as I possibly can about good 
coding practices and algorithms, but I do not have the knowledge of C, make, and 
compiled languages in particular that I would like to. It is nice to work in a memory 
managed environment, but Perl lets you get away with a whole lot, not to mention loose 
typing, etc, etc, etc.  On the other hand I know C coders that can't put together a 
web page, let alone fire up a CGI, or even know what an SQL statement looks like. But 
then I know a number of web appers that are out of work n!
owadays, but rarely have met an unemployed C programmer.

I would suggest pointing yourself in the direction that feels most comfortable and 
live life without any regrets...

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: random string

2002-11-27 Thread Mystik Gotan
It is just the enviroment where you're work. Perl is mostly used on Internet 
in association with CGI and Lunix. C/C++ and Python are both used as 
programming languages, mostly on whatever platform you want.
These are about the 3 most difficult languages you can imagine.

When trying to make some programs, usefull for windows, but not too hard, 
use Visual Basic, for example. For more difficult tasks, use C/Python. For 
Linux, shell, use Perl. For easy, dynamic and lots of form processing, use 
PHP. For more diffucult tasks, use Perl, as it can associate C with it and 
the strength of Modules, for example ImageMagick (make thumbnails, effects, 
etcs). I suggest you search out what's best for you. You don't wand ending 
up knowing quite some good Perl but you are not using it's strength and you 
could've learned PHP instead.



--
Bob Erinkveld (Webmaster Insane Hosts)
www.insane-hosts.net
MSN: [EMAIL PROTECTED]





From: [EMAIL PROTECTED]
To: "Payal Rathod" <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
Subject: Re: random string
Date: Wed, 27 Nov 2002 11:04:28 -0600

> Someone please answer this in one word. Which language do I start with,
> Choices are C, Python, Perl?
>

"Can't." That is one word :-), aka there is no way to answer your question 
in one word.

Besides you are posting on a perl list, so of course the answer is: Perl.

Honestly it totally depends on your purposes, goals, resources, etc. If you 
are young and have the time, and don't need to get something done, C will 
be invaluable and will show you the low level that you can abstract to Perl 
later. Python is a whole other ball game, but once you cover OOP it 
shouldn't be a problem.

I started my 2nd year in college programming as an economics major, which 
is late by most standards here in the US. I was working at the time and saw 
Perl as my way to advance in the web app area in which my company was 
working. If I had the time and had been able to get the training and 
resources I would love to hack in C, it is still my goal to make more of 
the transition. My low level knowledge comes from having run Linux for 5 
years, and having the desire to learn as much as I possibly can about good 
coding practices and algorithms, but I do not have the knowledge of C, 
make, and compiled languages in particular that I would like to. It is nice 
to work in a memory managed environment, but Perl lets you get away with a 
whole lot, not to mention loose typing, etc, etc, etc.  On the other hand I 
know C coders that can't put together a web page, let alone fire up a CGI, 
or even know what an SQL statement looks like. But then I know a number of 
web appers that are out of work n!
owadays, but rarely have met an unemployed C programmer.

I would suggest pointing yourself in the direction that feels most 
comfortable and live life without any regrets...

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


_
MSN Zoeken, voor duidelijke zoekresultaten! 
http://search.msn.nl/worldwide.asp


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Help creating a random string in Perl

2007-06-12 Thread p46921x

Hello, this is perl.beginners and I am really a beginner. This is also
my first Google group post so if I am in the wrong group, I am sorry.

I need to create a random combination of n-1 characters in a source
string. For example if the string is ABcDeFG (7 characters)
* I want to execute my perl script and get ABDeFG (6 characters)
* I execute my perl script a second time and get GABcDe (6 characters)
* I do it a third time and get AcBeDG (6 characters)
* etc

Also

1. Only characters in the source string are in the random string
meaning if Z is not in my source string, it will not be in my random
string. If A and B are in the source string, then at least one of them
will be in the random string.
2. Each source string will only contain one of the same characters, ie
ABcDeFG is a valid source string but  there will be no source strings
like ABBDeFG  (as it contains two "B"s).
3. Each random string has one less character than the source string,
ie the source string ABcDeFG has 7 characters but the random strings
ABDeFG and GABcDe and AcBeDG have 6 characters.

I can see how to generate a random number between 0 and 6 (meaning I
can pick one of the 7 characters in my source string) by using "print
int(rand(6))",  but I don't know where to being on the second and
third and fourth characters to and check that the random number hasn't
already been chosen.


Any help would be welcome. The more cryptic the better as it will
force me to understand what the Perl does ;)

Thank you
Richard

ps: I hope you don't mind but because I don't want spam, I have
created this email address specifically to post to Google groups. If
you are going to reply and I hope you do, please post to the Google
group as my email address will not be monitored.

ps: This isn't for school, it's sort of for fun for a program I am
writing to do crosswords.

ps: When I type perl - version, I see this as my version number
"v5.8.8 built for i486-linux-gnu-thread-multi".

ps: I have "Learning Perl 4th edition from Randal Schwartz". It is a
good book but doesn't describe the type of things I need to do. I have
access to Google but haven't been able to search a good link for the
type of random string code to work from for my problem.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Help creating a random string in Perl

2007-06-12 Thread Brown, Rodrick

Look at crypt();
$ perldoc -f crypt is a good  

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 12, 2007 3:39 PM
To: beginners@perl.org
Subject: Help creating a random string in Perl


Hello, this is perl.beginners and I am really a beginner. This is also
my first Google group post so if I am in the wrong group, I am sorry.

I need to create a random combination of n-1 characters in a source
string. For example if the string is ABcDeFG (7 characters)
* I want to execute my perl script and get ABDeFG (6 characters)
* I execute my perl script a second time and get GABcDe (6 characters)
* I do it a third time and get AcBeDG (6 characters)
* etc

Also

1. Only characters in the source string are in the random string meaning
if Z is not in my source string, it will not be in my random string. If
A and B are in the source string, then at least one of them will be in
the random string.
2. Each source string will only contain one of the same characters, ie
ABcDeFG is a valid source string but  there will be no source strings
like ABBDeFG  (as it contains two "B"s).
3. Each random string has one less character than the source string, ie
the source string ABcDeFG has 7 characters but the random strings ABDeFG
and GABcDe and AcBeDG have 6 characters.

I can see how to generate a random number between 0 and 6 (meaning I can
pick one of the 7 characters in my source string) by using "print
int(rand(6))",  but I don't know where to being on the second and third
and fourth characters to and check that the random number hasn't already
been chosen.


Any help would be welcome. The more cryptic the better as it will force
me to understand what the Perl does ;)

Thank you
Richard

ps: I hope you don't mind but because I don't want spam, I have created
this email address specifically to post to Google groups. If you are
going to reply and I hope you do, please post to the Google group as my
email address will not be monitored.

ps: This isn't for school, it's sort of for fun for a program I am
writing to do crosswords.

ps: When I type perl - version, I see this as my version number
"v5.8.8 built for i486-linux-gnu-thread-multi".

ps: I have "Learning Perl 4th edition from Randal Schwartz". It is a
good book but doesn't describe the type of things I need to do. I have
access to Google but haven't been able to search a good link for the
type of random string code to work from for my problem.


--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/



- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
- - - -

This message is intended only for the personal and confidential use of the 
designated recipient(s) named above.  If you are not the intended recipient of 
this message you are hereby notified that any review, dissemination, 
distribution or copying of this message is strictly prohibited.  This 
communication is for information purposes only and should not be regarded as an 
offer to sell or as a solicitation of an offer to buy any financial product, an 
official confirmation of any transaction, or as an official statement of Lehman 
Brothers.  Email transmission cannot be guaranteed to be secure or error-free.  
Therefore, we do not represent that this information is complete or accurate 
and it should not be relied upon as such.  All information is subject to change 
without notice.


IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within this 
communication (including any attachments) is not intended or written to be used 
and cannot be used for the purpose of (i) avoiding U.S. tax related penalties 
or (ii) promoting, marketing or recommending to another party any transaction 
or matter addressed herein.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Help creating a random string in Perl

2007-06-12 Thread Chas Owens

On 6/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
snip

I can see how to generate a random number between 0 and 6 (meaning I
can pick one of the 7 characters in my source string) by using "print
int(rand(6))",  but I don't know where to being on the second and
third and fourth characters to and check that the random number hasn't
already been chosen.

snip

What you are describing sounds like it would be best implemented by
1 breaking the the string into individual characters and storing them
in an array
2 shuffling the array
3 joining all but the last element of the array

Breaking a string into its characters in Perl is easy

my $str = "1234567";
my @a  = split //, $str;

Shuffling an array is easy as well.  Let's use Knuth's* shuffle
algorithm.  The idea here is to swap the current cell with some cell
that has not yet been processed.  So, the first cell can be swapped
with any other cell, the second cell can be swapped with any cell
other than the first, the third can swapped with any but the first and
second, and so on.  This will result in a shuffled array where any
permutation is equally likely**.

for my $i (0 .. $#a) {
   my $r = $i + int rand(@a - $i);
   @a[$i, $r] = @a[$r, $i];
}

Now that we have permuted the array we can turn a subset of it back
into a string and print it.

$str = join '', @a[0 .. $#a - 1];
print "$str\n";

And here it is put all together with a loop

#!/usr/bin/perl

use strict;
use warnings;

my $str = "ABCDEFG";
print "$str\n";

while (length($str) > 1) {
   my @a = split //, $str;
   for my $i (0 .. $#a) {
   my $r = $i + int rand(@a - $i);
   @a[$i, $r] = @a[$r, $i];
   }
   $str = join '', @a[0 .. $#a - 1];
   print "$str\n";
}

* also known as the Fisher-Yates shuffle
** given a sufficiently good RNG

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Help creating a random string in Perl

2007-06-12 Thread Randal L. Schwartz
>>>>> "p46921x" == p46921x  <[EMAIL PROTECTED]> writes:

p46921x> 1. Only characters in the source string are in the random string
p46921x> meaning if Z is not in my source string, it will not be in my random
p46921x> string. If A and B are in the source string, then at least one of them
p46921x> will be in the random string.
p46921x> 2. Each source string will only contain one of the same characters, ie
p46921x> ABcDeFG is a valid source string but  there will be no source strings
p46921x> like ABBDeFG  (as it contains two "B"s).
p46921x> 3. Each random string has one less character than the source string,
p46921x> ie the source string ABcDeFG has 7 characters but the random strings
p46921x> ABDeFG and GABcDe and AcBeDG have 6 characters.

my $input = "ABcDeFG";
use List::Util qw(shuffle); # core in 5.8, CPAN for earlier
my $output = join "", (shuffle split //, $input)[0..length($input)-2];
print $output, "\n";

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/