Loading ...
Sorry, an error occurred while loading the content.
 

Re: no repeats

Expand Messages
  • draktrax
    ... Thank you for the reply. The construct you presented, while helpful, is not shown in my book until after the exercise I m working on. Therefore: $c=0;
    Message 1 of 8 , May 29 1:08 AM
      --- In perl-beginner@yahoogroups.com, "C.Y./J.E. Cripps" <cycmn@...>
      wrote:
      >
      >
      >
      > > perl -e 'print if /unique/;' will for instance find lines
      > > such as
      > > # tests for duplicates, to get unique elements
      >
      > I was actually using:
      >
      > $ perl -lane 'print if /unique/;'
      >
      > My apology.
      >


      Thank you for the reply.
      The construct you presented, while helpful, is not
      shown in my book until after the exercise I'm working on.
      Therefore:

      $c=0;
      foreach $b ("spades", "hearts", "clubs", "diamonds") {
      foreach $a ("ace", 2..10, "jack", "queen", "king") {
      $deck[$c] = "$a of $b";
      $c++;
      }
      }

      foreach $d (1..10) {
      $card = $deck[rand @deck];
      print "Card $d is the $card\n";
      }

      How do I ensure no duplicates?
    • merlyn@stonehenge.com
      ... draktrax The construct you presented, while helpful, is not draktrax shown in my book until after the exercise I m working on. Therefore, you are asking
      Message 2 of 8 , May 29 6:24 AM
        >>>>> "draktrax" == draktrax <draktrax@...> writes:

        draktrax> The construct you presented, while helpful, is not
        draktrax> shown in my book until after the exercise I'm working on.

        Therefore, you are asking us to cheat with your homework.

        That's unethical. You should be ashamed.

        Ask your teacher for more understanding, not us for a crutch.

        --
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
        <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
        Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
        See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
      • draktrax
        ... 777 0095 ... discussion ... Since I am my own teacher and my text is Ellie Quigley s Perl by Example 4th Ed.; and given the fact that I have pored over the
        Message 3 of 8 , May 29 11:04 AM
          --- In perl-beginner@yahoogroups.com, merlyn@... wrote:
          >
          > >>>>> "draktrax" == draktrax <draktrax@...> writes:
          >
          > draktrax> The construct you presented, while helpful, is not
          > draktrax> shown in my book until after the exercise I'm working on.
          >
          > Therefore, you are asking us to cheat with your homework.
          >
          > That's unethical. You should be ashamed.
          >
          > Ask your teacher for more understanding, not us for a crutch.
          >
          > --
          > Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503
          777 0095
          > <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
          > Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
          > See http://methodsandmessages.vox.com/ for Smalltalk and Seaside
          discussion
          >

          Since I am my own teacher and my text is Ellie Quigley's Perl by
          Example 4th Ed.; and given the fact that I have pored over the first
          seven chapters to find a solution; I must be a brick wall.
          Not only do I not see the solution,I thought I had joined a BEGINNING
          Perl forum. Instead, I get patronization and condecending remarks.
          And code snippets that are FAR beyond what I would call beginner.
          If this is the way beginners are treated, then remove my name, please.

          Thank You, Donald R. Korrecta
        • merlyn@stonehenge.com
          ... draktrax Since I am my own teacher and my text is Ellie Quigley s Perl by draktrax Example 4th Ed.; You didn t do anything to disclose that, and if you
          Message 4 of 8 , May 29 11:34 AM
            >>>>> "draktrax" == draktrax <draktrax@...> writes:

            draktrax> Since I am my own teacher and my text is Ellie Quigley's Perl by
            draktrax> Example 4th Ed.;

            You didn't do anything to disclose that, and if you look at the history of
            this list, you will find that the majority of people talking about exercises
            are in fact would-be cheaters.

            I apologize for miscategorizing you, as you are the exception, not the rule.

            However, if someone answers your question with constructs you haven't yet
            seen, it'd be better to learn what those constructs are, rather than say "no,
            that can't be the answer". Your learning will progress quicker.

            --
            Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
            <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
            Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
            See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
          • C.Y./J.E. Cripps
            ... which of course needs a file name as an argument If one suspects what one wants is in the chap007.pl file $ perl -lane print if /MYTAG/; chap007.pl To
            Message 5 of 8 , May 29 3:00 PM
              cycjec>> I was actually using:

              >> $ perl -lane 'print if /unique/;'

              which of course needs a file name as an argument

              If one suspects what one wants is in the chap007.pl file

              $ perl -lane 'print if /MYTAG/;' chap007.pl

              To check several files with similar names

              $ perl -lane 'print if /MYTAG/;' chap00*

              And a solitary star * will check all files in the current directory.
            Your message has been successfully submitted and would be delivered to recipients shortly.