ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Yes, but providing a Perl solution would amount to doing his homework for him.
Yes, you are right, but I think the great problem of the OP will be to understand the solution (which is good, he should learn).
My concern is that once anyone uses the searchfunction of LQ in order to find a solution for a similar problem he will be mislead into this thread. Therefore off-topic posts are not very helpful on the long run. Maybe it's the best solution if a Moderator closes this thread.
I disagree entirely. These posts are not "off topic". They are expansions of the topic.
First of all, there's nothing special going on here. This kind of thing happens all the time in threads like this. There's an interesting challenge offered, so people naturally tend to want to try their hand at it. Since it's homework, we are deliberately avoiding solving it in the required way, but there's nothing stopping us from playing around with other tools instead. And we post the solutions we come up with in order to share all the different ways there are to solve the problem.
This does also provide valuable advice to the OP, by the way, without giving away the answer directly. Techniques used in one language are very often transferable to another, with just a little adaptation work. Besides, even if they aren't immediately useful, they might teach him something else he can use later on.
In fact, the only serious criticism I'd make concerning this thread would be towards the one person who actually posted a direct Perl solution to a problem that was obviously homework.
And that final argument is a bit weak, don't you think? The thread title itself doesn't mention Perl specifically, it only says "making a number pyramid", so anyone coming across it in a search will expect it to be about that. And if this hypothetical searcher does happen to be looking specifically for a Perl solution, he only has to scan down the thread to see whether one was provided or not; something he's going to do anyway on every thread that appears to match his search topic. Either he'll find something he can use, or he won't and will move on.
Come to think of it, the more solutions we add to the thread, in various languages, the more likely it is to contain something future searchers can use, and the more generally beneficial it will be.
Finally, if the OP would ever return and show us what he finally came up with, or otherwise post a follow up, then we'd be right back on topic, and could hammer out a final solution (or several) in Perl to wrap the thread up with. And if he doesn't show up after a reasonable wait (say a week or so), then we can probably treat the topic as closed, and feel free to post our own anyway.
That's exactly what happened, and your fix didn't change anything. Maybe I'm being too picky, so I'll hush up now.
I'm sorry, maybe there was some confusion. I didn't provide a "fix" in my last post, I only explained what my code was doing. I had simply used a parameter substitution that assumes an empty variable at the start. When you combined the two versions together, you broke that assumption.
So yes, as long as you run my revised version directly after the first one, you'll have to unset/reset the variable before that part runs.
I disagree entirely. These posts are not "off topic". They are expansions of the topic.
...
In fact, the only serious criticism I'd make concerning this thread would be towards the one person who actually posted a direct Perl solution to a problem that was obviously homework.
...
Come to think of it, the more solutions we add to the thread, in various languages, the more likely it is to contain something future searchers can use, and the more generally beneficial it will be.
...
Hi David the H.,
I think you are right, I have to say sorry . I've misinterpreted the OP's "lines of code" as an attempt to find a solution. Therefore I did not mean to do his homework but give him a start with Perl. I realized now that I should have been waiting with posting a solution in Perl.
its not a homework... i want to make a number pyramid using #!/usr/bin/perl
i made a half pyramid using nested for, but got errors while trying to make a full one so i need to know
instead of talking, we should help out so that the query is solved and easy for other searchers to find it , maybe get new ideas arising from it.
this is programming and all mind work in different directions, with different logics....
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.