Skip Menu |

This queue is for tickets about the XML-Smart CPAN distribution.

Report information
The Basics
Id: 89228
Status: resolved
Priority: 0/
Queue: XML-Smart

People
Owner: TMHARISH [...] cpan.org
Requestors: Daniel.Pirog2 [...] Honeywell.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Use of ('$') for returning scalar of a node has changed between XML-SMART v1.77 and v1.78.
Date: Thu, 3 Oct 2013 13:43:10 +0000
To: "bug-XML-Smart [...] rt.cpan.org" <bug-XML-Smart [...] rt.cpan.org>
From: "Pirog,Daniel" <Daniel.Pirog2 [...] Honeywell.com>
Use of ('$') for returning scalar of a node has changed between XML-SMART v1.77 and v1.78. The line of code giving me the problem: my $value = $XML->{StatusUpdate}{$key}('$'); This use is should still be supported as per the on-line documentation. In v1.77 this worked correctly, but in v1.78 receive the following message: Can't use string ("A350_CCWB_20") as an ARRAY ref while "strict refs" is in use at c:/perl/site/lib/XML/Smart.pm line 1423. The string referenced in the error message is the content of the node. Running: This is perl 5, version 14, subversion 2 (v5.14.2) built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2011, Larry Wall Binary build 1402 [295342] provided by ActiveState http://www.ActiveState.com Built Oct 7 2011 15:49:44
Following works for me - Please let me know if the structure you are using is different? #!perl -T use 5.006 ; use strict ; use warnings FATAL => 'all' ; use Test::More ; use XML::Smart ; # Bug id - 89228 subtest 'Copy' => sub { my $XML = XML::Smart->new(); $XML->{StatusUpdate}{19} = 'A350_CCWB_19'; $XML->{StatusUpdate}{20} = 'A350_CCWB_20'; my $key = 20 ; my $value = $XML->{StatusUpdate}{$key}('$') ; my $tmp = ref $value ; cmp_ok( $tmp, 'eq', '', 'Scalar Test' ); $tmp = ref $XML ; cmp_ok( $tmp, 'eq', 'XML::Smart', 'Control Test' ); done_testing() ; }; done_testing() ;
Subject: RE: [rt.cpan.org #89228] Use of ('$') for returning scalar of a node has changed between XML-SMART v1.77 and v1.78.
Date: Thu, 3 Oct 2013 19:43:27 +0000
To: "bug-XML-Smart [...] rt.cpan.org" <bug-XML-Smart [...] rt.cpan.org>
From: "Pirog,Daniel" <Daniel.Pirog2 [...] Honeywell.com>
Sample script and data file attached. Running with XML-Smart v1.77, output as follows: H:\A350 Data\2013\2013-10-02 S2.2 New TargetDates>smartbug.pl StatusWorkbook = S2_RBE_Current.xlsm PlanDatabase = H:\A350 Data\SES Verification Traceability\SESVerTrace.mdb Campaign = S2.2RBE; $VAR1 = 'S2_RBE_Current.xlsm'; $VAR2 = 'H:\\A350 Data\\SES Verification Traceability\\SESVerTrace.mdb'; $VAR3 = 'S2.2RBE;'; Running with XML-Smart v1.78, output as follows: H:\A350 Data\2013\2013-10-02 S2.2 New TargetDates>smartbug.pl Can't use string ("S2_RBE_Current.xlsm") as an ARRAY ref while "strict refs" in use at C:/Perl/site/lib/XML/Smart.pm line 1423. Show quoted text
-----Original Message----- From: Harish T Madabushi via RT [mailto:bug-XML-Smart@rt.cpan.org] Sent: Thursday, October 03, 2013 2:15 PM To: Pirog,Daniel Subject: [rt.cpan.org #89228] Use of ('$') for returning scalar of a node has changed between XML-SMART v1.77 and v1.78. <URL: https://rt.cpan.org/Ticket/Display.html?id=89228 > Following works for me - Please let me know if the structure you are using is different? #!perl -T use 5.006 ; use strict ; use warnings FATAL => 'all' ; use Test::More ; use XML::Smart ; # Bug id - 89228 subtest 'Copy' => sub { my $XML = XML::Smart->new(); $XML->{StatusUpdate}{19} = 'A350_CCWB_19'; $XML->{StatusUpdate}{20} = 'A350_CCWB_20'; my $key = 20 ; my $value = $XML->{StatusUpdate}{$key}('$') ; my $tmp = ref $value ; cmp_ok( $tmp, 'eq', '', 'Scalar Test' ); $tmp = ref $XML ; cmp_ok( $tmp, 'eq', 'XML::Smart', 'Control Test' ); done_testing() ; }; done_testing() ;

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Fixed in just uploaded 1.79 Details of fix below (in case you want to use it before the new version shows up on PAUSE) Diff details: --- a/lib/XML/Smart.pm +++ b/lib/XML/Smart.pm @@ -1156,7 +1156,10 @@ sub ret { my ($back , $key , $i) = $this->back ; if( $type =~ /\$$/ ) { - @ret = $back->{$key}[$i]->content ; + + my $val = $back->{$key}[$i]->content ; ## Changed call to scalar context so content does break (bug:89228) + @ret = ( $val ); + } elsif( $type =~ /\@$/ ) { @ret = @{$back} ; @@ -1174,7 +1177,10 @@ sub ret { return ; } - if ($type =~ /\$$/) { @ret = $this->content ; } + if( $type =~ /\$$/ ) { ## Changed call to scalar context so content does break (bug:89228) + my $val = $this->content ; + @ret = ( $val ) ; + } elsif ($type =~ /\@$/) { @ret = @{$this} ; } elsif ($type =~ /\%$/) { @ret = %{$this} ; } elsif ($type =~ /\.$/) { @ret = $this->pointer ; } @@ -1424,7 +1430,6 @@ sub content { } else { return $content_to_return ; } - }