Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Late as usual I see...
Here is my suggestion
#!/usr/bin/perl use strict; { local %_; while(<DATA>){ chomp; if(/(\d+|[A-Z])$/){ $_{substr($_,0,(length($_)-length($1)))}->{$1} = $_; } } for(sort keys %_){ if(scalar(keys %{$_{$_}}) % 2 == 0){ local @_ = sort{$a <=> $b || ord($a) <=> ord($b)}keys %{$_ +{$_}}; for(my $i = 0; $i < scalar(@_); $i+=2){ if( ($_[$i] =~ /\d$/ && abs($_[$i] - $_[$i+1]) == 1) | +| (abs(ord($_[$i]) - ord($_[$i+1])) == 1) ){ print $_{$_}->{$_[$i]}.";".$_{$_}->{$_[$i+1]}."\n" + ; print $_{$_}->{$_[$i+1]}.";".$_{$_}->{$_[$i]}."\n" + ; } } } } } __DATA__ AAA30 BBC5 SHT12H DAL33B BBC49 AAA31 BBC8 BBC3 DAL33A BBC6 SHT12G BBC50
Not exactly the OP's output but close...
Just a thought :)

"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo

In reply to Re: searching for strings by injunjoel
in thread searching for strings by steph_bow

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (9)
    As of 2019-06-18 12:44 GMT
    Find Nodes?
      Voting Booth?
      Is there a future for codeless software?

      Results (81 votes). Check out past polls.

      • (Sep 10, 2018 at 22:53 UTC) Welcome new users!