![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| lack of understanding > annoying error | jzacsh | Shell Programming and Scripting | 21 | 4 Weeks Ago 04:10 PM |
| error in output of perl script | namishtiwari | Shell Programming and Scripting | 2 | 06-15-2009 06:02 AM |
| Perl Error with ftptail script | Cooki3s! | UNIX for Dummies Questions & Answers | 2 | 05-04-2009 12:46 PM |
| Help understanding syntax error Issue | warlock129 | Shell Programming and Scripting | 6 | 04-26-2009 08:02 PM |
| Perl script error | pietie | Shell Programming and Scripting | 4 | 10-15-2008 10:05 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I'm not sure what all those "shift" lines are in there for, but your loop problem is here:
Code:
while ($f2){
($Fld0,$Fld1,$Fld2,$Fld3,$Fld4,$Fld5,$Fld6,$Fld7,$Fld8,$Fld9,$Fld10) = split(/[|\n]/,$f2, -1);
print $f3_out ($Fld0, $Fld1, $Fld2, $Fld3, $Fld4, $Fld10);
}
}
Code:
($Fld0,$Fld1,$Fld2,$Fld3,$Fld4,$Fld5,$Fld6,$Fld7,$Fld8,$Fld9,$Fld10) = split(/[|\n]/,$f2, -1); print $f3_out ($Fld0, $Fld1, $Fld2, $Fld3, $Fld4, $Fld10); } I don't know if that will make your code do something useful but hopefully it will run and you can further modify as needed. |
|
|||||
|
Thank you for the reply
I do want it to loop but not endlessly on the first line of file2. File2 has 24000 records split in 10 fields I do have it working Now but I’m using 2 scripts to do it one extract the records the Other matches them. What I’m trying to do is combining them Into one Thk |
|
||||
|
If you don't want it to loop endlessly then remove the 'while' loop I showed you to remove.
---------- Post updated at 02:25 PM ---------- Previous update was at 02:15 PM ---------- Maybe this is w2hat you want to do: Code:
#!/usr/local/bin/perl
use warnings;
use strict;
die "Usage: $0 <file1> <file2> <file_out>\n" unless $#ARGV==2;
my ($file1, $file2, $file3) = @ARGV;
open my $f1_in, $file1 or die "Could not open $file1\n";
open my $f2_in, $file2 or die "Could not open $file2\n";
open(my $f3_out, '>', $file3) or die "Could not open $file3: $!\n";
while (my $f1 = <$f1_in>) {
my $f2 = <$f2_in>;
$f1 =~ s/^\s+|\s+$//g;
$f2 =~ s/^\s+|\s+$//g;
my($Fld0,$Fld1,$Fld2,$Fld3,$Fld4,$Fld5,$Fld6,$Fld7,$Fld8,$Fld9,$Fld10) = split(/\|/,$f2, -1);
print $f3_out join(',',$Fld0, $Fld1, $Fld2, $Fld3, $Fld4, $Fld10);
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|