Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the IPC-System-Simple CPAN distribution.

Report information
The Basics
Id: 44731
Status: resolved
Priority: 0/
Queue: IPC-System-Simple

People
Owner: PJF [...] cpan.org
Requestors: sobek [...] irit.fr
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.18
Fixed in: (no value)



Subject: a bug in IPC-System-Simple
My problem is that I cannot inhibit variable interpolation, etc. under capturex, under IPC-System-Simple-1.18! I call the following line: my @lines = eval(capturex(EXIT_ANY, "$GREP", $mid , @FILES)); where $GREP is the path to grep, @FILES are the files to check, and $mid is a pattern containing a message-id mail header. It is $mid that does not pass! Either I quotemeta() protect it fully, and the pattern is not found by grep, or capturex producees a stack dump about "Possible unintended interpolation of ...". Here is the correct pattern for grep: ^Message-[Ii][Dd]: *<4A233B7B98624E2C8039746A8A06D1D9\@KarenPC> The anti-slash, \, is not necessary for grep. The system perl function does not have this problem! The error messages are appended at the end! perl -v: This is perl, v5.8.0 built for sun4-solaris uname -a: SunOS sareena 5.8 Generic_108528-19 sun4u sparc SUNW,Sun-Blade-100 Error messages: Possible unintended interpolation of @KarenPC in string at (eval 16)[/ home/sobek/bin/compare-mail-folders:148] line 1. eval 'surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> ;' called at /home/sobek/bin/compare-mail-folders line 148 main::chk_msg_id('4A233B7B98624E2C8039746A8A06D1D9@KarenPC') called at /home/sobek/bin/compare-mail-folders line 91 Bareword found where operator expected at (eval 16)[/home/sobek/bin/ compare-mail-folders:148] line 2, near "<4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames" eval 'surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> ;' called at /home/sobek/bin/compare-mail-folders line 148 main::chk_msg_id('4A233B7B98624E2C8039746A8A06D1D9@KarenPC') called at /home/sobek/bin/compare-mail-folders line 91 (Missing operator before surnames?) eval 'surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> ;' called at /home/sobek/bin/compare-mail-folders line 148 main::chk_msg_id('4A233B7B98624E2C8039746A8A06D1D9@KarenPC') called at /home/sobek/bin/compare-mail-folders line 91 Possible unintended interpolation of @KarenPC in string at (eval 16)[/ home/sobek/bin/compare-mail-folders:148] line 2. eval 'surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> ;' called at /home/sobek/bin/compare-mail-folders line 148 main::chk_msg_id('4A233B7B98624E2C8039746A8A06D1D9@KarenPC') called at /home/sobek/bin/compare-mail-folders line 91 Bareword found where operator expected at (eval 16)[/home/sobek/bin/ compare-mail-folders:148] line 3, near "<4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames" eval 'surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> ;' called at /home/sobek/bin/compare-mail-folders line 148 main::chk_msg_id('4A233B7B98624E2C8039746A8A06D1D9@KarenPC') called at /home/sobek/bin/compare-mail-folders line 91 (Missing operator before surnames?) eval 'surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> ;' called at /home/sobek/bin/compare-mail-folders line 148 main::chk_msg_id('4A233B7B98624E2C8039746A8A06D1D9@KarenPC') called at /home/sobek/bin/compare-mail-folders line 91 Possible unintended interpolation of @KarenPC in string at (eval 16)[/ home/sobek/bin/compare-mail-folders:148] line 3. eval 'surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> ;' called at /home/sobek/bin/compare-mail-folders line 148 main::chk_msg_id('4A233B7B98624E2C8039746A8A06D1D9@KarenPC') called at /home/sobek/bin/compare-mail-folders line 91 Error abort = Illegal octal digit '8' at (eval 16)[/home/sobek/bin/ compare-mail-folders:148] line 1, at end of line syntax error at (eval 16)[/home/sobek/bin/compare-mail-folders:148] line 1, near "31:" Global symbol "@KarenPC" requires explicit package name at (eval 16)[/ home/sobek/bin/compare-mail-folders:148] line 1. Illegal octal digit '8' at (eval 16)[/home/sobek/bin/compare-mail- folders:148] line 2, at end of line Global symbol "@KarenPC" requires explicit package name at (eval 16)[/ home/sobek/bin/compare-mail-folders:148] line 2. Illegal octal digit '8' at (eval 16)[/home/sobek/bin/compare-mail- folders:148] line 3, at end of line Global symbol "@KarenPC" requires explicit package name at (eval 16)[/ home/sobek/bin/compare-mail-folders:148] line 3. The lines listed as: surnames.family.08-31:Message-ID: <4A233B7B98624E2C8039746A8A06D1D9@KarenPC> are the 3 $result lines of the grep function. The $result does NOT make it through! Sincerely, --Ralph Sobek
Subject: Unintended interpolation of variables in capturex()
G'day Ralph, I'm going to apologise for my short response, I'm currently interstate and using a free internet service provided by a bus-stop as my connection. On Wed Apr 01 13:04:01 2009, sobek@irit.fr wrote: Show quoted text
> my @lines = eval(capturex(EXIT_ANY, "$GREP", $mid , @FILES));
I'm a little perplexed what the 'eval' is doing here. 'eval' in this context is a string eval, which tells perl to interpret its arguments as perl code and execute them. Unless your files contain actual perl code you wish to evaluate, I would have expected your line to be: my @lines = capturex(EXIT_ANY, $GREP, $mid, @FILES); If the eval has another purpose, I can't fathom it, and would appreciate a further explanation. If the eval is there mistakenly, is there any chance you could remove it and tell me if the problem still persists? Many thanks, Paul
Subject: Re: [rt.cpan.org #44731] Unintended interpolation of variables in capturex()
Date: Mon, 6 Apr 2009 20:07:38 +0200
To: bug-IPC-System-Simple [...] rt.cpan.org
From: Ralph SOBEK <sobek [...] irit.fr>
Hi Paul, You are absolutely right! But the code was suggested in the man page section in order to protect from exceptions within the code: eval { run("cat *.txt"); }; if ($@) { print "Something went wrong - $@\n"; } As such, is it possible to protect from exceptions here? Thanks for your answer, --Ralph Show quoted text
>>>>> "PvR" == PJF via RT <bug-IPC-System-Simple@rt.cpan.org> writes:
Show quoted text
PvR> <URL: https://rt.cpan.org/Ticket/Display.html?id=44731 > PvR> G'day Ralph,
Show quoted text
PvR> I'm going to apologise for my short response, I'm currently interstate PvR> and using a free internet service provided by a bus-stop as my connection.
Show quoted text
PvR> On Wed Apr 01 13:04:01 2009, sobek@irit.fr wrote:
Show quoted text
>> my @lines = eval(capturex(EXIT_ANY, "$GREP", $mid , @FILES));
Show quoted text
PvR> I'm a little perplexed what the 'eval' is doing here. 'eval' in this PvR> context is a string eval, which tells perl to interpret its arguments as PvR> perl code and execute them.
Show quoted text
PvR> Unless your files contain actual perl code you wish to evaluate, I would PvR> have expected your line to be:
Show quoted text
PvR> my @lines = capturex(EXIT_ANY, $GREP, $mid, @FILES);
Show quoted text
PvR> If the eval has another purpose, I can't fathom it, and would appreciate PvR> a further explanation. If the eval is there mistakenly, is there any PvR> chance you could remove it and tell me if the problem still persists?
Show quoted text
PvR> Many thanks,
Show quoted text
PvR> Paul
G'day Ralph, On Mon Apr 06 14:08:25 2009, sobek@irit.fr wrote: Show quoted text
> You are absolutely right! But the code was suggested in the man > page > section in order to protect from exceptions within the code:
Aha! You've discovered the difference between eval(), which does a "string eval", and eval {}, which does a "block eval". The first considers its argument to be a string of Perl code, and evaluates it. It's almost never something you want. The second acts just like a "try" block in other languages. So, for your example, you should be able to use: my @lines = eval { capturex(EXIT_ANY, $GREP, $mid, @FILES); }; if ($@) { print "Oh noes! Something went wrong!\n"; } It's unfortunate that Perl has two different forms of 'eval'. If you use the Error module[1] from the CPAN, you can actually write 'try {}' instead of 'eval {}'. Likewise, if you're using Perl::Critic[2], it will complain loudly if it ever sees you using a string eval (since it's almost never needed). All the very best, Paul [1] http://search.cpan.org/search?query=Error [2] http://search.cpan.org/perldoc?perlcritic
Subject: Re: [rt.cpan.org #44731] Unintended interpolation of variables in capturex()
Date: Thu, 9 Apr 2009 20:27:50 +0200
To: bug-IPC-System-Simple [...] rt.cpan.org
From: Ralph SOBEK <sobek [...] irit.fr>
Hi Paul, I _never_ noticed that there wer two different eval's in perl. That solves evrything! Thanks again, for all your help. --Ralph Show quoted text
>>>>> "PJF" == PJF via RT <bug-IPC-System-Simple@rt.cpan.org> writes:
Show quoted text
PJF> <URL: https://rt.cpan.org/Ticket/Display.html?id=44731 > PJF> G'day Ralph,
Show quoted text
PJF> On Mon Apr 06 14:08:25 2009, sobek@irit.fr wrote:
Show quoted text
>> You are absolutely right! But the code was suggested in the man >> page >> section in order to protect from exceptions within the code:
Show quoted text
PJF> Aha! You've discovered the difference between eval(), which does a PJF> "string eval", and eval {}, which does a "block eval".
Show quoted text
PJF> The first considers its argument to be a string of Perl code, and PJF> evaluates it. It's almost never something you want. The second acts PJF> just like a "try" block in other languages.
Show quoted text
PJF> So, for your example, you should be able to use:
Show quoted text
PJF> my @lines = eval { PJF> capturex(EXIT_ANY, $GREP, $mid, @FILES); PJF> };
Show quoted text
PJF> if ($@) { print "Oh noes! Something went wrong!\n"; }
Show quoted text
PJF> It's unfortunate that Perl has two different forms of 'eval'. If you PJF> use the Error module[1] from the CPAN, you can actually write 'try {}' PJF> instead of 'eval {}'. Likewise, if you're using Perl::Critic[2], it PJF> will complain loudly if it ever sees you using a string eval (since it's PJF> almost never needed).
Show quoted text
PJF> All the very best,
Show quoted text
PJF> Paul
Show quoted text
G'day Ralph, On Thu Apr 09 14:28:45 2009, sobek@irit.fr wrote: Show quoted text
> I _never_ noticed that there were two different evals in perl. > Thanks again, for all your help.
Excellent! I'm glad to have helped! All the best, Paul