Sponsored Content
Full Discussion: Perl search multiple fields
Top Forums Shell Programming and Scripting Perl search multiple fields Post 302785481 by sabercats on Monday 25th of March 2013 05:09:18 PM
Old 03-25-2013
Perl search multiple fields

Hi all,

I have a flatfile 300 lines
Code:
tiger,tampa10-pc,yellow,none,2013-02-25 08:56:51.000,2013-02-25 21:41:11.380,12hrs : 44min
cat,tampa10-pc,white,none,2013-02-28 08:56:58.000,2013-03-04 23:18:23.003,110hrs : 21min
dog,tampa10-pc,yellow,none,2013-03-05 09:50:17.000,2013-03-07 00:08:02.617,38hrs : 17min
dog,tampa10-pc,yellow,Trainned,2013-02-24 00:00:00.000,2013-02-24 22:34:10.293,22hrs : 34min
dog,sanjose10-pc,yellow,Trainned,2013-02-24 22:34:32.000,2013-02-25 08:56:58.743,10hrs : 22min
dog,sanjoseis10-pc,yellow,Unknown,2013-02-25 21:40:21.000,2013-02-27 00:17:36.007,26hrs : 37min
dog,sanjose10-pc,yellow,Unknown,2013-02-27 00:17:57.000,2013-02-28 00:19:35.340,24hrs : 01min
dog,denver10-pc,black,Unknown,2013-02-28 00:19:38.000,2013-02-28 08:57:12.103,8hrs : 37min
dog,denver10-pc,black,Trainned,2013-03-04 23:18:16.000,2013-03-05 09:50:25.500,10hrs : 32min
dog,denver12-pc,yellow,Unknown,2013-03-07 00:07:51.000,2013-03-13 00:04:35.213,143hrs : 56min
dog,denver10-pc,yellow,Unknown,2013-03-13 00:04:48.000,2013-03-14 01:24:15.437,25hrs : 19min
dog,denver12-pc,yellow,Unknown,2013-03-14 01:24:37.000,2013-03-15 10:23:17.503,32hrs : 58min

I created a basic html form:
Code:
 <html><head> <TITLE>Search </TITLE>
 <script language="javascript" type="text/javascript" src="./applets/datetimepicker_css.js">
</script>
</head>

 <body>
<center><h1>Search</h1></center>
<hr WIDTH="80%">
<FORM METHOD="POST" ACTION="search.pl">
<table  border=0 WIDTH="80%"cellspacing=4 cellpadding=3 bordercolor="#FFCC00" style="background-color:#FFFFCC">
 <tr >
  <td >
  Start Date:
  </td>
  <td >
<input type="text" id="startdate" size="16"> <img src="./images/cal.gif" width="16" height="16" border="0" onclick="javascript:NewCssCal('startdate','yyyyMMdd')" style="cursor:pointer"/>
  </td>
  <td >
  End Date:
  </td>

  <td >
<input type="text" id="enddate" size="16"> <img src="./images/cal.gif" width="16" height="16" border="0" onclick="javascript:NewCssCal('enddate','yyyyMMdd')" style="cursor:pointer"/>
  </td>
 </tr>
 <tr >
  <td >
  Animal
  </td>

  <td >
 Location:
  </td>
  <td >
  Color:
  </td>
  <td >
  Trainning:
  </td>
 </tr>
 <tr >

  </td>
  <td >
  <SELECT NAME="animal" SIZE="1">
    <OPTION SELECTED>all
    <OPTION>tiger
     <OPTION>cat
    <OPTION>dog
    
</SELECT>
  </td>
  <td >
  <SELECT NAME="location" SIZE="1">
  <OPTION SELECTED>all
  <OPTION>tampa
   <OPTION>sanjose
  <OPTION>denver
</SELECT>
  </td>
  <td>
<SELECT NAME="color" SIZE="1">
  <OPTION SELECTED>all
  <OPTION>black
   <OPTION>yellow
  <OPTION>white

</SELECT>
  </td>
    </td>
    <td>
  <SELECT NAME="training" SIZE="1">
    <OPTION SELECTED>Unknown
     <OPTION>Traiined
    <OPTION>none
  
</SELECT>
  </td>
 </tr>
</table>
 <HR WIDTH="80%">

<INPUT TYPE="Reset" VALUE="Clear Form">
<INPUT TYPE="Submit" VALUE="Submit">
</FORM>

</body></html>

How do i write search.pl so when i select startdate : 2013-03-15 and enddate : 2013-03-24 AND select option animal AND select option Location AND select option Color AND select option training then SUBMIT it will search for me.

I cannot use sql because my system does not have it.
Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl: Match a line with multiple search patterns

Hi I'm not very good with the serach patterns and I'd need a sample how to find a line that has multiple patterns. Say I want to find a line that has "abd", "123" and "QWERTY" and there can be any characters or numbers between the serach patterns, I have a file that has thousands of lines and... (10 Replies)
Discussion started by: Juha
10 Replies

2. Shell Programming and Scripting

How to search for two fields

Hi all, I have a file with format as below: cat 0 animal 90 number90 cat_number_name cat 1 animal 91 number91 cat_animal_name cat 2 animal 92 number92 cat_name_animal kiwi 0 bird 90 number90 ... (3 Replies)
Discussion started by: jisha
3 Replies

3. Shell Programming and Scripting

Perl - How to search a text file with multiple patterns?

Good day, great gurus, I'm new to Perl, and programming in general. I'm trying to retrieve a column of data from my text file which spans a non-specific number of lines. So I did a regexp that will pick out the columns. However,my pattern would vary. I tried using a foreach loop unsuccessfully.... (2 Replies)
Discussion started by: Sp3ck
2 Replies

4. Shell Programming and Scripting

help with search and replace in multiple fields

I have a pipe delimited file with 27 fields. Each record has 26 fields. I need to search for the 25,26,27 fields and replace "," with nothing. How can I acheive this. Sed is more preferred. e.g data row o/p (5 Replies)
Discussion started by: dsravan
5 Replies

5. Post Here to Contact Site Administrators and Moderators

Search fields

I routinely use the search field in the top right hand corner. When the results to a search are displayed, two new search input fields are shown at the top of the search results: google('this_site') google('the_world') Is there a reason for having 3 search input fields on the... (0 Replies)
Discussion started by: figaro
0 Replies

6. UNIX for Dummies Questions & Answers

Formatting Multiple fields on 1 line to multiple rows

I'm trying extract a number of filename fields from a log file and copy them out as separate rows in a text file so i can load them into a table. I'm able to get the filenames but the all appear on one line. I tried using the cut command with the -d (delimiter) option but cant seem to make it... (1 Reply)
Discussion started by: Sinbad-66
1 Replies

7. Shell Programming and Scripting

Multiple pattern search in perl

user 10 values content is: musage.py yes value user 11 values content is: gusage.py yes value how to print "user" string line by searching "content is:" string and "usage.py" string in perl (8 Replies)
Discussion started by: Anjan1
8 Replies

8. Shell Programming and Scripting

Help need with PERL multiple search pattern matching!

My example file is as given below: conn=1 uid=oracle conn=2 uid=db2 conn=3 uid=oracle conn=4 uid=hash conn=5 uid=skher conn=6 uid=oracle conn=7 uid=mpalkar conn=8 uid=anarke conn=9 uid=oracle conn=1 op=-1 msgId=-1 - fd=104 slot=104 LDAPS connection from 10.10.5.6 to 10.18.6.5 conn=2... (3 Replies)
Discussion started by: sags007_99
3 Replies

9. Shell Programming and Scripting

Search and swap multiple lines in file using Perl

Hi all, I have a vcd file with a bunch of lines containing an array, like this $var wire 1 b a $end $var wire 1 c a $end $var wire 1 d a $end $var wire 1 e a $end $var wire 1 f b $end $var wire 1 g b $end $var wire 1 h b $end $var wire 1 i b $end I want it like this: $var wire 1 e a... (12 Replies)
Discussion started by: veerabahu
12 Replies

10. Shell Programming and Scripting

perl: search replace in multiple files

When I use special characters the command to replace multiple files with a string pattern does nt work. ---------- Post updated at 12:33 PM ---------- Previous update was at 11:38 AM ---------- This works perl -pi -e 's/100/test/g' * This does nt work perl -pi -e 's... (1 Reply)
Discussion started by: w020637
1 Replies
All times are GMT -4. The time now is 10:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy