newbie Q:create a subset 
Author Message
 newbie Q:create a subset

hi!




thanks,
-Raj
-----------------------------------------------

I was trying this , but does not seem to work.
any hints please. thanks



$ct=1;

{


        $ct = $ct +1;

Quote:
}


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



Fri, 21 Jul 2000 03:00:00 GMT  
 newbie Q:create a subset


Quote:
>hi!




>thanks,

You can do something like this verbose snippet:

#!/usr/local/bin/perl -w

{
  local (%mark);





  }

Quote:
}


__END__

or you can use perl 5's map to make it shorter, the block can be:

{


Quote:
}

or you can look in the FAQ which suggests this in section 4:

How do I compute the difference of two arrays? How do I compute the
intersection of two arrays?

Use a hash. Here's code to do both and more. It assumes that each element
is unique in a given array:


    %count = ();

    foreach $element (keys %count) {


    }

Hope this helps,

Mike
--

http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41



Fri, 21 Jul 2000 03:00:00 GMT  
 newbie Q:create a subset





Here's my current favorite for that.  Beware that the
delete-hash-slice operator doesn't work prior to 5.004.  (Good reason
to upgrade, and it's FREE! :-)


print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 210 more days

--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying

Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me



Fri, 21 Jul 2000 03:00:00 GMT  
 newbie Q:create a subset

: hi!




In perlfaq4.pod, you'll find an entry entitled "how do I compute the
difference of two arrays."

Note that this can become very complicated if the arrays contain
references; you might want to do a DejaNews search on this group to find
a discussion that occurred a couple weeks ago regarding how to determine
if two arrays are identical.



Fri, 21 Jul 2000 03:00:00 GMT  
 newbie Q:create a subset

Quote:





>thanks,
>-Raj
>-----------------------------------------------
>I was trying this , but does not seem to work.
>any hints please. thanks



I don't think these two lines are doing what you think that they are


Have you seen the entry in the FAQ titled "How do I compute the
difference of two arrays?  How do I compute the intersection of two
arrays?" Its not exactly what you want, (the difference between two


you on the right track.


  $seen{$elem} = 1;

Quote:
}




--
Andrew Langmead



Fri, 21 Jul 2000 03:00:00 GMT  
 newbie Q:create a subset





That is called the "set difference" operation.

Perl FAQ, part4:

   "How do I compute the difference of two arrays?  
    How do I compute the intersection of two arrays?"

--
    Tad McClellan                          SGML Consulting

    Fort Worth, Texas



Fri, 21 Jul 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Newbie: 2 More Substitution Regex Qs

2. Small subset of Perl....

3. Algorithm for Text Subsets

4. make subset of the search result

5. Perl tuning/speed question: all subsets of a set of length k -- keeping the inital order

6. Simple Subset Question

7. alphabetical subset of hash keys

8. all unique subsets of a list

9. Subset Question

10. Perl 4a12e Solaris 2.3 build Qs

11. 2 Perl Style Qs

12. : novice Qs: minimal input loops, field specifiers

 

 
Powered by phpBB® Forum Software