473,385 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Get Values for the id's

Hi,

I have an array like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. @arr="(mouse 18340633
  3.  
  4. sperm 18340633
  5.  
  6. proteome 18340633
  7.  
  8. strip 18340633
  9.  
  10. Role 18184912
  11.  
  12. insulator 18184912 )";
  13.  
I want to retrieve the words that corresponds to that id.

I tried removing duplicates and getting the words but it didn't work!!!

Here is the code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. $join=join("#",@arr);
  3.  
  4. $join=~/(.*)\#(.*);
  5.  
  6. push(@id,$2);
  7. push(@words,$1);
  8.  
  9. #push(@temp,$join);
  10.  
  11. %seen;
  12.         for ( my $i = 0; $i <= $#id; )
  13.         {
  14.                 splice @id, --$i, 1
  15.                 if $seen{$id[$i++]}++;
  16.         }
  17.  
  18.   for($j=0;$j<scalar(@id);$j++)
  19.   {
  20.     print "<br> $words[$j] <br>";
  21.   }
  22.  
  23.  
I want the ouput like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. 18340633: mouse, sperm ,proteome,strip  
  3.  
  4. 18184912: Role, insulator 
  5.  
How can i get the words?

Regards
Archana
Feb 11 '09 #1
3 1424
KevinADC
4,059 Expert 2GB
What you really want is a hash (of arrays), not an array.

Expand|Select|Wrap|Line Numbers
  1. my %hash =  (
  2.    '18340633' => [qw(mouse sperm proteome strip)],
  3.    '18184912' => [qw(Role insulator)],
  4. );
  5.  
  6. foreach my $key (keys %hash) {
  7.    print "$key ", join (",", @{$hash{$key}}), "\n";
  8. }
The code you posted is full of errors and will not even compile.
Feb 11 '09 #2
@KevinADC
Hi,

oh ok!!!

sorry for that!!!

How to create an hash for that?

This is just an example of the values!!

How can i create hash dynamically?
Feb 11 '09 #3
KevinADC
4,059 Expert 2GB
@Archanak
Depends on the input data. Post an example of the data you are using to create the hash.
Feb 11 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Angelos | last post by:
I have this list of logs stored in a MySQL DB. I display them in a list and next to each log I have a del view LINK I want to add Checkboxes next to each log and keep del and view links as...
2
by: sukh | last post by:
From the table i want everything highlighted with a * I wanted an SQl expression to look at values in Column 1 (ID), look at the corresponding values in the second column (F1) and select the row...
3
by: muzamil | last post by:
To get rid of redundant data in a table, my cleint will be providing something like this: IDtokeep Ids to delete 34 24,35,49 12 14,178,1457 54 32,65,68 I have to write a...
4
by: cwwilly | last post by:
Hello, Thanks for taking a look at this! Problem: I'm trying to pass multiple dynamic values between a slaveform and a masterform. The problem I'm having is on the slaveform I loop through...
3
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that...
4
by: devi | last post by:
Hi, In oracle I have a LAG function using which I could get the previous value of a field. Do we have anything similar to that in SQL Server or access? Thanks Devi
3
by: Frankie | last post by:
Hi, I need to add shirt size info for new T-shirts into a mysql database in this order: S, M, L, XL, creating the following table: itemNumber size inStock 1000 ...
4
by: scparker | last post by:
Hello, We have a stored procedure that does a basic insert of values. I am then able to retrieve the ID number created for this new record. We are currently using ASP.NET 2.0 and use N-Tier...
0
by: chandrasekhar | last post by:
Hi I have developed a web page with some controls. I put all of them in session variables. I passed this values in the page. When an user enter some data in form fields and click the buttton ,...
2
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
Hi, Is there a way to get/set (or override) SqlParameter.SourceColumn values manually? Code example: // create DeleteCommand by SourceColumn strSQL = "DELETE FROM WHERE (ID=@ID)"; using...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.