CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
Perl Scripting | hashes

 



ravi333raj
New User

Aug 2, 2015, 9:08 PM

Post #1 of 2 (6673 views)
Perl Scripting | hashes Can't Post

I have an input file which looks like below -

=IP1
abc[0]
abc[1]
abc[2]
=IP2
def[4]
def[8]
def[9]

I need to get the output in the below format-

=IP1
abc[0-2]
=IP2
def[4,8-9]

Can anyone help to achieve the above using hashes


Laurent_R
Veteran / Moderator

Aug 4, 2015, 1:02 PM

Post #2 of 2 (6638 views)
Re: [ravi333raj] Perl Scripting | hashes [In reply to] Can't Post

Hmm, you don't give enough information. I could suggest a very simple solution (almost a one-liner) or a far more complex one, depending on what more input data looks like.

Is "=IP" always a separator between different sections? If so, are the "sections" always containing the same root (i.e. first three letters) values? Would the following output:

Code
=IP1 
abc[0,1,2]
=IP2
def[4,8,9]

be acceptable (it would be far easier)?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives