Random letters, getting same results

L

LANkrypt0

I wrote the following little script below and am running into a problem.

The script with an argument:
../script.pl hello

It then would get the length of the word hello and use that to generate
random letters of that amount. i.e, doiqw

Then it SHOULD keep running until the word hello is matched with a one of
the random outputs. The problem is that it outputs the same results, i.e
doiqw
doiqw
doiqw
etc.

Any help or insight into why this is happening would be greatly
appreciated. Also any tips on better coding practices or streamlining
this is also appreciated =)

Thanks!


==+ BEGIN CODE +==

#!/usr/bin/perl
use strict;

my $counter = 0;
my $attempts = 0;
my $word;
my $tword;

sub wordcheck #Checks if word matches, if so print and exit
{
if ($word eq $ARGV[0])
{
print "Word found in $attempts attempts!\n";
exit
}
}

sub getword #Generates random letters, length based on $ARGV[0] length
{
while ($counter < length($ARGV[0]))
{
$tword = chr(int(rand(ord("z")-ord("a"))+ord("a")));
$word = $tword.$word;
$counter++;
}
}

while ($word ne $ARGV[0]) #Runs until matches
{
getword
print "$word\n";
wordcheck
$attempts++
}

==+ END CODE +==
 
L

LANkrypt0

Thanks for your help. I went back and reevaluated what was being done and
really took a look at it and got it all figured out. The counter was not
resetting itself, nor was $word, so I added those lines in and then
combined most of the lines into one loop and rid myself of the
subfunctions. Anywhere here is the working product.

Thanks!

==+ BEGIN CODE +==

#!/usr/bin/perl

while ($word ne $ARGV[0])
{
while ($counter < length($ARGV[0]))
{
$counter++;
$word = chr(int(rand(ord("z")-ord("a"))+ord("a"))).$word;
}
print "$word\n";

if ($word eq $ARGV[0])
{
print "Word found in $attempts attempts!\n";
exit;
}
$attempts++;
$counter = 0;
$word = "";
}

==+ END CODE +==
 
L

LANkrypt0

I assure you no trolling. Two completely separate things i was working
on.

The first was a logical search: aaaaa aaaab aaaac, etc. I quickly got that
one working, smacking myself in the forehead, when I realized the error)

This one obviously does its random thing :) I came over here as I read a
few messages in that one pointing people this-a-way.

Basically I am just learning perl now. I had previously worked with KSH.
I thought it would be a good lesson to convert all my old KSH scripts to
perl ones, to see what differs in how everything is formatted and in which
order things need to be placed, etc. So far it has proven to be a good
learning lesson.
 
M

Michele Dondi

./script.pl hello

It then would get the length of the word hello and use that to generate
random letters of that amount. i.e, doiqw

Then it SHOULD keep running until the word hello is matched with a one of
the random outputs. The problem is that it outputs the same results, i.e [snip]
==+ BEGIN CODE +==

#!/usr/bin/perl

the shebang line '#!/usr/bin/perl' is much like a 'BEGIN CODE' marker
that is much like a 'hello'...

[snip 33 lines of code]
==+ END CODE +==

The '__END__' line is much (but not completely!) like a 'END CODE'
marker that is much like a 'bye'!


#!/usr/bin/perl -l

use strict;
use warnings;

my ($w,$c)=$_=shift ||
die "Usage: $0 <word>\n";

{
s/./('a'..'z')[rand 26]/ge;
print;
$_ eq $w or $c++, redo;
}

print "`$w' found again in $c attempts";

__END__


HTH,
Michele
 
B

Ben Morrow

LANkrypt0: you are probably not aware of this, but Purl Gurl is our
resident troll. Google for her other posts to verify this.

Strictures are always helpful, even for short scripts. About the only
exception I would make is one-liners, where every character counts.

This is not true. It means that the variable is not accessible outside
this file, say from a different module. This prevents some other code
from changing it by mistake.

However, here PG is correct... your declarations are in the wrong
places.
#!/usr/bin/perl

use strict;
use warnings;
while ($word ne $ARGV[0])
{

while (my $word ne $ARGV[0]) {
my $attempts;

while ($counter < length($ARGV[0]))
{

while (my $counter < length $ARGV[0]) {
$counter++;
$word = chr(int(rand(ord("z")-ord("a"))+ord("a"))).$word;

I would have written this

$word = (a..z)[int rand 26] . $word;
}
print "$word\n";

Set $\ = "\n" rather than putting an explicit "\n" on the end of every
print.
if ($word eq $ARGV[0])
{
print "Word found in $attempts attempts!\n";
exit;
}
$attempts++;
$counter = 0;
$word = "";

As these variables are now properly scoped to their respective loops you
don't need to reset them.

Ben
 
B

Ben Morrow

Quoth Ben Morrow said:
$counter++;
$word = chr(int(rand(ord("z")-ord("a"))+ord("a"))).$word;

I would have written this

$word = (a..z)[int rand 26] . $word;

....except that, unlike my one-liner test, I would be using strictures,
so I would need to write

$word = ('a'..'z')[int rand 26] . $word;

:(

Ben
 
J

John Bokma

Purl said:
ignorance, bigotry, hatred and mental illness , elsewhere.

for many people mental illness is reality. Since I doubt you even
understand what DSM IV means, and are far from even able to understand
the basics of diagnosing a person, let alone based on Usenet postings,
please refrain from diagnosing people in the future. It hurts both
sides, and contributes to many of the misunderstandings about mental
illness as well as classifying sufferers as less than normal.

Besides, I agree with Ben, keep strict and warnings in your scripts
until you know 100% what you are doing, and based on the OP's question,
this is not the case. The danger of vars coming to life when you use
them is that a typo in the name creates a new var, a mistake even
experienced programmers make now and then.
 
J

John Bokma

Purl said:
John Bokma wrote:

(author attributes stripped by Bokma)

Purl Gurl said:
ignorance, bigotry, hatred and mental illness , elsewhere.
"

I guess you were the author?

I wrote:
"for many people mental illness is reality. Since I doubt you even
understand what DSM IV means, and are far from even able to understand
the basics of diagnosing a person, let alone based on Usenet postings,
please refrain from diagnosing people in the future. It hurts both
sides, and contributes to many of the misunderstandings about mental
illness as well as classifying sufferers as less than normal.

Besides, I agree with Ben, keep strict and warnings in your scripts
until you know 100% what you are doing, and based on the OP's question,
this is not the case. The danger of vars coming to life when you use
them is that a typo in the name creates a new var, a mistake even
experienced programmers make now and then.
"
Your continued postings of insults, discontent and hatred
benefit none. Most would appreciate your taking your
ignorance, bigotry, hatred and mental illness , elsewhere.

It is you who showed, and show again ignorance.

Look up "bigotry", and please explain in what part of the above I showed
such a state of mind.

Hate is an emotion I don't understand, and I doubt I ever used it.

And since your posting is merely a repeat of the one you gave to Ben
your behaviour can certainly be qualified as ignorance.

Please reread the first paragraph I wrote, quoted above (after the first
"I wrote:", without the quotes) for your convenience.
 
J

John Bokma

Purl said:
John Bokma wrote:

(author attributes previously stripped by Bokma)




(snipped)

Like many others here, you are psychotically obsessed with me.

Can you clarify the qualification "psychotically obesessed"?
You are mentally ill, as are those others.

As I stated, you are not able to diagnose me as such. By using this term
loosely you hurt people who suffer from mentally illness as well as
their friends, family etc.
You and others are, in common terms, "stalkers" which is a
behavorial manifestation of mental illness.

Since mental illness is a broad generic term, you can not state that
stalking is a manifestation of it in general. As an English professor
(your words) you should at least understand such basic things. Also,
again, you hurt many people with your silly statements.
Your words, thoughts, actions, daily internet activities, various
historical archives, all evidence several years worth of abnormal
psychotic obsession,

With you? ROTFLMAO.
along with daily stalking and harassment
of not only me, but our entire family as well.

I don't even know your family. Also, as I stated in a previous post, I
guess that the "hacking attempts, harassment, stalking" etc. you see at
your fat bottom girl page are just.... HITS thanks to the page showing
up in search engines. ROTFLMAO!

Yeah, really gurl, I have hundreds and hundreds of hack attempts via
Google, people using proxies, and weird cloaking tricks... brrr. They
scare me!

Just a hint: put a robots.txt file in your Document root, and most of
the "stalking and harassment" will be gone. You can also try
mod_rewrite, but I am afraid to be able to use it you need some basic
regexp skills :-D.
You and others are, very clearly, mentally ill.

Again, you don't even come close to the skills required to make such a
diagnosis. Drop the abuse of a medical term you clearly are not capable
of handling.
 
J

John Bokma

Purl said:
You and others are, in common terms, "stalkers" which is a

<http://www.purlgurl.net/~callgirl/stats/>

Top 20 of 65 Total Search Strings
# Hits Search String
1 858 65.75% fat girls
2 110 8.43% callgirl
3 75 5.75% androids
4 46 3.52% fat bottom girls
5 38 2.91% fat bottom

Top 30 of 276 Total Referrers (some snipped)
# Hits Referrer
2 937 8.57% http://images.search.yahoo.com/search/images/view
12 130 1.19% http://images.google.com/imgres
17 74 0.68% http://images.google.de/imgres
21 52 0.48% http://www.altavista.com/image/results
23 38 0.35% http://images.google.nl/imgres
24 37 0.34% http://www.alltheweb.com/search
25 29 0.27% http://www.google.com/search
30 27 0.25% http://uk.search.yahoo.com/images/view_ukie

Top 30 of 554 Total URLs

# Hits KBytes URL
7 259 2.37% 613 0.43% /~callgirl/videfatb.html

Top 10 of 145 Total Entry Pages

# Hits Visits URL
1 259 2.37% 261 19.65% /~callgirl/videfatb.html

Since she has blocked that page:
<http://66.102.11.104/search?q=cache:w6hVT7p7_KoJ:www.purlgurl.net/~callgirl/videfatb.htm>

Which shows the words of a song by Queen "Fat Bottomed Girls".

So guess where all those stalkers are coming from?
 
J

John Bokma

Purl said:
John Bokma wrote:

(attributes context stripped by Bokma)

Which are?
Without my needing to do so, you have independently
provided evidence of your and others stalking of
our family, evidence any can verify.

LOL, how stupid are you really? You have a link to your stats page
on your "homepage".
Additionally, your prior knowledge of "Fat Bottom Girls,"

Yes, you complained about stalkers last week, and refered to an
access_log entry, which showed a Google hit (IIRC), for fat bottom, and
rest snipped. As someone who has some experience with Google, it was not
that hard to find the videfatb page, which you blocked recently.
knowledge which you have verified previously, amounts to
a confession on your part, you are stalking our family.

Since when is visiting an accessible webpage stalking? Your stats can be
accessed. That Queen lyric with some pics could be accessed a few days
ago, and still is available (minus the pics) using Google cache.

You probably still got quite a lot of hits, due to yahoo, and google. It
amazes me that you talk about Perl programming but don't even grasp the
basics of a website on the Internet nor the working of a search engine.

You perceive normal search engine related hits as stalking. ROTFLMAO.

You are not a troll, a troll has more sense.
Mentally ill people, such as yourself and those others,
are often easily manipulated into unintended confessions.

Sure. You are not able to distinguish between a person who is mentally
ill and not. Stop puting labels on people if you don't understand what
it means. YOU are the one that is insulting and harming others.
You are mentally ill. Others here are mentally ill.
You and those others, are mentally disturbed criminal
stalkers, well evidenced in many ways, and well verified
by your series of articles, past and present.

Pathetic.
 
M

Michele Dondi

Strictures are always helpful, even for short scripts. About the only
exception I would make is one-liners, where every character counts.

And golfing code, where every character counts even more...


Michele
 
T

Tore Aursand

Without my needing to do so, you have independently
provided evidence of your and others stalking of
our family, evidence any can verify.
[...]

Why are you linking to that page from your own homepage, then? Are you
stalking yourself?
 
M

Matt Garrish

Purl Gurl said:
Like many others here, you are psychotically obsessed with me.
You are mentally ill, as are those others.

You and others are, in common terms, "stalkers" which is a
behavorial manifestation of mental illness.

Has it ever dawned on you that everyone is tired of your pathetic act?
You're not intelligent, insightful, original or even amusing. You're a
one-trick fool whose fifteen minutes ended with Randal's open letter to you.

Matt
 
J

John Bokma

Tore said:
1 858 65.75% fat girls
4 46 3.52% fat bottom girls
5 38 2.91% fat bottom

7 259 2.37% 613 0.43% /~callgirl/videfatb.html
1 259 2.37% 261 19.65% /~callgirl/videfatb.html

Without my needing to do so, you have independently
provided evidence of your and others stalking of
our family, evidence any can verify.
[...]

Why are you linking to that page from your own homepage, then? Are you
stalking yourself?

I guessed about a week ago when she accused people from here, regulars,
to "attack" her fat bottomed girl page, and proving it with a access_log
snippet showing the visitor came via a search engine, that she mistakes
regular visitors for "attacks and stalking of regulars to clpm using
open proxies" :-D.

If she just use a robots.txt file, she can stop spiders getting that
page. I guess most come for the pictures, and some others for the lyrics
of Queen.

Also using ~callgirl in an URI is not that smart.
 
J

John Bokma

Matt said:
Has it ever dawned on you that everyone is tired of your pathetic act?
You're not intelligent, insightful, original or even amusing. You're a
one-trick fool whose fifteen minutes ended with Randal's open letter to you.

I did miss that one:
<http://groups.google.com/groups?hl=...elm=38824167.C946B538%40telisphere.com&rnum=1>

Since she left the thread (or so it seems), she really acts like a
troll, or maybe hit & run posting. She drops bait, and wait until others
take it. I try to avoid getting hooked in the future :-D.

I hope she can make an apology to people mentally ill, and people
diagnosed as such by *her*. Also people accused of being hackers,
bigots, hateful, stalkers, and harassing her family. And I doubt the
reference at <http://www.purlgurl.net/~callgirl/videfatb.htm> to "Frank
Gostak" is even valid at all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top