Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8727221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:23:55+00:00 2026-06-13T08:23:55+00:00

Question is 2 fold: I’m writing a perl (not to experienced with perl) script

  • 0

Question is 2 fold:

  1. I’m writing a perl (not to experienced with perl) script and can get it to convert one file at a time from csv to ascii. I want to do a loop that takes all csv’s in a folder and converts them to ascii/txt.

  2. Is perl the best language to be attempting this with? I assumed yes since i can successfully do it one file at a time but having a very hard time figuring out a way to loop it.

I was trying to figure out how to load all the files into an array then run the loop for each one, but my googling has reached its limit and i’m out of ideas.
here’s my working script:

#!/usr/bin/env perl
use strict;
use warnings;
use autodie;

use open IN => ':encoding(UTF-16)';
use open OUT => ':encoding(ascii)';

my $buffer;

open(my $ifh, '<', 'Software_compname.csv');
read($ifh, $buffer, -s $ifh);
close($ifh);

open(my $ofh, '>', 'Software_compname.txt');
print($ofh $buffer);
close($ofh);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:23:56+00:00Added an answer on June 13, 2026 at 8:23 am

    Just add the following loop to your script and give it the files to process as arguments:

    for my $input_file (glob shift) {
        (my $output_file = $input_file) =~ s/csv$/txt/ or do {
            warn "Invalid file name: $input_file\n";
            next;
        };
    
        my $buffer;
    
        open my $ifh, '<', $input_file;
        read $ifh, $buffer, -s $ifh;
        close $ifh;
    
        open my $ofh, '>', $output_file;
        print{$ofh} $buffer;
        close $ofh;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, this question is two-fold: 1) The actual file manupulation bit 2) Looping this
Question from Object-Oriented JavaScript book: Imagine Array() doesn't exist and the array literal notation
My question is two fold, firstly, is it possible to create a foreign key,in
Just a quick question really: I'm running a method to pull records from an
Sorry, this became a 3-fold question regarding arrays I think (dynamic) arrays are truly
Ok so this question is two fold. I am creating a bill reminder app
I am not sure what is the difference between fold and foldLeft in Scala.
I have a Python script which processes a .txt file which contains report usage
Question Is it possible to stop a Message Driven Bean (programmatically), so that it
Question context: let say that there is some really important row in config/locales/en.yml that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.