Random letters, getting same results

Discussion in 'Perl Misc' started by LANkrypt0, Jun 19, 2004.

  1. LANkrypt0

    LANkrypt0 Guest

    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 +==


    --
    LANkrypt0 :: aa#2118
     
    LANkrypt0, Jun 19, 2004
    #1
    1. Advertising

  2. LANkrypt0

    LANkrypt0 Guest

    On Fri, 18 Jun 2004, Purl Gurl wrote:

    >> LANkrypt0 wrote:
    >>
    >> (snipped)
    >>
    >> > use strict;

    >>
    >> Not needed for such a simple script.
    >>
    >> > my $counter = 0;
    >> > my $attempts = 0;
    >> > my $word;
    >> > my $tword;

    >>
    >> Use of "my" declarations for globals serves no purpose.
    >> Remove strict, get rid of your "my" declarations or
    >> make use of useless "our" declarations; use of "our"
    >> serves absolutely no purpose save for satiation of
    >> anal retentive geeks who insist you must use strict.
    >>
    >> <sniperoo>
    >>
    >> Give careful thought to your $counter variable.
    >> That variable needs to be elsewhere, and when
    >> in the correct place, it will not be a global
    >> variable if "my" declared. Print your $counter
    >> value with each loop for a hint on what is wrong.
    >> Then give thought to how you have created a
    >> rather classic infinite loop in your coding.
    >>
    >> Purl Gurl
    >>

    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 +==

    --
    LANkrypt0 :: aa#2118
     
    LANkrypt0, Jun 19, 2004
    #2
    1. Advertising

  3. LANkrypt0

    LANkrypt0 Guest

    On Fri, 18 Jun 2004, Purl Gurl wrote:

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

    >>
    >>
    >> I am curious why you have presented two radically different
    >> versions of your code, in different newsgroups.
    >>
    >> Some might think you are trolling. I presume this is not so.
    >>
    >>
    >> Purl Gurl
    >>

    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.

    --
    LANkrypt0 :: aa#2118
     
    LANkrypt0, Jun 19, 2004
    #3
  4. On Fri, 18 Jun 2004 20:25:13 -0400, LANkrypt0 <>
    wrote:

    >./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
    --
    you'll see that it shouldn't be so. AND, the writting as usuall is
    fantastic incompetent. To illustrate, i quote:
    - Xah Lee trolling on clpmisc,
    "perl bug File::Basename and Perl's nature"
     
    Michele Dondi, Jun 19, 2004
    #4
  5. LANkrypt0

    Ben Morrow Guest

    Quoth LANkrypt0 <>:
    > On Fri, 18 Jun 2004, Purl Gurl wrote:
    >
    > >> LANkrypt0 wrote:
    > >>
    > >> (snipped)
    > >>
    > >> > use strict;
    > >>
    > >> Not needed for such a simple script.


    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.

    > >> > my $counter = 0;
    > >> > my $attempts = 0;
    > >> > my $word;
    > >> > my $tword;
    > >>
    > >> Use of "my" declarations for globals serves no purpose.


    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.

    > >> Give careful thought to your $counter variable.
    > >> That variable needs to be elsewhere,


    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

    --
    If you put all the prophets, | You'd have so much more reason
    Mystics and saints | Than ever was born
    In one room together, | Out of all of the conflicts of time.
    The Levellers, 'Believers'
     
    Ben Morrow, Jun 19, 2004
    #5
  6. LANkrypt0

    Ben Morrow Guest

    Quoth Ben Morrow <>:
    >
    > > $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

    --
    All persons, living or dead, are entirely coincidental.
    Kurt Vonnegut
     
    Ben Morrow, Jun 19, 2004
    #6
  7. LANkrypt0

    John Bokma Guest

    Purl Gurl wrote:

    > 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.

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
     
    John Bokma, Jun 19, 2004
    #7
  8. LANkrypt0

    John Bokma Guest

    Purl Gurl wrote:

    > John Bokma wrote:
    >
    > (author attributes stripped by Bokma)


    "Purl Gurl wrote:

    > 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.

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
     
    John Bokma, Jun 19, 2004
    #8
  9. LANkrypt0

    John Bokma Guest

    Purl Gurl wrote:

    > John Bokma wrote:
    >
    > (author attributes previously stripped by Bokma)
    >
    >
    >>Purl Gurl wrote:
    >>
    >>>John Bokma wrote:
    >>>
    >>>>Purl Gurl wrote:

    >
    >
    > (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.

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
     
    John Bokma, Jun 19, 2004
    #9
  10. LANkrypt0

    John Bokma Guest

    Purl Gurl wrote:

    > 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?

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
     
    John Bokma, Jun 19, 2004
    #10
  11. LANkrypt0

    John Bokma Guest

    Purl Gurl wrote:

    > John Bokma wrote:
    >
    > (attributes context stripped by Bokma)


    Which are?

    >>Purl Gurl wrote:

    >
    > (snipped)
    >
    >>>You and others are, in common terms, "stalkers" which is a

    >
    >>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.


    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.

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
     
    John Bokma, Jun 19, 2004
    #11
  12. On Sat, 19 Jun 2004 14:07:35 +0000 (UTC), Ben Morrow
    <> wrote:

    >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
    --
    you'll see that it shouldn't be so. AND, the writting as usuall is
    fantastic incompetent. To illustrate, i quote:
    - Xah Lee trolling on clpmisc,
    "perl bug File::Basename and Perl's nature"
     
    Michele Dondi, Jun 20, 2004
    #12
  13. LANkrypt0

    Tore Aursand Guest

    On Sat, 19 Jun 2004 12:04:44 -0700, Purl Gurl wrote:
    >> 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?


    --
    Tore Aursand <>
    "What we see depends mainly on what we look for." (Sir John Lubbock)
     
    Tore Aursand, Jun 20, 2004
    #13
  14. LANkrypt0

    Matt Garrish Guest

    "Purl Gurl" <> wrote in message
    news:...
    >
    > 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
     
    Matt Garrish, Jun 20, 2004
    #14
  15. LANkrypt0

    John Bokma Guest

    Tore Aursand wrote:

    > On Sat, 19 Jun 2004 12:04:44 -0700, Purl Gurl wrote:
    >
    >>>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.

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
     
    John Bokma, Jun 20, 2004
    #15
  16. LANkrypt0

    John Bokma Guest

    Matt Garrish wrote:

    > "Purl Gurl" <> wrote in message
    > news:...
    >
    >>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.


    I did miss that one:
    <http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=38824167.C946B538%40telisphere.com&rnum=1&prev=/groups%3Fq%3Dopen%2Bletter%2Brandal%2Bpurl%2Bgurl%26hl%3Den%26lr%3D%26ie%3DUTF-8%26selm%3D38824167.C946B538%2540telisphere.com%26rnum%3D1>

    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.

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
     
    John Bokma, Jun 20, 2004
    #16
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Merrigan
    Replies:
    4
    Views:
    583
    Chris
    Dec 14, 2007
  2. globalrev
    Replies:
    4
    Views:
    782
    Gabriel Genellina
    Apr 20, 2008
  3. Amir  Michail
    Replies:
    10
    Views:
    408
    Carl Banks
    Mar 4, 2009
  4. Venugopal
    Replies:
    11
    Views:
    1,564
    Tassilo v. Parseval
    Nov 5, 2003
  5. VK
    Replies:
    15
    Views:
    1,214
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page