VsCode Perl Debug时模拟命令行传入参数

复制代码
Unknown option: name zhangs
at D:/ProgramFiles/strawberry/perl/lib/Getopt/Long.pm line 1072.
Getopt::Long::FindOption(ARRAY(0x29ad740), "(--|-|\\+)", "--", "-name zhangS", HASH(0x32d54e0)) called at D:/ProgramFiles/strawberry/perl/lib/Getopt/Long.pm line 528
Getopt::Long::GetOptionsFromArray(undef, undef, undef, undef, undef, ARRAY(0x29ad740), "name=s", SCALAR(0x2d5c3e8), ...) called at D:\work\p1\t1.pl line 10
Unknown option: age 25
at D:/ProgramFiles/strawberry/perl/lib/Getopt/Long.pm line 1072.
Getopt::Long::FindOption(ARRAY(0x29ad740), "(--|-|\\+)", "--", "-age 25", HASH(0x32d54e0)) called at D:/ProgramFiles/strawberry/perl/lib/Getopt/Long.pm line 528
Getopt::Long::GetOptionsFromArray(undef, undef, undef, undef, undef, ARRAY(0x29ad740), "name=s", SCALAR(0x2d5c3e8), ...) called at D:\work\p1\t1.pl line 10
Error in command line arguments
at D:\work\p1\t1.pl line 10.




Perl VsCode debug 很麻烦,各种报错.而且LZ本地装上了,发现数字类型的变量可以看到,字符串类型的变量不显示,NND,折腾了好几天,最后放弃,还是用CMD 进行debug

最终还是用CMD debug 省事,就是操作小麻烦...

复制代码
DBD::Pg::db do failed: 错误:  当前事务被终止, 事务块结束之前的查询被忽略 at able.pl line 777
引起原因:LZ本地是手动事务AutoCommit => 0, (AutoCommit => 1 就是自动事务)
$dh = DBI->connect(DSN, USER, PASSWORD, { RaiseError => 1,AutoCommit => 0,pg_enable_utf8 => 1}) or die DBI::errstr;
上一个SQL执行失败了,没有回滚 or 提交事务造成
代码里加:$dh->commit;

DBD::Pg::st execute failed: 错误:  无效的类型 integer 输入语法: ""
CONTEXT:  unnamed portal parameter $12 = '' at Table.pl line 800, <INFILE_CSV> line 1.
PostgreSQL数据库某字段是Integer类型,但是CSV文件某字段的值是空串''造成的异常
foreach my $value (@$csvdata) {
				if ($value eq '') {
			        $value = undef;
			    }
				if ($cnt != 0) {
					$sql .= ", ";
				}
				$sql .= "?";
				$cnt++;
			}
追加了
if ($value eq '') {
       $value = undef;
   }
把空串替换为undef,PG就能接受

DBI connect('dbname=postgres;host=127.0.0.1;port=5432','bkdb3',...) failed: authentication method 10 not supported at
Failed:不支持认证方式10 at 276行
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::Pg::db handle dbname=postgres;host=127.0.0.1;port=5432 at D:/ProgramFiles/strawberry/perl/lib/Encode.pm line 212.
Exception : 処理中にエラーが発生しました ( Wide character at D:/ProgramFiles/strawberry/perl/lib/Encode.pm line 212. 
)。
错误信息表明你在使用 Perl DBI 连接 PostgreSQL 时,遇到了认证方式的问题。具体来说,错误信息中的"认证方式10"通常是指 PostgreSQL 服务器正在使用的认证方法与你的客户端驱动程序(DBD::Pg)不兼容
解决方案:修改了pg_hba.conf文件
LZ本地是先把 md5  →  trust 了先用着调试程序,
相关推荐
huizhixue-IT10 小时前
2026年还需要学习RHCE 吗?
开发语言·perl
m0_748254666 天前
Perl 变量类型
spark·scala·perl
mzhan01716 天前
perl: redhat9, perl-interpreter.rpm 一个包分成很多个小包
开发语言·perl·redhat·rpm
无限大.1 个月前
为什么“云计算“能改变世界?——从本地计算到云端服务
开发语言·云计算·perl
源文雨1 个月前
PVE实现USB硬盘盒在备份前自动上电/结束后自动断电脚本
linux·运维·服务器·备份·perl·pve·usb硬盘盒
凯新生物1 个月前
聚乙二醇二生物素,Biotin-PEG-Biotin在生物检测中的应用
scala·bash·laravel·perl
柒儿吖1 个月前
Perl在鸿蒙PC上的使用方法
开发语言·harmonyos·perl
深兰科技1 个月前
坦桑尼亚与新加坡代表团到访深兰科技,促进AI在多领域的应用落地
java·人工智能·typescript·scala·perl·ai大模型·深兰科技
hid711713661 个月前
基于RISC-V指令集的五级流水线CPU设计、验证及上板实践:详细说明与代码注释完备
perl
沟通qq 8762239651 个月前
基于改进A*算法的单agv路径规划算法仿真 可以更改地图,起始点,目标点 % 1 表示障碍物 ...
perl