Re: An issue of Scope that I do not understand

2015-02-28 Thread Martin G. McCormick
Charles DeRykus writes: > You could also simplify the closure since @tasks is in the closure's > lexical scope, eg, > > my $report_static = sub { print $tasks[$iter++]; ... }; > > foreach $task (@tasks) { > if (...) > $report_statics->(); > else > $report_dynami

Re: An issue of Scope that I do not understand

2015-02-28 Thread Martin G. McCormick
Shlomi Fish writes: http://perl-begin.org/tutorials/bad-elements/#declaring_all_vars_at_top > > (Note: perl-begin.org is a domain I originated and maintain). Shlomi Fish, Uri and Brock, I certainly wish I had known about a resource like this earlier in my relatively short perl career.

Re: An issue of Scope that I do not understand

2015-02-27 Thread Martin G. McCormick
Brock Wilcox writes: > I'm afraid a bit more context is needed to identify the problem. Could you > post your entire bit of code into a gist or pastebin or something for us > to > see? I'll do better than that. This is a script which is stripped of everything but the problem code. It is 2

An issue of Scope that I do not understand

2015-02-27 Thread Martin G. McCormick
I put together an anonymous subroutine which partly works. There is an array called @tasks which is defined as a local variable in the main routine and when I call the anonymous subroutine, one can still read all the elements in @tasks. There is also a single scaler called $task, a

Re: Is There a Way to Make Uninitialized Warnings Fatal?

2014-12-10 Thread Martin G. McCormick
Nathan Hilterbrand writes: > Just firing from memory here... That was extremely good from memory. I tried the code and it just worked except for one line which appears that it should cause the warning to be printed since we are catching a signal and probably need to recreate the warning by feeding

Re: Is There a Way to Make Uninitialized Warnings Fatal?

2014-12-10 Thread Martin G. McCormick
Nathan Hilterbrand writes: > Just firing from memory here... > > my $warning_occured = 0; > my $default_warn = $SIG{__WARN__}; > $SIG{__WARN__} = sub { > $warning_occured = 1; > $default_warn(@_); > } > > Then in later code: > if ($warning_occured) { > # Code to run if a w

Is There a Way to Make Uninitialized Warnings Fatal?

2014-12-10 Thread Martin G. McCormick
We've all seen and probably pounded the table a few times when that "Use of uninitialized value" warning pops up. Recently a worker in our group ran a script I wrote and got that warning due to an unforeseen circumstance. Unfortunately since the script continues to run, the caller w

Re: What Happened to Net::DNS and a few others on December 1?

2014-12-02 Thread Martin G. McCormick
Shlomi Fish writes: > There could be several reasons: > > 1. The @INC of the installed module was perl-version-specific. E.g in my > perl > -V: > As you can see, some of them are versioned and if the previous versions > are not > added to the inc of the new perl, the modules installed there won

What Happened to Net::DNS and a few others on December 1?

2014-12-02 Thread Martin G. McCormick
We run some FreeBSD systems using FreeBSD9.1 and 9.3 and the response to perl -version is: This is perl 5, version 18, subversion 4 (v5.18.4) built for amd64-freebsd-thread-multi On December 1 of 2014, we were alerted to the fact that some perl scripts were no longer working. The

Net::DNS::Update

2014-09-18 Thread Martin G. McCormick
Are the packets built with this module using udp or tcp? I have been having mostly excellent results adding and deleting forward and reverse IP addresses using it, but on occasion, things that were supposed to go away did not and we ended up with a mess. I understand from the examples I hav

Re: When a File Exists and is Empty

2014-09-11 Thread Martin G. McCormick
Shawn H Corey writes: > Yes, Perl does follow the shell when it comes to file tests. See > `perldoc -f -X > > Also, you can use `-s` instead of `! -z`. Thank you. That's very close to the test -s clause in shell scripting. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For ad

When a File Exists and is Empty

2014-09-11 Thread Martin G. McCormick
I was checking to see how in perl can one quickly test for a file which exists but is empty and found an example so I wrote the following code which seems to work beautifully but it looks a little different compared to some things I have seen so I am asking whether it could have unintended

Re: Why Does the Following Not Work? Solved!

2014-07-31 Thread Martin G. McCormick
I thought I was loosing my mind. Please read everything. John SJ Anderson writes: > > die("***YOU MUST HAVE A DESTINATION ADDRESS/NETWORK address.\n") > > if (@destinations); > > Don't you mean 'if !@destinations' or 'unless @destinations' here? > That test is for whether @destinations ha

Re: Why Does the Following Not Work?

2014-07-30 Thread Martin G. McCormick
Ken Slater writes: > Your logic is backwards. You are testing for at least one destination with > no from_addresses. First, thank you. This actually gets more strange. I took out the && and left only a statement that tests: die("***YOU MUST HAVE A DESTINATION ADDRESS/NETWORK addr

Why Does the Following Not Work?

2014-07-30 Thread Martin G. McCormick
There are two arrays or lists. One is called @from_addresses and the other is @destinations. For the program to work, there must be at least one, possibly many strings in each of those arrays. Never under any circumstance should there be an empty @destinations list when there is even one st

Useful Constructs (was About staying brushed up on perl)

2014-07-28 Thread Martin G. McCormick
One thing I just started working with is the anonymous subroutine as in $stringmuncher = sub { }; It lets one execute the same code multiple times from other code in the same scope without having to define and then pass values to lots of different variables. As long as one und

Re: About staying brushed up on perl

2014-07-26 Thread Martin G. McCormick
mimosin...@gmail.com writes: > I have self-learned Perl about a couple of years ago and I am also having > a > similar use of Perl, so I often forget how I did things. I must also say > that I am about to be 50 years old next December and I do not have any > technical education as my degree is in

No Lines are Breakable.

2014-05-21 Thread Martin G. McCormick
I have a large perl script that checks clean when running perl -c scriptname. It also executes when called without throwing error messages but suddenly, any line I give it while in the debugger initially reports "Line [any_number] not breakable. I can load the script with perl -d s

Output of expect commands in to Strings Solved

2014-04-03 Thread Martin G. McCormick
After further study, I probably would have had to setup a named pipe to capture expect's output in to strings which would have not bought me anything useful for this situation. We needed to know what was going on with expect as it happened, not after the fact. More study shows that there is

Output of expect commands in to Strings

2014-04-02 Thread Martin G. McCormick
When using the expect module in a perl program, one can log expect output to a file with a command like $exp->log_file($somefilename); You can turn off STDOUT with $exp->log_stdout(0); Is there a way to capture either the file output or expect's STDOUT directly i

Re: Skipping X Number of Iterations before Stopping on a Break Point

2014-02-28 Thread Martin G. McCormick
Shlomi Fish writes: > Hi Martin, > I know of several options for that: > > 1. Use a package-scope count variable: e.g, do: > > <> > > 2. source a file (see "source" on "perldoc perldebug") that will contain > several "c" statements. > > 3. Maybe try Devel::Trepan instead: > https://metacpan.o

Skipping X Number of Iterations before Stopping on a Break Point

2014-02-27 Thread Martin G. McCormick
I am running a script under perl -d and want to break execution at line 243 in this case. perl -d scriptname loads the script in to the debugger and b 243 sets the break point. c then Enter starts the program which runs until it reaches the desired line at which point it stops. All I want t

A Small Contribution to the List

2014-01-30 Thread Martin G. McCormick
After being informed about the File::Copy module, I started exploring a bit. Since these perl modules have man pages, the apropos command is extremely handy. I tried apropos File:: and found a list of several utilities in that suite which one can then man File::X to learn more about what is there

Solved mv Is Not Working the Same Way Under System as Under a Shell.

2014-01-30 Thread Martin G. McCormick
This is a classic example of the admonition, "Never trust data." I did try the following: David Precious writes: > change "system" to "print" to print out the command that would be run, > and (a) you'll likely see the problem, or (b) you can try running that > exact command.

Re: mv Is Not Working the Same Way Under System as Under a Shell.

2014-01-30 Thread Martin G. McCormick
"Ron Bergin" writes: > As has already been mentioned, part of the problem is your quoting. > > What is the value of $directories and more specifically, does it end with > a forward slash? Personally, I prefer to leave off the trailing dir > separator because IMO it makes it more clear later when

Re: mv Is Not Working the Same Way Under System as Under a Shell.

2014-01-30 Thread Martin G. McCormick
David Precious writes: > change "system" to "print" to print out the command that would be run, Great suggestion! I actually did try that using echo instead of print so that system was still involved and the values were correct. It looked beautiful. > and (a) you'll likely see the problem, or (b)

mv Is Not Working the Same Way Under System as Under a Shell.

2014-01-30 Thread Martin G. McCormick
I have a perl script that I run as root which needs to move a file from where it is to another directory. I keep getting the "Usage" help message and a permission denied. If I su to root and manually make the move, it works. The perl script is not trying to run suid to ro

Using Files in Chronological Order

2014-01-27 Thread Martin G. McCormick
This is a perl philosophy question. I need to look for some files, newest first. If I use the glob directive in perl, I can fill an array with all the file names that match the pattern but they aren't sorted in to chronological order. I found a perlmonks posting in which the same question w

Still Trying to Understand Perl Module Control Process

2014-01-14 Thread Martin G. McCormick
I am using cpanp or cpan plus to handle perl modules on a FreeBSD system. If I give the command cpanp -i Net::DNS it installs Net::DNS 0.73. Normally, this is exactly what one would want it to do but Net::DNS0.73 is buggy. At least one bug causes domain name server or DNS updates to fail s

Re: Best Way to Downgrade Perl Module Net::DNS

2014-01-10 Thread Martin G. McCormick
Shlomi Fish writes: > Hi Martin, > > see https://metacpan.org/release/App-pmuninstall . > > and just for reference, when using Mageia Linux, I normally prefer > packaging > every CPAN distrbution as an .rpm using the tools given here: Thank you. I appreciate this. I use both Linux and F

Best Way to Downgrade Perl Module Net::DNS

2014-01-09 Thread Martin G. McCormick
I have been writing a perl script that uses the Net::DNS modules. After banging my head, so to speak for many days, I asked on a DNS-related discussion list for help in figuring out why name server updates had started always failing with errors about not auth and BADKEY when I seem to recal