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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strings

Status
Not open for further replies.

Neoport

Programmer
Aug 4, 2000
10
US
Hi,

I have copy the filenames in the directory to a text file. The format of the file is
[year month date page#]-> [0010102.lib]
so this would denote 1900, January, 1st, page 2.

How would I get the list of files in the file that ends anything after the specific date but not the page number. So I would be able to see the list of pages on the specific date.

So it would be:
[000101##.blah], # = any number, no characters.

Thank You
Henry
 
while(<>){
print &quot;Page $1 in $2\n&quot; if /^\[000101..(..)\].+\[(.+)\]/;
}

Above Perl fragment will print the following

Page 26 in 0010102.lib
Page 16 in 0010103.lib

if run over this file.

[0001010126]-> [0010102.lib]
[0001010116]-> [0010103.lib]
[0001020126]-> [0010104.lib]
[0001020126]-> [0010105.lib]

Is this what you meant?
Mike
michael.j.lacey@ntlworld.com
 
The list of files are stored in a array, and also the files doesn't start with &quot;[&quot; or end with &quot;]&quot;. So do I just remov e the two brackets in the if statement below?
the file name is only 8 number long,
00010108.lib
1900, January 1st, page #8.

I'm just going to loop through the whole array and from each line in the text, I just want to do the comparison whether it has the specific date with worrying about the page number.

Thanks
 
To match [ in a Perl regular expression you need two characters '\[' because [ means something special otherwise.

So to remove the searches for square brackets you have to remove the leading backslashes as well.

Would you post a few lines from your array exactly as they're stored please?
Mike
michael.j.lacey@ntlworld.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top