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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re: How to merge cells dynamically using some variable as input in excel using perl by kcott
in thread How to merge cells dynamically using some variable as input in excel using perl by Sandeep Kumar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-16 04:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found