On 05/14/2017 08:02 AM, Shawn H Corey wrote:
On Sun, 14 May 2017 02:08:11 +0100
lee wrote:
I haven't used 'eval' before, and this seems inherently dangerous.
eval EXPR;
eval;
These are dangerous.
eval BLOCK
This is not.
just to clarify and add to shawn
On 11-04-25 09:20 PM, siegfr...@heintze.com wrote:
Is there a counterpart to the
lisp set function in Perl?
Not really. Consider using a hash instead.
$hash{x} = 23;
To view your data structures, use Data::Dumper;
use Data::Dumper;
print Dumper( \%hash );
Data::Dumper is a standard module
2011/4/26 :
>
>
> $s = "$x = 23";
> eval $s;
>
>
eval a string is considered a bad way.
You may store and read the variables to and from a pure Perl data
structure storage, like Tie::Hash.
Regards.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For
Ooops, I forgot to use plain text when I sent this the first time. Sorry
if this appears twice.
I want read some variable names and values out of a flat (xml) file and
assign them.
I suppose I could write
$s = "$x = 23";
eval $s;
Is this the best way? Is there a better way? In lis
s ($@);
>
>
> I use:
>
> if (not $@) {return 1;}
>
>
>
> OR
>
> return 1 if (not $@);
>
>
>
> the syntax error does not get printed out. I assumed that these statements
> were logically equal, so, what gives?
I'm not sure. As Ruud mentioned, the
On 2010-10-01 04:37, Jon Hermansen wrote:
sub is_valid_xml {
my ($content) = @_;
eval {
my $xs = XML::Simple->new();
my $ref = $xs->parse_string($content);
};
return 1 unless ($@);
}
Don't test the truth of $@, but use the return value
On Thu, Sep 30, 2010 at 8:34 PM, C.DeRykus wrote:
> On Sep 30, 7:37 pm, jon.herman...@gmail.com (Jon Hermansen) wrote:
> > Hey all,
> > I have this block of code:
> >
> > sub is_valid_xml {
> >
> > > my ($content) = @_;
> >
> >
On Sep 30, 7:37 pm, jon.herman...@gmail.com (Jon Hermansen) wrote:
> Hey all,
> I have this block of code:
>
> sub is_valid_xml {
>
> > my ($content) = @_;
>
> > eval {
> > my $xs = XML::Simple->new();
> > my $ref = $xs->parse
Hey all,
I have this block of code:
sub is_valid_xml {
> my ($content) = @_;
>
> eval {
> my $xs = XML::Simple->new();
> my $ref = $xs->parse_string($content);
> };
>
> return 1 unless ($@);
> }
>
and when I pass in 'bla
Uri Guttman wrote:
"JWK" == John W Krahn writes:
>> Also, how does 'eval' work and when is it useful? What is the difference if
>> we put a block inside eval like: eval ( };
JWK> eval interprets a string as Perl code and compiles and runs it. If
J
>>>>> "JWK" == John W Krahn writes:
>> Also, how does 'eval' work and when is it useful? What is the difference if
>> we put a block inside eval like: eval ( };
JWK> eval interprets a string as Perl code and compiles and runs it. If
J
t does set $. to the total lines read.
Also, how does 'eval' work and when is it useful? What is the difference if
we put a block inside eval like: eval ( };
eval interprets a string as Perl code and compiles and runs it. If you
are using a block eval then the block must be valid
Hello All,
Could you tell me what does the following do?
1 while (<>);
Also, how does 'eval' work and when is it useful? What is the difference if
we put a block inside eval like: eval ( };
--
Regards,
Arun.P.Menon
Hi Xiaolan!
On Sunday 24 Jan 2010 05:37:49 Xiao Lan (小兰) wrote:
> Hi,
>
> what's the difference between do a block and eval a block?
>
> sub test {
> my $bl = shift;
> eval $bl;
> # do $bl;
> }
>
> test { print "hello\n" };
Well,
Hi,
what's the difference between do a block and eval a block?
sub test {
my $bl = shift;
eval $bl;
# do $bl;
}
test { print "hello\n" };
from the code, I see both do and eval work the same.
Thanks.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
On Dec 11, 10:52 am, rvtol+use...@isolution.nl (Dr.Ruud) wrote:
> C.DeRykus wrote:
> > Dr.Ruud:
> >> C.DeRykus:
> >>> eval { asub() };
> >>> die $@ if $@;
>
> >> You need to test the return of eval itself to be sure.
>
>
C.DeRykus wrote:
Dr.Ruud:
C.DeRykus:
eval { asub() };
die $@ if $@;
You need to test the return of eval itself to be sure.
Example:
perl -wle '
die "An error: ", $@ || "whoopy"
if !eval{ asub(); 1 };
sub asub{ my $x = bless {}, "
On Dec 10, 1:21 pm, rvtol+use...@isolution.nl (Dr.Ruud) wrote:
> C.DeRykus wrote:
> > On Dec 8, 1:57 am, dery...@gmail.com (C.DeRykus) wrote:
> >> On Dec 8, 12:08 am, an...@melerit.se (Anders Hartman) wrote:
> >> Also, in this case, I'd write the eval for compil
On Dec 10, 12:57 pm, shawnhco...@gmail.com (Shawn H Corey) wrote:
> C.DeRykus wrote:
> > On Dec 8, 1:57 am, dery...@gmail.com (C.DeRykus) wrote:
> >> On Dec 8, 12:08 am, an...@melerit.se (Anders Hartman) wrote:
>
> >>> ...
>
> >> ...
> >> Also,
C.DeRykus wrote:
On Dec 8, 1:57 am, dery...@gmail.com (C.DeRykus) wrote:
On Dec 8, 12:08 am, an...@melerit.se (Anders Hartman) wrote:
Also, in this case, I'd write the eval for compile-time and check
for errors:
eval { asub() };
die $@ if $@;
No, sorry, that's a "
C.DeRykus wrote:
> On Dec 8, 1:57 am, dery...@gmail.com (C.DeRykus) wrote:
>> On Dec 8, 12:08 am, an...@melerit.se (Anders Hartman) wrote:
>>
>>> ...
>
>> ...
>> Also, in this case, I'd write the eval for compile-time and check
>> for err
On Dec 8, 1:57 am, dery...@gmail.com (C.DeRykus) wrote:
> On Dec 8, 12:08 am, an...@melerit.se (Anders Hartman) wrote:
>
>> ...
> ...
> Also, in this case, I'd write the eval for compile-time and check
> for errors:
>
> eval { asub() };
> die $@ if $
On Dec 8, 12:08 am, an...@melerit.se (Anders Hartman) wrote:
> Hello,
>
> I which to use eval to execute subroutines dynamically.
>
> The following code snippet fails:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> sub asub {
> our $abc;
>
pa...@arcor.de wrote:
> Well, the OP said the method name is changing during the running time, so he
> want to eval the method name.
> So a AUTOLOAD method is right for him as far as I can think.
AUTOLOAD introduces the possibility of code injection. So does eval.
If the code is run
- Original Nachricht
Von: Shlomi Fish
An: beginners@perl.org
Datum: 08.12.2009 12:08
Betreff: Re: Eval scoping question
> On Tuesday 08 Dec 2009 12:18:10 Jeff Pang wrote:
> > Shlomi Fish:
> > > On Tuesday 08 Dec 2009 11:46:59 Jeff Pang wrote:
On Tuesday 08 Dec 2009 12:18:10 Jeff Pang wrote:
> Shlomi Fish:
> > On Tuesday 08 Dec 2009 11:46:59 Jeff Pang wrote:
> >> Shlomi Fish:
> >>> Regarding using string eval "" - you can do the same using
> >>> UNIVERSAL::can, which would be safer i
Shlomi Fish:
On Tuesday 08 Dec 2009 11:46:59 Jeff Pang wrote:
Shlomi Fish:
Regarding using string eval "" - you can do the same using
UNIVERSAL::can, which would be safer in this case:
<<<<
__PACKAGE__->can("asub")->(@params);
or define a package an
On Tuesday 08 Dec 2009 11:46:59 Jeff Pang wrote:
> Shlomi Fish:
> > Regarding using string eval "" - you can do the same using
> > UNIVERSAL::can, which would be safer in this case:
> >
> > <<<<
> > __PACKAGE__->can("asub")->(@
Shlomi Fish:
Regarding using string eval "" - you can do the same using UNIVERSAL::can,
which would be safer in this case:
<<<<
__PACKAGE__->can("asub")->(@params);
or define a package and use AUTOLOAD method?
--
Jeff Pang
http://home.arco
2009/12/8 Anders Hartman :
>>> Hello,
>>> I which to use eval to execute subroutines dynamically.
>>> The following code snippet fails:
>>>
>>> #!/usr/bin/perl
>>>
>>> use strict;
>>> use warnings;
>>>
>>>
On Tuesday 08 Dec 2009 11:03:44 Anders Hartman wrote:
> Jeff Pang skrev:
> > Anders Hartman:
> >> Hello,
> >>
> >> I which to use eval to execute subroutines dynamically.
> >>
> >> The following code snippet fails:
> >>
&g
Jeff Pang skrev:
Anders Hartman:
Hello,
I which to use eval to execute subroutines dynamically.
The following code snippet fails:
#!/usr/bin/perl
use strict;
use warnings;
sub asub {
our $abc;
print $abc;
}
my $abc = "abc\n";
eval "asub";
exit 0;
I don'
Anders Hartman:
Hello,
I which to use eval to execute subroutines dynamically.
The following code snippet fails:
#!/usr/bin/perl
use strict;
use warnings;
sub asub {
our $abc;
print $abc;
}
my $abc = "abc\n";
eval "asub";
exit 0;
I don't think you want
Hello,
I which to use eval to execute subroutines dynamically.
The following code snippet fails:
#!/usr/bin/perl
use strict;
use warnings;
sub asub {
our $abc;
print $abc;
}
my $abc = "abc\n";
eval "asub";
exit 0;
with the error:
Use of uninitialized value i
On Oct 21, 8:31 am, jimsgib...@gmail.com (Jim Gibson) wrote:
> At 3:59 PM -0700 10/20/09, cerr wrote:
>
> >Hi,
>
> >I wanna execute an external bash command but timeout if it's taking
> >longer than XX seconds. I've tried it like this:
> >eval {
At 3:59 PM -0700 10/20/09, cerr wrote:
Hi,
I wanna execute an external bash command but timeout if it's taking
longer than XX seconds. I've tried it like this:
eval {
local $SIG{ALRM} = sub {die "alarm\n"};
alarm $timeout;
$test = `$sshpassPATH . &q
Hi,
I wanna execute an external bash command but timeout if it's taking
longer than XX seconds. I've tried it like this:
eval {
local $SIG{ALRM} = sub {die "alarm\n"};
alarm $timeout;
$test = `$sshpassPATH . " -p ".$clientpw."
Hi all,
Although I've read the docs and have been practising with it, I'm a bit
confused on the use of eval().
For some reason, it took a few swings of the hammer to get past wanting
to look for array elements within $@ :P
I think I now understand the dangers of using eval() to t
Date sent: Tue, 06 Oct 2009 15:45:44 +0200
From: Alexander Koenig
To: beginners
Subject:eval and next
> Hi all,
>
> I have a Perl program where I use eval to catch errors. As they are Java
> errors (via Inline::Jav
Hi all,
I have a Perl program where I use eval to catch errors. As they are Java
errors (via Inline::Java) I want my program to continue and just log the
errors somewhere.
My problem with this is, that I use the eval within a loop and I also
use next in this loop to ignore some special cases
rt perl modules and found
> > > > > something cryptic to myself:
> > > > >
> > > > > package Module;
> > > > >
> > > > > $Module::VERSION = '1.0';
> > > > > $Module::VERSION = eval $Module::V
On Tue, Jun 23, 2009 at 07:54:54PM +0200, Paul Johnson wrote:
>
> >From the docs: http://perldoc.perl.org/perlmodstyle.html#Version-numbering
>
Big thanks.
--
If you think of MS-DOS as mono, and Windows as stereo,
then Linux is Dolby Digital and all the music is free...
--
To unsubscribe, e
> > > something cryptic to myself:
> > > >
> > > > package Module;
> > > >
> > > > $Module::VERSION = '1.0';
> > > > $Module::VERSION = eval $Module::VERSION;
> > > >
> > > > Why eval part is needed here ?
t; >
> > > $Module::VERSION = '1.0';
> > > $Module::VERSION = eval $Module::VERSION;
> > >
> > > Why eval part is needed here ?
> >
> > It's not. What module was that? Maybe you skipped something that was
> > the reason.
>
On Tue, Jun 23, 2009 at 12:46:33PM +0200, Jenda Krynicky wrote:
> From: Roman Makurin
> > Just looked throught some standart perl modules and found
> > something cryptic to myself:
> >
> > package Module;
> >
> > $Module::VERSION = '1.0
From: Roman Makurin
> Just looked throught some standart perl modules and found
> something cryptic to myself:
>
> package Module;
>
> $Module::VERSION = '1.0';
> $Module::VERSION = eval $Module::VERSION;
>
> Why eval part is needed here ?
It's no
Hi all!
Just looked throught some standart perl modules and found
something cryptic to myself:
package Module;
$Module::VERSION = '1.0';
$Module::VERSION = eval $Module::VERSION;
Why eval part is needed here ?
Thanks
PS: sorry for my english
--
If you think of MS-DOS as mono, a
I can run a function this way (in the main package namespace):
&main::aMainFunctionName(@param);
How do I run it with a namespace var?
$space = 'main';
eval \&${space}::aMainFunctionName(\@);
Then, when and if that is possible, can I pass namespace to another
package and
Hi there,
I just wanted to ask if somebody has implementet an "nonblocking" socket reader,
which uses Time::HiRes ualarm() function (or nativ perls alarm function) to
break the "waiting on data in socket (if the socket has no data)"
after a view microsecond... (in eval bloc
on't work
correctly because you don't have a 'foo' filehandle and you can't use
barewords (because of strict) or assign to them.
eval {$cmds};
eval {} is used to evaluate valid perl code but you have a single scalar
variable in void context, hence the message "variab
I should use "eval EXPR", not "eval BLOCK". Thanks!
-Original Message-
From: Zhao, Bingfeng [mailto:[EMAIL PROTECTED]
Sent: Monday, October 20, 2008 11:13
To: Perl Beginners
Subject: How to turn a user perl script in string format into actual
perl commands that eval
w/bar/";
eval {$cmds};
my $result = $_;
print $result;
[/code]
But I got a error: Useless use of private variable in void context at
ss.pl line 7. So how can I do? Thanks in advance.
Best regards,
Bingfeng
Deviloper wrote:
The last time I considered using eval is years ago.
I remember that I had read an article somewhere that doing eval could lead to dramatic performance issues.
I want to use eval{} to check my db-transactions. I looking for informations at
perldoc eval, but there is nothing
On Thu, Oct 16, 2008 at 12:38:54PM +0100, Deviloper wrote:
> The last time I considered using eval is years ago. I remember that I
> had read an article somewhere that doing eval could lead to dramatic
> performance issues.
>
> I want to use eval{} to check my db-transactions
The last time I considered using eval is years ago.
I remember that I had read an article somewhere that doing eval could lead to
dramatic performance issues.
I want to use eval{} to check my db-transactions. I looking for informations at
perldoc eval, but there is nothing mentioned about
"John W. Krahn" schreef:
> s/\\//g;
> s/'/\\'/g;
These two can be combined to
s/(?=[\\'])/\\/g
which I don't expect to be faster; it just makes it easier to add
characters to be escaped.
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PR
Gundala Viswanath wrote:
Hi,
Hello,
This cowde below tries to convert
the string in newick format into the corresponding
data structure (Array of Array).
But somehow the EVAL function doesn't work
as expected. What's wrong with my code here?
__BEGIN__
use Data::Dumper;
use Carp
> my $nstr= $nstr_in;
> for ($nstr) {
> s/\\//g;
> s/'/\\'/g;
> s/\(/['/g;
> s/\)/']/g;
> s/,/','/g;
s/'\[/[/g;
s/\]'/]/g;
> }
>
> return eval{$nstr};
Hi,
This cowde below tries to convert
the string in newick format into the corresponding
data structure (Array of Array).
But somehow the EVAL function doesn't work
as expected. What's wrong with my code here?
__BEGIN__
use Data::Dumper;
use Carp;
my $str = "(foo,(bar,qux))&q
On 3/22/07, Kevin Old <[EMAIL PROTECTED]> wrote:
Not sure why eval isn't working. Nothing is returned if I print $@
after the eval statement.
What do you mean whan you say eval "isn't working"? What is it doing?
Does it run any of the code? The code you inclu
Hello everyone,
I am using Class::InsideOut and am looping through some params passed
and need to set their accessors (identified by the keys passed into my
class), but the following code isn't working.
Not sure why eval isn't working. Nothing is returned if I print $@
after the eval
The general form for block eval is:
#!/usr/bin/perl
use strict;
use warnings;
eval {
die 'There was an error!!!' . "\n";
};
if ($@) {
print $@;
}
print 'On the other side.' . "\n";
Robert
On Feb 19, 2007, at 4:13 PM, Gallagher, Tim F ((NE))
I am working my butt off trying to get eval blocks working. When I run
a pert of perl code, if the code fails I dont want the script to
terminate. Here is what I am talking about:
[CODE]
use Win32::Registry;
eval{
my ($node) = 'ComputerName';
my ($hNode, $hKey, %values);
$HKEY_LOC
On Tue, 27 Jun 2006, Smith, Derek wrote:
So could this `$SIG{'PIPE'}="IGNORE";' be considered a global similar to
$ENV{"PATH"} = qq(/opt/SUNWsamfs/sbin:/usr/bin);
Yes, %SIG is a global hash.
Jorge
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED
-Original Message-
From: Jorge Almeida [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 27, 2006 9:37 AM
To: John W. Krahn
Cc: Perl Beginners
Subject: Re: eval problem
On Tue, 27 Jun 2006, John W. Krahn wrote:
> Jorge Almeida wrote:
>> What is happening?
>
> When find
On Tue, 27 Jun 2006, John W. Krahn wrote:
Jorge Almeida wrote:
What is happening?
When find dies a SIGPIPE signal is sent to the parent process which kills it.
Thank you. Putting `$SIG{'PIPE'}="IGNORE";' in the beginning of my
program solves my problem.
Jorge
--
To unsubscribe, e-mail
Jorge Almeida wrote:
> Can someone help me to understand what's wrong with this? (Or: what I
> didn't understand about eval?)
>
> $ perl -e 'use strict;use warnings;eval{open(OUT,"|file")};eval{print
> OUT "aa\n";};eval{close OUT};;'
>
Can someone help me to understand what's wrong with this? (Or: what I
didn't understand about eval?)
$ perl -e 'use strict;use warnings;eval{open(OUT,"|file")};eval{print OUT
"aa\n";};eval{close OUT};;'
Usage: file [-bcikLnNsvz] [-f namefile] [-F separa
>> It works fine for me:
>But you're cheating and not using my program! :-)
>If I comment out the "use warnings" in my program then it works as
>expected (at least, as *I* expected it to)
>--
>Steve Swift (aka "Swifty")
I used your program and it works for me in case:
$a=1
print $a
1
Maybe U
On Fri, May 05, 2006 at 10:13:00AM -0400, Chas Owens wrote:
>
> By the way, $a and $b are special varaibles used by the sort function
> and therefore do not need to be declared with "my", but it is bad form
> to use them for anything but the sort function. For short examples it
> is best to use $
stem('clear');
system('perl -v');
print "Go on - try a few... Enter 'exit' to end.\n";
while (<>) {
eval $_;
if ($@) {print "[EMAIL PROTECTED]";}
print ' ','.'x50," perltry on $^O\n"
};
If I enter a s
It works fine for me:
But you're cheating and not using my program! :-)
If I comment out the "use warnings" in my program then it works as
expected (at least, as *I* expected it to)
--
Steve Swift (aka "Swifty")
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [
strict;
> use warnings;
> system('clear');
> system('perl -v');
> print "Go on - try a few... Enter 'exit' to end.\n";
> while (<>) {
>eval $_;
>if ($@) {print "[EMAIL PROTECTED]";}
>print '
('clear');
> system('perl -v');
> print "Go on - try a few... Enter 'exit' to end.\n";
> while (<>) {
> eval $_;
> if ($@) {print "[EMAIL PROTECTED]";}
> print ' ','.'x50," perltry on $^
;
> use warnings;
> system('clear');
> system('perl -v');
> print "Go on - try a few... Enter 'exit' to end.\n";
> while (<>) {
>eval $_;
>if ($@) {print "[EMAIL PROTECTED]";}
>print ' ',&
"Go on - try a few... Enter 'exit' to end.\n";
while (<>) {
eval $_;
if ($@) {print "[EMAIL PROTECTED]";}
print ' ','.'x50," perltry on $^O\n"
};
If I enter a statement, such as "$a=1;" (without the quotes)
On 3/7/06, Chas Owens <[EMAIL PROTECTED]> wrote:
> On 3/7/06, Jay Savage <[EMAIL PROTECTED]> wrote:
> snip
> > Since eval traps die, 'eval{ eval {} or die [EMAIL PROTECTED];};' is a
> > convenient
> > method for propagating $@ out of deeply nested e
On 3/7/06, Jay Savage <[EMAIL PROTECTED]> wrote:
snip
> Since eval traps die, 'eval{ eval {} or die [EMAIL PROTECTED];};' is a
> convenient
> method for propagating $@ out of deeply nested evals. It's just a way
> to save writing lots of if blocks that do nothing
On 3/6/06, Tom Allison <[EMAIL PROTECTED]> wrote:
> Jay Savage wrote:
>
> >
> > die on errors and just keep passing them up the line:
> >
> > eval {
> > eval {
> > eval {
> > bad_system_call() or die &qu
On 3/6/06, Tom Allison <[EMAIL PROTECTED]> wrote:
> Will 'die' by itself propogate the contents of $@ ad infinitum?
Well, not ad infinitum. But it will propagate, according to perldoc's
entry on die(). Cheers!
--Tom Phoenix
Stonehenge Perl Training
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
F
Jay Savage wrote:
die on errors and just keep passing them up the line:
eval {
eval {
eval {
bad_system_call() or die "$!\n";
} or die $@;
} or die $@;
};
print "eval says: [EMAIL PROTECTED]" if $@;
t falls
> into a few steps:
>
> read from network
> read from database
> write to database
> do something else on network
> write to network
>
> Being the cautious code writer I thought it would make sense to use
> something like:
>
> eval{
> alarm(10);
> "
On 3/6/06, Tom Allison <[EMAIL PROTECTED]> wrote:
> The problem I run into is throwing the exceptions up to the top eval{}
> structure when I need to communicate that something didn't work right
> so I can provide feedback to the network client connection.
>
> I suppose I
se
do something else on network
write to network
Being the cautious code writer I thought it would make sense to use
something like:
eval{
alarm(10);
"read from network"
"read from database"
}
But each of these database calls has it's own eval{} around the database
Inpecting $@ and caller() after an eval will yield:
Error message (eval 6750):428
How does one view line 428. Are there formal hooks with which
(immediately following an eval) one can:
my $eval_number = ???;
my $eval_contents = ???( $eval_number );
The debugger seems to do a
hi to all and thanks to all suggested me some solution,
using debug lines (or something similar) I understood how obtaining the
output I want.
Now, I'm writing this e-mail to show a possible way to do a discrete
corrector: I write a regexp to substitute (maybe with another regexp
including bac
text to replace it with.
PATTERN: Te([^ ]+).*support
REPLACEMENT: sticular
Pattern Found!
$_ => Tech Support
$1 => ch
Type "s" to confirm substitution,
or press any other key to cancel: s
COMMAND: s/Te([^ ]+
ne to:
if(/($pattern)/gi)
-Original Message-
From: Adriano Allora [mailto:[EMAIL PROTECTED]
Sent: Mon 1/2/2006 3:48 AM
To: beginners@perl.org
Cc:
Subject: about eval and stdin
hi to all,
a friend of mi
pattern = (dir)ectory and replacement = $1, why the script
> does not eval $1 as "dir"? how I can change the script to make it works
> as I want?
because there is no $1 at the point you test it. You get an $1 by putting '()'
in a match/substitution.
btw: What would be t
hi to all,
a friend of mine ask me for a perl script to change regexp patterns in
some texts (he can learn regexp, but I suppose he won't learn perl). So
I start write this one to him.
I have a problem:
==> with pattern = (dir)ectory and replacement = $1, why the script
does not ev
On 12/26/05, Robin Houston <[EMAIL PROTECTED]> wrote:
> +# Check that constant overloading propagates into evals
As a further confirmation of the fact, the following one-liner (using
bigint and eval with strings) that used to output
$ perl -Mbigint -e "my $x = eval '1+2
Jennifer Garner wrote:
And, I have another syntax question here. I can't know clearly the
difference between eval "" and eval {}. I have run "perldoc -f eval" and
read it,but still can't know clearly.Can you help me on this?
eval {} or eval BLOCK is parsed only on
"
>
> Here's a solution that works for the cases you've provided:
>
>sub try_eval {
> local $@;
> my $warning;
> local $SIG{__WARN__} = sub { $warning = 1 };
> my $expr = shift;
> my $val = eval $expr;
> $val = $expr if $@ or
you've provided:
sub try_eval {
local $@;
my $warning;
local $SIG{__WARN__} = sub { $warning = 1 };
my $expr = shift;
my $val = eval $expr;
$val = $expr if $@ or $warning;
return $val;
}
It catches fatal errors (via $@) and non-fatal warnings (via the __WARN__
> On Tue, 27 Sep 2005, Bryan R Harris wrote:
>
>> I'd like to evaluate user input only where it makes sense, e.g.
>>
>> "2*(3+2)" ==> 10
>> "2*dog" ==> "2*dog"
>> "mysquarefunction(2)" ==> 4
>> "3*mysquarefunction(2)" ==> 12
>> "some guy" ==> "some guy"
>
> What happens when they put somethin
On Tue, 27 Sep 2005, Bryan R Harris wrote:
> I'd like to evaluate user input only where it makes sense, e.g.
>
> "2*(3+2)" ==> 10
> "2*dog" ==> "2*dog"
> "mysquarefunction(2)" ==> 4
> "3*mysquarefunction(2)" ==> 12
> "some guy" ==> "some guy"
What happens when they put something in like
"sys
I'd like to evaluate user input only where it makes sense, e.g.
"2*(3+2)" ==> 10
"2*dog" ==> "2*dog"
"mysquarefunction(2)" ==> 4
"3*mysquarefunction(2)" ==> 12
"some guy" ==> "some guy"
I've tr
Jose Alves de Castro wrote:
On Sun, 2004-08-08 at 04:06, JupiterHost.Net wrote:
I found this code in a script right after the she-bang line:
eval 'exec /usr/bin/perl -T -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
What is it doing?
Hi.
From `perldoc perlrun`, u
On Sun, 2004-08-08 at 04:06, JupiterHost.Net wrote:
> I found this code in a script right after the she-bang line:
>
> eval 'exec /usr/bin/perl -T -w -S $0 ${1+"$@"}'
> if 0; # not running under some shell
>
> What is it doing?
Hi.
From `perldoc p
I found this code in a script right after the she-bang line:
eval 'exec /usr/bin/perl -T -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
What is it doing?
Its like its executing itself again, but why?
What the heck is: ${1+"$@"} ??
Wouldn't the eval
1 - 100 of 252 matches
Mail list logo