Reading the entire file into an array is rarely a good idea, but if you insist on doing it, then you have to realize that each element of the array is going to be exactly one line of the file. So, "hostname XXXXX\n" is going to be one element unless you explicitly extract using a split or regex. -----Original Message----- From: Grossner, Tim X. (AIT) [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 12, 2001 3:28 PM To: Mooney Christophe-CMOONEY1 Subject: RE: searching for a string of characters after another string of characters No, I have already extracted the line, and i put it into an array...the problem is that its ending up as the only element of the array. IE, print @hostname returns "hostname XXXXX". I only want the XXXXX. -----Original Message----- From: Mooney Christophe-CMOONEY1 [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 12, 2001 1:11 PM To: Grossner, Tim X. (AIT) Subject: RE: searching for a string of characters after another string of characters If i understand you correctly, you're trying to extract exactly one line out of a file. I would do this: while (<IN>) { if (/^hostname\s+(\S+)$/) # or some other regex derivative { $hostname=$1; last; } } -----Original Message----- From: Grossner, Tim X. (AIT) [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 12, 2001 3:03 PM To: [EMAIL PROTECTED] Subject: searching for a string of characters after another string of characters How would I do this: file A contains a line of characters always looking like "hostname XXXXX". I want to take the XXXXX and assign that to a scalar...I tried making an array out of it by using grep to search for the line starting with "hostname", but then the one and only element of the array is "hostname XXXXX" and I cant figure out how to extract the XXXXX out... Any help would be greatly appreciated. __________________________________________________ Tim Grossner Field Operations Manager CCNA, MCP, A+ Southwestern Bell Datacom voice - 217-522-7564 pager - 217-467-3148 cell - 217-971-3060 data - [EMAIL PROTECTED]