Re: handling lists in perl

2018-12-19 Thread Greg Wooledge
On Wed, Dec 19, 2018 at 02:48:17PM -0600, David Wright wrote: > I assume that for two numbers in the second list to be selected, both > have to match the two members of an individual tuple. As the tuples > are ordered, I would assume that they are to be tested in the order > supplied. > > As dicti

Re: handling lists in perl

2018-12-19 Thread David Wright
On Wed 19 Dec 2018 at 16:53:44 (+), Andy Smith wrote: > On Wed, Dec 19, 2018 at 09:23:59AM +, mick crane wrote: > > just to be a bit clearer. > > given a list A of *unique* numbers > > and a list B of possible pairings find which pairs you can make from the > > list A. > > 6 can pair with 1

Re: handling lists in perl

2018-12-19 Thread deloptes
Andy Smith wrote: > You saying, "a list B of possible pairings find which pairs you can > make from the list A" doesn't help when B is actually a hash, > because hashes have keys and values, so we don't know if you mean to > "make pairings" with the key or the value, nor is it entirely clear > wha

Re: handling lists in perl

2018-12-19 Thread Andy Smith
Hi Mick, On Wed, Dec 19, 2018 at 09:23:59AM +, mick crane wrote: > just to be a bit clearer. > given a list A of *unique* numbers > and a list B of possible pairings find which pairs you can make from the > list A. > 6 can pair with 100 and 15 can pair with 100 but they cannot both be > in the

Re: handling lists in perl

2018-12-19 Thread mick crane
On 2018-12-19 09:12, mick crane wrote: On 2018-12-19 08:34, deloptes wrote: mick crane wrote: yes but there is only one 100, only one key can have it. I still try to figure out what goes on with the hash pairs with a longer list of numbers your example seems to pick up on the values somehow. I

Re: handling lists in perl

2018-12-19 Thread mick crane
On 2018-12-19 08:34, deloptes wrote: mick crane wrote: yes but there is only one 100, only one key can have it. I still try to figure out what goes on with the hash pairs with a longer list of numbers your example seems to pick up on the values somehow. I dunno, unless there is something about

Re: handling lists in perl

2018-12-19 Thread deloptes
mick crane wrote: > yes but there is only one 100, only one key can have it. > I still try to figure out what goes on with the hash pairs > with a longer list of numbers your example seems to pick up on the > values somehow. > I dunno, unless there is something about using $_ in a loop being > unr

Re: handling lists in perl

2018-12-19 Thread mick crane
On 2018-12-19 07:17, deloptes wrote: mick crane wrote: except there is only one 100 in @array it gets me along. thanks and David too. but this one 100 satisfies both 6 and 15 so 6 and 15 match. regards yes but there is only one 100, only one key can have it. I still try to figure out what

Re: handling lists in perl

2018-12-18 Thread deloptes
mick crane wrote: > except there is only one 100 in @array it gets me along. > thanks and David too. but this one 100 satisfies both 6 and 15 so 6 and 15 match. regards

Re: handling lists in perl

2018-12-18 Thread mick crane
On 2018-12-19 00:43, deloptes wrote: deloptes wrote: if ( @array =~ /$hash[$key]/) { print "key $key with value " . $hash{$key} . " is in the array of values\n"; } I checked and it seems the right answer is my %hash = ( 1=>8,2=>20,6=>100,15=>100 ); my @array = (1, 21, 100, 8, 15, 22, 6, 12,

Re: handling lists in perl

2018-12-18 Thread mick crane
On 2018-12-19 00:43, deloptes wrote: deloptes wrote: if ( @array =~ /$hash[$key]/) { print "key $key with value " . $hash{$key} . " is in the array of values\n"; } I checked and it seems the right answer is my %hash = ( 1=>8,2=>20,6=>100,15=>100 ); my @array = (1, 21, 100, 8, 15, 22, 6, 12,

Re: handling lists in perl

2018-12-18 Thread David Christensen
On 12/18/18 5:43 AM, mick crane wrote: On 2018-12-18 13:34, mick crane wrote: sorry I put 15 twice there just to confuse the issue should be not really on the topic but... I'm not very good at perl (or anything else ) and could maybe sort it but perhaps there is an extension that does it. I h

Re: handling lists in perl

2018-12-18 Thread deloptes
deloptes wrote: > if ( @array =~ /$hash[$key]/) { > print "key $key with value " . $hash{$key} . > " is in the array of values\n"; > } I checked and it seems the right answer is my %hash = ( 1=>8,2=>20,6=>100,15=>100 ); my @array = (1, 21, 100, 8, 15, 22, 6, 12, 56); foreach my $key (keys %hash

Re: handling lists in perl

2018-12-18 Thread deloptes
Hi, it is not exactly clear if you want to test the key or the value of the pairs, but I assume you are after the values. mick crane wrote: > I have an list of pairs > (1=>8,2=>20,6=>100,15=>100) this would be a hash array (means key/value pairs) > and an array of unique numbers > (1 21 10

Re: handling lists in perl

2018-12-18 Thread Greg Wooledge
On Tue, Dec 18, 2018 at 01:34:53PM +, mick crane wrote: > I'm not very good at perl (or anything else ) and could maybe sort it but > perhaps there is an extension that does it. > I have an list of pairs > (1=>8,2=>20,6=>100,15=>100) > and an array of unique numbers > (1 21 100 8 15 22 6 12

Re: handling lists in perl

2018-12-18 Thread mick crane
On 2018-12-18 13:34, mick crane wrote: sorry I put 15 twice there just to confuse the issue should be not really on the topic but... I'm not very good at perl (or anything else ) and could maybe sort it but perhaps there is an extension that does it. I have an list of pairs (1=>8,2=>20,6=>100,

handling lists in perl

2018-12-18 Thread mick crane
not really on the topic but... I'm not very good at perl (or anything else ) and could maybe sort it but perhaps there is an extension that does it. I have an list of pairs (1=>8,2=>20,6=>100,15=>100) and an array of unique numbers (1 21 100 8 15 22 6 12 15 ) I want to see what pairs can