加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

我如何在Perl中解开一个对象?

发布时间:2020-12-15 21:26:09 所属栏目:大数据 来源:网络整理
导读:从 perldoc -f bless: bless REF,CLASSNAME This function tells the thingy referenced by REF that it is now an object in the CLASSNAME package. 有没有办法获得一个没有不必要的复制结构? 解决方法 Data::Structure::Util unbless($ref) Remove the
从 perldoc -f bless:

bless REF,CLASSNAME

This function tells the thingy referenced by REF that it is now
an object in the CLASSNAME package.

有没有办法获得一个没有不必要的复制结构?

解决方法

Data::Structure::Util

unbless($ref)

Remove the blessing from any objects found within the passed data structure.

#!/usr/bin/perl

use strict; use warnings;

use Scalar::Util qw( refaddr );
use Data::Structure::Util qw( unbless );

my $x = bless { a => 1,b => 2 } => 'My';

printf "%s : %sn",ref $x,refaddr $x;

unbless $x;

printf "%s : %sn",refaddr $x;

输出:

My : 237356
HASH : 237356

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读