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 6544651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:29:28+00:00 2026-05-25T11:29:28+00:00

I need some guidance with the following Perl code. When I leave the no

  • 0

I need some guidance with the following Perl code. When I leave the no strict 'refs', the sub works fine. But if the no strict 'refs' is removed, then I get the error message:

Can't use string ("A") as a symbol ref while "strict refs" in use at test.pl

It dies in the lines marked as “Here” below. This sub needs to open (write >) all files from A..Z and based on the regex from the READ file (LOG) the output will be written to the correspond file output.

use strict;
use Text::CSV_XS;
no strict 'refs';  
...
...
sub file_split {

    my ( $i, $fh, @FH );
    my ( $file ) = @_;
    my ( @alpha) = ("A".."Z");

    for ( @alpha) {                            
            $fh = $_ ;
            open ( $fh,">","$_-$file" )  || die $!;      <--------- HERE
            push @FH, $fh;
    }

    my $csv = Text::CSV_XS->new( {  binary => 1,
                                    allow_whitespace => 1,
                                    allow_loose_escapes => 1,
                                    allow_loose_quotes =>1,
                                    escape_char => undef ,
                                    sep_char => ',',
                                    auto_diag=> 1
                                    } );
    open( LOG,"<", $file ) || die $!;
    while ( my $row = $csv->getline( *LOG ) ) {
            if ( $row->[0] =~ /^(\w)/ ) {
                    print $1                       <--------- HERE
                            "$row->[0]".",".
                            "$row->[1]" .",".
                            "$row->[2]" .",".
                            "$row->[3]" .",".
                            "$row->[4]".",".
                            "$row->[5]"."\n";

            } else {
                        print "Record skipped... --> $row->[0] <-- ... please verify     \n";
                }
    }
}
  • 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-05-25T11:29:29+00:00Added an answer on May 25, 2026 at 11:29 am

    Don’t assign $fh = $_ it’s not doing anything useful.

    @FH should be %FH and instead of the push try:

    $FH{ $_ } = $fh
    

    Replace the $1 with $FH{ $1 }.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some guidance for following : I have an ActionSheet. When it appears
Need some guidance figuring out what went wrong. I've been using mysql, phpmyadmin for
I am new to mocking and dependency injection and need some guidance. My application
I am new in this field and i desperately need some guidance from u
I am in need of some guidance of how to carry out a specific
Need some guidance. I have java webstart app and I want it to connect
I'm new to PHP, so I need some guidance as to which would be
i need some help and guidance in displaying the splitted Strings in order. let
I'm heavily geared towards C++ thinking and need some guidance on a specific C#
I need some help/guidance on WinForms data binding and I can't seem to get

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.