Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl pattern matching

Status
Not open for further replies.

jay123454

Programmer
Jun 15, 2001
46
US
i'm having trouble matching in perl. i'd like to read from an existing file and match certain data types, then pass what has matched into an array...can anyone help?
 
Ummm...I'm not a professional programmer or anything but I do believe that plain vanilla Perl or any other language doesn't care too much about the data types that have been laid out in a datafile which (I assume) is binary. This is all just a concept based on the type of format that the writing program has used to write out the stream which (hopefully) you have some clue to...

Sorry, but I think you need to include more information or an example or something.

-al
 
i think what you mean is, you want to search the contents of a file(s) and check to see if you find a match, right?
if so try this:

open (SEARCH, "path/to/myfil.dat");
for($i = 0; <SEARCH>; $i++)
{
$file_contents[$i] = $_;
if ($search eq $file_contents[$i])
{
Do you stuff here

END;
}
}

close (SEARCH);

that should open the file, and put it into an array for you (handy for later) and then match up your search string to each of those array elements until/unless it finds one that matches where it should end. What ever you want to do with the data you've matched up, do inside the if loop (print it out/whatever) if your doing the program i think, (webmnkeys tutorial - the move library/review?) then this should be a sinch :)
Good Luck
Sib

 
Please can anyone help...

I am trying to substitute '(*)' and replace with '<z9b15>(*)<z$b$>'

I am not having much luck!

Many thanks
 
thanks al!
yes, after i submitted it i realized that i was much to vague..especially after reading some of the other posts. anyways, here is the main task that i am trying to accomplish...

i will have an html document with patterns such as this

6.3.2.1 T_THI
7.3.2.3 G_G
5.2.3.3 S_SH

but many of them...and they refer to a definition later in the doc and i'd like to link them together..so i need a program to reference the letter combination with the corresponding number..then set a source at the location above and a target at the definition later in the document.....
THANKS!
 
hi
just to be clear..i'll use an example. it would be like making a source link on the T_THI to 6.3.2.1, in many cases more than one, whereever T_THI occurs...and then making the 6.3.2.1 a target in the definitions section....i may split up the docs to do this if it would be easier to do in two programs..anyone have any ideas?

thanks!
jay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top