Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: Combining files

by vitoco (Friar)
on Oct 02, 2009 at 13:37 UTC ( #798857=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Combining files
in thread Combining files

AFAIK, wildcards in OS boxes are expanded by programs, not by the shell (cmd.exe) as in *nix. Perl will keep "*" as an argument, and it's illegal as a filename when interpreted by <> operator.

You may consider this:

FOR %F IN (*) DO perl -pe "" "%F" >> ..\newfile.txt

but it's better to use Win's built-in commands, like TYPE or COPY, as it was already said.

Note that newfile.txt must be empty or must not exists before the FOR, because >> opens it for append on each iteration.

Update: Using globs:

perl -e "while (<*>) {open(F,$_) or next;while(<F>){print}/}}" > ..\ne +wfile.txt

Note: this code has errors, but works as an example.

BTW, it seems that files order is not important.


Comment on Re^4: Combining files
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://798857]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2015-07-06 22:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (84 votes), past polls