How to print variables in Perl

How did Perl complain? print $ids should work, though you probably want a newline at the end, either explicitly with print as above or implicitly by using say or -l/$\. If you want to interpolate a variable in a string and have something immediately after it that would looks like part of the variable but isn’t, enclose the variable name in {}:

How can I call a shell command in my Perl script?

How to run a shell script from a Perl program 1. Using system system($command, @arguments); For example: System will execute the $command with @arguments and return to your script when finished. You may check $! for certain errors passed to the OS by the external application. Read the documentation for system for the nuances of how … Read more

Find size of an array in Perl

The first and third ways are the same: they evaluate an array in scalar context. I would consider this to be the standard way to get an array’s size. The second way actually returns the last index of the array, which is not (usually) the same as the array size.

How to fix a locale setting warning from Perl

Your OS doesn’t know about en_US.UTF-8. You didn’t mention a specific platform, but I can reproduce your problem: % uname -a OSF1 hunter2 V5.1 2650 alpha % perl -e exit perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LC_ALL = (unset), LANG = “en_US.UTF-8” are supported and installed on your … Read more

How do I completely mirror a web page?

If your just looking to run a command and get a copy of a web site, use the tools that others have suggested, such as wget, curl, or some of the GUI tools. I use my own personal tool that I call webreaper (that’s not the Windows WebReaper though. There are a few Perl programs … Read more

Global symbol requires explicit package name

Have a look at perldiag: Global symbol “%s” requires explicit package name (F) You’ve said “use strict” or “use strict vars”, which indicates that all variables must either be lexically scoped (using “my” or “state”), declared beforehand using “our”, or explicitly qualified to say which package the global variable is in (using “::”).

How do I use the MOSS script?

Seems one should be registered to use it, instructions weren’t clear on the site. I received the email finally with userid and ran the script, this time it worked.

What does “if (1)” do?

Technically, the if (1) does nothing interesting, since it’s an always-executed if-statement. One common use of an if (1) though is to wrap code you’d like to be able to quickly disable, say for debugging purposes. You can quickly change an if (1) to if (0) to disable the code.

How to decrypt hash stored by bcrypt

You’re HASHING, not ENCRYPTING! What’s the difference? The difference is that hashing is a one way function, where encryption is a two-way function. So, how do you ascertain that the password is right? Therefore, when a user submits a password, you don’t decrypt your stored hash, instead you perform the same bcrypt operation on the user input and compare … Read more