Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: How to merge cells dynamically using some variable as input in excel using perl

by kcott (Chancellor)
on Jun 21, 2018 at 10:33 UTC ( #1217110=note: print w/replies, xml ) Need Help??

in reply to How to merge cells dynamically using some variable as input in excel using perl

G'day Sandeep Kumar,

Welcome to the Monastery.

"I'm very new to perl, ..."

That's quite OK. We all were once. :-)

There's possibly other issues here but, without being able to see any code outside of the while loop you posted, it would be pure guesswork trying to divine them. So, for now, I'm just going to focus on two areas: the variables $a and $b; and, the use of my.

In perlvar, you'll see that $a and $b are special variables. While you are learning Perl, I strongly recommend that you do not use them for anything except their special purpose. That's a standalone issue unrelated to what follows.

From the code you posted, it looks like you haven't really understood my.

You actually have four instances of "my $a ..." throughout your code; each has its own scope; and, mostly, they do nothing useful as they go out of scope before being used in a meaningful way. Your treatment of $b is similar. Try adding print statements throughout your code to see the values of $a and $b: you may be surprised.

I don't know if you thought you needed my as part of the assignment (you don't, by the way); however, I think it's evident that there's a big hole in your understanding here. I suggest you go back to basics and read: "perlintro: Perl introduction for beginners". That may well raise further questions, which is fine: just ask.

— Ken

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1217110]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2019-02-19 10:44 GMT
Find Nodes?
    Voting Booth?
    I use postfix dereferencing ...

    Results (104 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!