I am a novice in writing Perl script.
How can I concatenate two files. The files are created in separate runs. I need to send the files out as one file.
is the file data stored as a scalar or as an array? if it's a scalar, the scalar concatenation operator is '.', so just do:[tt]
my $two_files = $file1 . $file2;[/tt]
if they are arrays, you can join two arrays with the 'push' function:[tt]
push @two_files, @file1, @file2;[/tt]
really, though, you don't need to do either of these - when you open up the file to be printed, just print in both sets of data.
or, after you've already print into the file the first time and closed it, open it up for concatenation ("open FILE, '>>file.ext'" and print in the second one.
hope this helps "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
yet another perspective....
If you are running on a *nix system and all you want to do is string two files together, then don't use Perl. Just use the OS command.....
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.