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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:16:32+00:00 2026-06-19T03:16:32+00:00

I’m developing a small Perl script to automate some server tasks and when I

  • 0

I’m developing a small Perl script to automate some server tasks and when I test it on my Windows machine everything works, but when I upload it to my Linux server the script returns multiple:

Use of uninitialized value $line in chomp at CreateEntity.pl line 52, <HANDLE> line 5.
Use of uninitialized value $line in string ne at CreateEntity.pl line 52, <HANDLE> line 5.
Use of uninitialized value $string in substitution (s///) at CreateEntity.pl line 67, <HANDLE>
Use of uninitialized value $string in substitution (s///) at CreateEntity.pl line 68, <HANDLE>
Use of uninitialized value $string in substitution (s///) at CreateEntity.pl line 67, <HANDLE>
Use of uninitialized value $string in substitution (s///) at CreateEntity.pl line 68, <HANDLE>

And here is the code itself:

#!/usr/bin/env perl

# This fils SHOULD go in the root of Symfony... put it anywhere else AT YOUR OWN RISK !!!

use warnings;

# Declare the subroutines
sub trim;

if(!defined $ARGV[0])
{
    die( "No FilePath Specified!\n" );

}

my $entityFile = $ARGV[0];

open( HANDLE, $entityFile ) or die( "The file could not be open!" );

my $entityCmd = "php app/console doctrine:generate:entity --entity=\"rapliqBundle:";
my $entityName = "";

chomp( my $line = ( <HANDLE> ) );
$line = trim( $line );
while( $line ne "END" )
{
    if( trim( $line ) ~~ "NAME:" )
    {
        chomp( $line = ( <HANDLE> ) );
        $entityName = trim( $line );
        $entityCmd = $entityCmd . $entityName;
        $entityCmd = $entityCmd . "\" --fields=\"";
    }
    elsif( trim( $line) ~~ "FIELDS:" )
    {
        chomp( $line = ( <HANDLE> ) );
        my @data = split( '=', $line );
        foreach my $val (@data) 
        {
            $val = trim( $val );
            if( $val ~~ lc "string" )
            {
                $entityCmd = $entityCmd . $val . "(255) ";
            }
            else
            {
                $entityCmd = $entityCmd . $val . ":";
            }
        }
    }

    52: chomp( $line = ( <HANDLE> ) );
}

close( HANDLE );
$entityCmd = $entityCmd . "\"";

#print $entityCmd;

system( $entityCmd );
system( "php app/console doctrine:generate:entities rapliqBundle:" . $entityName );
system( "php app/console doctrine:schema:update --force");

sub trim
{
    my $string = $_[0];
    67:$string =~ s/^\s+//;
    68:$string =~ s/\s+$//;
    return $string;
}

Thanks for any idea or comments 🙂

EDIT: I put the line number for the concerned line in front of the line of code.

  • 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-19T03:16:33+00:00Added an answer on June 19, 2026 at 3:16 am

    It all comes down to handling the end of your input file better.

    1. Use of uninitialized value $line in chomp at CreateEntity.pl line 52, line 5.

      <HANDLE> returns undef to indicate you’ve reached the end of the file. You ignore this and attempt to chomp the returned value.

    2. Use of uninitialized value $line in string ne at CreateEntity.pl line 52, line 5.

      Misreported line number. The warning is actually coming from $line ne "END".

      $line is still undefined from having reached the end of the file.

    3. Use of uninitialized value $string in substitution (s///) at CreateEntity.pl line 67,

    4. Use of uninitialized value $string in substitution (s///) at CreateEntity.pl line 68,

      trim( $line ) ~~ "NAME:"

      $line is still undefined from having reached the end of the file.

    5. Use of uninitialized value $string in substitution (s///) at CreateEntity.pl line 67,

    6. Use of uninitialized value $string in substitution (s///) at CreateEntity.pl line 68,

      trim( $line) ~~ "FIELDS:"

      $line is still undefined from having reached the end of the file.

    You should trim a line only once, and there’s no need to chomp if you’re going to trim.


    In a flash of brilliance, I think I know what you’re underlying problem is 🙂

    Your data file has Windows line endings. You chomp the line, leaving you with "END\r" instead of "END". The dos2unix command line tool would fix that, and so would trimming.

    while (my $line = <HANDLE>) {
       $line = trim( $line );
       last if $line eq "END";
       ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small JavaScript validation script that validates inputs based on Regex. I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
This could be a duplicate question, but I have no idea what search terms

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.