Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Nov 8, 2024
1 parent b6e7dbe commit 0b3ceb0
Show file tree
Hide file tree
Showing 12 changed files with 313 additions and 13 deletions.
2 changes: 1 addition & 1 deletion sites/en/pages/multiple-expected-values.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
=status show
=books testing
=author szabgab
=comments_disqus_enable 1
=comments_disqus_enable 0

=abstract start

Expand Down
21 changes: 20 additions & 1 deletion sites/en/pages/open-and-read-from-files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
=status show
=books beginner
=author szabgab
=comments_disqus_enable 1
=comments_disqus_enable 0

=abstract start

Expand Down Expand Up @@ -193,3 +193,22 @@ if (open(my $fh, '<:encoding(UTF-8)', $filename)) {
</code>


<h2>Comments</h2>

Does opening $filename within if condition automatically close the file after reading ?
If not, How can I close this file ?

No, you must close the file yourself with the close() function. In the examples above it would be close($fh).

That's not exactly true.

"The filehandle will be closed when its reference count reaches zero. If it is a lexically scoped variable declared with my, that usually means the end of the enclosing scope."
Copied from here: https://perldoc.perl.org/functions/open

<hr>

So reading with <> is reading line-by-line.
This is great for files, but I'm interested in pipes.
How to read all the available data from pipe, without waiting for \n or EOF to come?

use read https://perlmaven.com/search/read
2 changes: 1 addition & 1 deletion sites/en/pages/open.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=indexes open
=status show
=author szabgab
=comments_disqus_enable 1
=comments_disqus_enable 0

=abstract start

Expand Down
11 changes: 10 additions & 1 deletion sites/en/pages/packaging-with-makefile-pl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
=books advanced
=status show
=author szabgab
=comments_disqus_enable 1
=comments_disqus_enable 0

=abstract start

Expand Down Expand Up @@ -88,4 +88,13 @@ that would install the module in the right place.

On MS Windows, instead of <hl>make</hl> you'd probably have either <hl>dmake</hl> or <hl>nmake</hl> depending the toolchain you have.

<h2>Comments</h2>

I tried the command "make" on my WIN10 device , but it shows "'make' is not recognized as an internal or external command".
Do you know how to fix this ?

As Gabor noted on another article in this series:

On MS Windows, instead of make you'd probably have either dmake or nmake depending the toolchain you have.


5 changes: 4 additions & 1 deletion sites/en/pages/parsing-nan-in-json.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=indexes JSON, NaN
=status show
=author szabgab
=comments_disqus_enable 1
=comments_disqus_enable 0

=abstract start

Expand Down Expand Up @@ -107,4 +107,7 @@ $VAR1 = {
The JSON parsers of Perl are correct in <b>not</b> parsing <hl>NaN</hl>.
The file created by the Python script was invalid.

<h2>Comments</h2>

No - they are incorrect - I have a string this is JSON serialized, but it needs to be turned into actual JSON. NaN is a valid value. JavaScript is not a real programming language and I hope someone replaces it for the web soon.

15 changes: 14 additions & 1 deletion sites/en/pages/perl-arrays.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
=status show
=books beginner
=author szabgab
=comments_disqus_enable 1
=comments_disqus_enable 0

=abstract start

Expand Down Expand Up @@ -209,3 +209,16 @@ $VAR1 = [
'Baz',
];
</code>

<h2>Comments</h2>

Great arrays tutorial, but i still feel lack of unshift operation- i use it to reverse an array, like while debugging, to access latest caller($i) element as first of @stack array

my @stack;
for ($i=0;;$i++) {
my ($pack, $fn, $ln, $subr) = caller($i);
last unless ($pack);
unshift (@stack,[$pack, $fn, $ln, $subr]);
}


59 changes: 58 additions & 1 deletion sites/en/pages/perl-cgi-script-with-apache2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
=status show
=books beginner, cgi
=author szabgab
=comments_disqus_enable 1
=comments_disqus_enable 0

=abstract start

Expand Down Expand Up @@ -347,3 +347,60 @@ Of course using PSGI is much more <a href="/modern-web-with-perl">modern</a> and
than CGI. For that you might want to check out the <a href="/dancer">Perl Dancer</a>, or the <a href="/mojolicious">Mojolicious</a> frameworks.
They provide a better experience.

<h2>Comments</h2>

I just wanted to thank you for this detailed guide. I've been trying to get perl running correctly with Apache2 for so long I never thought i'd see it run. I think all the other guides must have assumed some other software was present, but this guide worked from a fresh install, thanks so much!

<hr>

Mirroring the previous comment; thanks so much. I went through a bunch of guides and posts but ultimately this was the one that got my Perl working.

Such a good job. I am definitely bookmarking this site!!

<hr>

This link is spot on and thanks to Gabor for this effort.

<hr>
Thanks for the hint about the AH01257 error in Apache; I just spun up a new DO droplet and was being vexed by that one.

<hr>
Thanks for the great guide!

I am running into an issue where test.pl never loads - no errors in the browser and no errors in the logs. Do you know what could cause this? The link is https://stroh.family/cgi-bin/test.pl


You'd probably need to describe the situation in more detail to get help. e.g. What if you run "perl test.pl" on the command line? What is in test.pl? What are the rights on that file? What is in the web server configuration file?


Can you run ./test.pl as well ? Without prefixing with perl.


Yep, that gives the same output as when using the Perl prefix.


Then I ran out of ideas for this remote debugging session.

I appreciate the help! I will keep working and will update my initial comment if I figure it out.

<hr>

How works that with nginx? Thank you very mich.

<hr>

It is really a great post. Things happen exactly as described and they are explained!. The "Trouble shooting" section is very usefull too. Thanks a lot Gabor. One question: why do you suggest creating /var/cgi-bin directory instead of using the existing one /usr/lib/cgi-bin (on Debian Jessie) ? And with your permission one suggestion: Nowadays most of the sites are secured with SSL certificates. Thus the virtual host configuration file to be modified concerns <virtualhost *:443=""> Maybe it's worth to be mentionned.


I think the reason was that I want to be sure it is not overwritten when an upgrade to the OS happens.

Regarding https, mentioning it might be a good idea, but configuring it would need another post. Maybe with a link here: https://code-maven.com/the-importance-of-https

<hr>

Am a perl developer and am following your page for improving my knowledge in perl.
During lockdown i started implementing perl projects in my personal computer. So i installed the Strawberry perl in my windows machine. Perl Script is running fine in cmd prompt. Could please guide me how to install apache in windows machine and configuring the conf files to run the perl files in website?

My suggestion would be to install Linux in a VirtualBox environment or to use Docker on that Windows.

Thanks for the info!
22 changes: 21 additions & 1 deletion sites/en/pages/perl-command-line-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=indexes -v, -e, -E, -p, -i
=status show
=author szabgab
=comments_disqus_enable 1
=comments_disqus_enable 0

=abstract start

Expand Down Expand Up @@ -245,3 +245,23 @@ There are a number of screencasts showing some of the command line options:

Another article show an example of <a href="/perl-on-the-command-line">Perl on the command line using -e, -p, -i</a>.

<h2>Comments</h2>

Your code snippet for -p has a bug (two bugs; -p works subtly differently from what your translation suggests, which you can show by including a next in the program): you need a ; after the s/// statement, or it's not valid Perl.

<hr>

Ooh. I didn't know -E. I'd been using -M5.010 -e.

<hr>
Thanks..Can we see at which line the changes has been done?
<hr>


perl main_raman_bfl.pl -p 1 -i 1 -e 0
This Perl not built to support threads
Compilation failed in require at main_raman_bfl.pl line 5.
BEGIN failed--compilation aborted at main_raman_bfl.pl line 5.

What is issue?

12 changes: 11 additions & 1 deletion sites/en/pages/perl-editor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
=status show
=books beginner
=author szabgab
=comments_disqus_enable 1
=comments_disqus_enable 0

=abstract start

Expand Down Expand Up @@ -81,3 +81,13 @@ In October 2009 I ran a poll and asked <a href="http://perlide.org/poll200910/">

While they are native to Unix/Linux, both <b>Emacs</b> and <b>Vim</b> are available for all the other major operating systems.

<h2>Comments</h2>

It's worth to mention that instead of Sublime there is also a free editor called Atom, very similar to Sublime in functionality. I'm not a user of it, because I still prefer vim.

<hr>
Perl plugin in intellij works well, I have been using it since quiet some time.

<hr>

VS code is also a great editor :)
Loading

0 comments on commit 0b3ceb0

Please sign in to comment.