if the header existed in line 1 to go to the next file.
but i am getting error explciti errors
Here is my code I am using
Expand|Select|Wrap|Line Numbers
- #!/usr/bin/perl
- user warnings;
- use strict;
- use Tie::File;
- opendir(DIR, ".") or die $!;
- my @files = readdir(DIR); # reads everything in the dir
- close(DIR); #
- $i = 1; #declared variable
- # While loop implemented with the array
- while (@files) {
- @row = split(/\./,$_); # will return each line listed in the read filename. ext - or whatever is listed
- $name = $row[0]; # will read everything on the left of the . meaning will read the file name alone
- chomp($name);
- $new_name = $name.$i.'.txt' # The new name variable is declared so that the the filename left of the. will include the $i ands concatnate then end in .txt
- rename($_, $new_name); # will return filename, ==> which will rename to the newname in the variable above.
- $i++;
- ################ Adding line 1 - Header information for each file that does not have it###############
- tie @files, 'Tie::File', '$new_name' || die "Can't open: $!\n";
- $numrows = @files;
- $insertpoint = $numrows - 1;
- $newrec="PARTY_UID|NAME|ADDR_ADDR|ADDR_ADDR_LINE_2|ADDR_ADDR_LINE_3|ADDR_ADDR_NAME|ADDR_ZIPCODE|ADDR_POBOX|ADDR_CITY|ADDR_PROVINCE|ADDR_COUNTRY|MAIN_PH_NUM|MAIN_FAX_PH_NUM|LANG_ID|X_VAT_NUM|TAX_JURIDICTION_CODE|ACCOUNT_GROUP|COMPLETE_DELIVERIES|INCO_TERMS1|INCO_TERMS2|CUSTOMER_GROUP|CUSTOMER_GROUP3|CUSTOMER_GROUP5|PRICE_LIST_TO_USE|SALES_ORG|BASE_CURCY_CD|PAY_TERM_NAME|CREATED|CREATED_BY|TAX_EXEMPT_FLG|X_PPL_HOLD|X_PPL_HOLD_DATE|X_CREDIT_HOLD
- ";
- splice @rows, $insertpoint, 0, $newrec;
- untie @rows;
- };