一部のサーバー タスクを自動化する小さな Perl スクリプトを開発しています。Windows マシンでテストするとすべてが機能しますが、Linux サーバーにアップロードすると、スクリプトは複数を返します。
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>
コード自体は次のとおりです。
#!/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;
}
アイデアやコメントをありがとう:)
編集:コード行の前に、関係する行の行番号を付けました。