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

Converting script from Windows to Linux - RE issues

Status
Not open for further replies.

sloppyhack

Technical User
Apr 17, 2001
111
US
I am moving some scripts from a Windows env to Linux. The scripts ran fine under Windows but I'm running into some RegEx problems in Linux. I have a subprocess that checks the header row of input data. The last header value is not being recognized with the following expression. It is recognized if I put an additional tab at the end. Here's the expression. Anyone know why it's not working under Linux? Is there a syntax issue I overlooked? FYI..the line is being "chomped" before getting here.

unless (/(^|\t)$_[0]($|\t)/) { #check to see if the header value exists preceeded by (beginning of line or tab) and followed by (end of line or tab)
}

It always falls to recognize the last value of the line even though it exists in the file? Any help would be greatly appreciated.

Cheers,

Sloppyhack
 
Try 'chomp' to remove the new line character, which differs between linux and windows.
 
I have a 'chomp' statement before the search is performed. It's perplexing. It doesn't seem to be recognizing '$' as end of line.

Cheers,

Sloppyhack
 
--SH,
more relevant code pleez
--waider,
that you?
 
Here is the block I'm having trouble with. It is reading in tab delimited text with a header row. This part validates that all header info is there. It always fails to find the header element at the end of the line. Also, I am getting a lot of crazy carriage returns when the data is printed out. I think something is going on with "end of lines". Everything worked perfectly when run under Windows.

while (<PRODUCTS>) { #read in each line
chomp;
if ($. == 1) { #find header row

im_validate (&quot;VENNAME&quot;);#sub process each of these
im_validate (&quot;VENCODE&quot;);
im_validate (&quot;VENCATNUM&quot;);

sub im_validate {#sub to check for headers
unless (/(^|\t)$_[0]($|\t)/) { #THIS WONT FIND THE LAST ELEMENT IN THE HEADER ROW...IT WORKED PERFECTLY WHEN RUNNING UNDER WINDOWS.

#more code

Cheers,

Sloppyhack
 
NEVERMIND!!!!! I GOT IT. I was using a Samba share and was dropping the text files I was processing directly from Windows to LINUX. The files were formated for PC not UNIX. I saved the input file as UNIX and everything runs fine. It was driving me crazy!!!! The devil's in the details.

Cheers,

Sloppyhack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top