Thanks
Thanks, that's a neat trick - I hadn't realised you could still capture things from within a lookahead. Richard On Jun 24, Richard Adams said: @peptides = $sequence =~ /(\w{4}S\w{4})/g; this works up to a point, but if there are 2 adjacent 'S' the 2nd one is not extracted, I guess because the regexp engine continues after the end of the previous match ie., it doesn't extract DFRSSSGHY above. Here's the trick for you: @peptides = $sequence =~ /(?=(\w{4}S\w{4}))/g; The (?=...) assertion looks ahead in the string for the pattern, without actually advancing in the string when it's done. In this way, we capture something without advancing past it. -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dear answerers - sorry
Sorry to have incensed many of you with what was a genuine oversight in omitting a subject. Richard Jenda, et al -- ...and then Jenda Krynicky said... % ... % I would like to ask all the people who invest their time and answer % the questions in this list to ignore the posts whose authors were too % lazy to specify a meaningful subject. % % If they do not get any reply, they might start wondering why and % maybe even come to the right conclusion. I'm inclined to doubt it, sad though that may be. I'm more in favor of a gentle flaming at the top of the reply; as an added bonus, since most of these yahoos also top-post that's where they'll first look for any answer. % % Jenda HAND :-D -- Dr Richard Adams Chromosome Structure Group Room 6.37, Swann Building ICMB, University of Edinburgh Kings Buildings, Mayfield Rd, Edinburgh EH9 3JR UK Tel 44 131 650 7102 Fax 44 131 650 7028 Email [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
no subject
Hi, I have a long sequence of letters ( an amino acid sequence). I want to extract 4letters either side of each S and get them into an array. e.g., ADFGTREDSWQACVDFRSSSGHYT would get TREDSWQAC VDFRSSSGH DFRSSSGHY etc. I have worked out how to do this by using substr() but wondered if there was a more elegant way using regexps . I tried: @peptides = $sequence =~ /(\w{4}S\w{4})/g; this works up to a point, but if there are 2 adjacent 'S' the 2nd one is not extracted, I guess because the regexp engine continues after the end of the previous match ie., it doesn't extract DFRSSSGHY above. . Is it possible to try the next match from within the previous match to remedy this? Thanks for any tips or flashes of inspiration, Richard -- Dr Richard Adams University of Edinburgh Kings Buildings, Mayfield Rd, Edinburgh Email [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Use of our
Hi, I'm sure this has been asked before, but I'm having a problem with understanding our. I get the idea of my, and also variable declared without a qualifier is visible to all packages/modules..also that $package::varname can be used to access a global variable in another package... But the more I read the camel book the more confused I get, especially about the lexical scoping of our..if it's lexically scoped how can it be global?? Does declaring our $a refer to a previously declared $a in another package/module, with the lexical scoping keeping it within a block of the current package? Any help in clearing the fog from my brain greatly appreciated... -- Richard Adams University of Edinburgh Kings Buildings, Mayfield Rd, Edinburgh EH9 3JR UK Email [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Ok- real dumb question
Hi, This works, even if it's not the most elegant. open LIST, mail.txt or die cannot open mail file; while (my $line = LIST) { @details = split /\s+/, $line; if (@details == 5) {#test for length of array $details[2] .= ; $details[2] .= $details[3]; #put middle name in with 1st name splice @details, 3, 1; #get rid of unwanted middle name field } push @list, [@details]; #make array of arrays. } foreach (@list) { foreach (@$_) { print $_: } print \n; } -- Dr Richard Adams Chromosome Structure Group Room 6.37, Swann Building ICMB, University of Edinburgh Kings Buildings, Mayfield Rd, Edinburgh EH9 3JR UK Tel 44 131 650 7102 Fax 44 131 650 7028 Email [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Sorting problem
Hello, I've got an array of arrays, and want to sort by the 3rd element of the subarray. I then want to print out the sorted array, showing the index and values. E.g., @AoA = ( [23.56, 65.2, 12.4], [13, 56, 87], [45,876, 23], etc ) And then the printout should look like: 1: 87 2: 23 3: 12.4 I've tried @sorted = {$a -[2] = $b -[2]} @AoA but this gives a cannot modify..error. I've a feeling this is really trivial but have got abit bogged down with it... Thanks in advance Richard -- Dr Richard Adams Chromosome Structure Group University of Edinburgh Kings Buildings, Mayfield Rd, Edinburgh EH9 3JR UK Email [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Sorting problem
Thanks for all your help...I just forgot the sort in my post... The reason it wasn't working wasn't the sort, it was just that $AoA[0] was undefined.. But sort {$a-[2] = $b-[2]} @AoA[1..$#AoA] works just fine. Thanks again! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Sorting problem-part2
Now I've got an array of hashes, where each hash can have different keys e.g., @aoh = ( {H3 =234, H1 =127, DNA =1, p135 =167}, {H4=24, H3=1550, DNA =25, p39 =67}, {H3 =34, H2A =125, DNA =5, p32 =7}, {H3 =24, H4 =156, DNA =123, p12 =13} ) And I'd like to order the array elements by virtue of the biggest value in the hash. 1. H3 1550 2. H3 234 3. H4 156 4. H2A 125 Is there a quick one liner for this or do I need to find the max in each hash, store them in an array, and then sort the array of hash maxima separately, while maintaining the key/value associations? Thanks a lot for any suggestions! Richard -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Selftuition
Hi, I've been teaching myself Perl and C in preparation for a new job. I've been using Wrox's Beginning Perl and the Camel book for Perl, and KR and the DeitelDeitel How to program for C. Does anyone know of a Perl instruction book/web resource that has plenty of exercises (with example answers) like the Deitel book for C? The main problem I've had learning Perl is trying to separate out the need -to -know stuff from the very clever but you can get by without it info, esp in the manpages and the Camel book. Also I find the exercises in the deitel book for C very useful for getting the syntax firmly learned. This is my first post so hope it's suitable, -- Dr Richard Adams University of Edinburgh Kings Buildings, Mayfield Rd, Edinburgh Email [EMAIL PROTECTED] http://www.ed.ac.uk/~rradams/passengers.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]