in reply to Re: Read excel column and compare with array
in thread Read excel column and compare with array

Hi, I need to format my output of XL column : But not getting as expected ...

AR-AB-1111 AR-AB-23213 AR-AB-232 AR-AB-234 AR-AB-1 AR-AB-4 AR-AB-32 AR-AB-21 AR-AB-32

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use XML::XPath; use Spreadsheet::Read; my $book = ReadData("C:/SLB/Dashboard/DCSS_Applications.xlsx"); my $sheet = $book->[1]; # first data sheet my @column = ($sheet->{cell}[3]); # 2nd column, unformatted #@column =~ s/EAR-AA-//; use feature 'say'; foreach my $row (@column) { for (@$row) { my $rowdata; #say $_ if (defined); $rowdata = @$row; say $rowdata =~ s/AR-AB-//; } }

Expected output :

1111 23213 232 234 1 4 32 21 32

Replies are listed 'Best First'.
Re^3: Read excel column and compare with array
by Corion (Patriarch) on Aug 08, 2017 at 08:48 UTC

    Can you explain in English what this part of your code does?

    $rowdata =~ s/EAR-AA-//;

    Your input data as shown will not match the replacement.

      Sorry by mistake,I edited it .

        The return value of the s/// operator is the number of substitutions.

        Use the following instead:

        $variable =~ s/foo/bar/; say $variable;