Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Adding empty value in an Array!

by chandantul (Scribe)
on Mar 10, 2021 at 17:38 UTC ( #11129413=perlquestion: print w/replies, xml ) Need Help??

chandantul has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Adding empty value in an Array!
by davido (Cardinal) on Mar 10, 2021 at 18:40 UTC

    I assume you are using Spreadsheet::ParseExcel. So I'll try to help with that assumption.

    First, though; what is this line doing?

    for my $col10 ( $col_min = 1) {

    $col10 will only ever contain one value, the integer 1. And you aren't using $col10 ever. And the loop only happens once. It seems broken.

    As for getting the value, it seems like this is what you want:

    $cell0 = $cello->value; push @cello, length($cell0) ? $cell0 : $no2;

    This will push into @cello either the value held in $cell0, or if there is no value (empty string, or undef), it will push in whatever is stored in $no2.

    Your question, as asked, leaves a lot of questions unanswered. Imagine a kid asking his parent "How do I get there?" And the parent has to ask "Where?" and then has to follow up with "Where are you now?", and then "What mode of transportation?" You know more about this problem than we do. Please be sure when you ask, that you provide enough context so that we don't have to guess where you are coming from and where you are going.


      Thanks for the response Dave. Yes I would like to replace the empty value with $no2 = "NO Email ID exist"

Re: Adding empty value in an Array!
by marto (Cardinal) on Mar 10, 2021 at 18:41 UTC
Re: Adding empty value in an Array!
by BillKSmith (Monsignor) on Mar 11, 2021 at 16:41 UTC
    Although the style is poor, your code can be fixed with minor changes. If by 'empty values' you mean 'empty strings', remove the line next.... If you mean 'undefined', you must also change
    #if ( $cellO eq "" ) { if (!defined $cellO) {

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11129413]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2022-06-26 01:28 GMT
Find Nodes?
    Voting Booth?
    My most frequent journeys are powered by:

    Results (83 votes). Check out past polls.