I'm seeking a strategy for diagnosing a bug that seems difficult to reduce to a
simple reproducible case.
The bug is that a hash element apparently becomes undef. When used as an
argument to "split" or "index", it generates a "Use of uninitialized value"
error.
The mysterious thing about this
Thanks to all. I have learned a lot tonight. Syntax sugar should be only
used when I know clearly what happened.
On Sat, Dec 4, 2010 at 12:34 AM, Jim Gibson wrote:
> On 12/3/10 Fri Dec 3, 2010 8:26 AM, "Odin Liu"
> scribbled:
>
> > Interesting. So if I need deal with an array of files, and I
On 12/3/10 Fri Dec 3, 2010 8:31 AM, "Odin Liu"
scribbled:
> No, actually I need deal with these files twice. So I need to keep the array
> of these files. But after the first time dealing with these files, the array
> of these files had been changed.
Then you should modify your program so that
On 12/3/10 Fri Dec 3, 2010 8:30 AM, "Roche, Johnny"
scribbled:
> To my understanding, "$_" is the default input of the current running
> script/program, hence, if you overwrite $_ in an inner loop, it will overwrite
> $_ for the whole process. If you do not want to overwrite it, you'll need to
Oh, it works!
Thanks a lot.
On Sat, Dec 4, 2010 at 12:29 AM, Shawn H Corey wrote:
> On 10-12-03 11:26 AM, Odin Liu wrote:
>
>> Interesting. So if I need deal with an array of files, and I have to use
>> the array after reading each file. I have to save another copy of the
>> array?
>>
>
> No, use
> "OL" == Odin Liu writes:
OL> I consider $_ is a value-copy of the loop-element, but as shown in
OL> a while loop inside a for loop, it seems that $_ is a reference of
OL> the loop-element.
it doesn't matter what you consider $_ to be. don't use it for
loops. use a lexical variable wh
> "RJ" == Roche, Johnny writes:
RJ> To my understanding, "$_" is the default input of the current
RJ> running script/program, hence, if you overwrite $_ in an inner
RJ> loop, it will overwrite $_ for the whole process. If you do not
RJ> want to overwrite it, you'll need to assign $_
On 10-12-03 11:40 AM, Odin Liu wrote:
I consider $_ is a value-copy of the loop-element, but as shown in a
while loop inside a for loop, it seems that $_ is a reference of the
loop-element.
The loop variable for a foreach loop is the actual element of the array.
Consider:
#!/usr/bin/perl
u
I consider $_ is a value-copy of the loop-element, but as shown in a while
loop inside a for loop, it seems that $_ is a reference of the loop-element.
On Sat, Dec 4, 2010 at 12:30 AM, Roche, Johnny wrote:
> To my understanding, "$_" is the default input of the current running
> script/program, h
Hi Jim,
Thanks for the tip.
I searched CPAN prior to ask here and also I googled to find tutorials and
everybody pointed me to RTF::Tokenizer.
I use RTF::Writer to generate RTF files, but I need another module to append
text to already generated *.rtf file by other user.
I'll try also the modules
On 10-12-03 11:30 AM, Roche, Johnny wrote:
To my understanding, "$_" is the default input of the current running
script/program, hence, if you overwrite $_ in an inner loop, it will overwrite $_ for the
whole process. If you do not want to overwrite it, you'll need to assign $_ to a scalar
be
Shawn is absolutely right. If you don't care to save the array, then you can
use $_.
Johnny Roche
Associate, Help Desk
Harvard Management Company
Tel: 617-720-6827
Fax: 617-878-6827
Email: roc...@hmc.harvard.edu
-Original Message-
From: Shawn H Corey [mailto:shawnhco...@gmail.com]
Sent:
On 12/3/10 Fri Dec 3, 2010 8:26 AM, "Odin Liu"
scribbled:
> Interesting. So if I need deal with an array of files, and I have to use the
> array after reading each file. I have to save another copy of the array?
No. You need to learn where and when it is appropriate to use the default
variable
On 10-12-03 11:31 AM, Odin Liu wrote:
No, actually I need deal with these files twice. So I need to keep the
array of these files. But after the first time dealing with these files,
the array of these files had been changed.
Only if you try to use $_ twice. Use a lexical variable for all your
No, actually I need deal with these files twice. So I need to keep the array
of these files. But after the first time dealing with these files, the array
of these files had been changed.
On Sat, Dec 4, 2010 at 12:24 AM, Roche, Johnny wrote:
> Would this satisfy your desired output?
>
> my @ins =
To my understanding, "$_" is the default input of the current running
script/program, hence, if you overwrite $_ in an inner loop, it will overwrite
$_ for the whole process. If you do not want to overwrite it, you'll need to
assign $_ to a scalar before entering the loop that will overwrite $_
On 10-12-03 11:26 AM, Odin Liu wrote:
Interesting. So if I need deal with an array of files, and I have to use
the array after reading each file. I have to save another copy of the array?
No, use a lexical variable for each loop:
foreach my $file ( @ins ){
while( defined( my $line = <$in_fh>
Interesting. So if I need deal with an array of files, and I have to use the
array after reading each file. I have to save another copy of the array?
Anyway, thanks for helping.
On Sat, Dec 4, 2010 at 12:16 AM, Shawn H Corey wrote:
> On 10-12-03 11:12 AM, Odin Liu wrote:
>
>> Still confusing. We
On 12/3/10 Fri Dec 3, 2010 5:11 AM, "Cristi Ocolisan"
scribbled:
> Hi all,
>
>
>
> Have anybody used RTF::Tokenizer module?
>
> I'm struggling to find out how to retrieve the content of tokens.
>
>
>
> What I'm trying to do is to open a file (*.rtf) that a user uploaded on
> server add
Would this satisfy your desired output?
my @ins = @ARGV;
foreach(@ins) {
open IN, $_;
my $fn = $_;
while() {
chomp;
print "$fn\n";
}
close IN;
}
Johnny Roche
Associate, Help Desk
Harvard Management Company
Tel: 617-720-6827
Fax: 617
On 10-12-03 11:12 AM, Odin Liu wrote:
Still confusing. We know that inner loop's $_ overwrite the outer loop's
$_ only in the inner loop. When the inner loop was over, the $_ would be
it was in outer loop before the inner loop begin. Outer $_ would be
restored by Perl automatically.
But why this
On 10-12-03 10:36 AM, Odin Liu wrote:
Suppose file test.pl is:
my @ins = @ARGV;
foreach(@ins) {
open IN, $_;
# the three argument open is preferred. See `perlodc -f open`.
open my $in_fh, '<', $_ or die "could not open $_: $!\n";
while() {
while( defined( my $line = <$in_f
Hi, all
Suppose file test.pl is:
my @ins = @ARGV;
foreach(@ins) {
open IN, $_;
while() {
chomp;
print "@ins\n";
}
close IN;
}
and file case is:
a
b
c
When I run it in shell, using:
$ perl test.pl case
I thought it would be print:
case
Hi all,
Have anybody used RTF::Tokenizer module?
I'm struggling to find out how to retrieve the content of tokens.
What I'm trying to do is to open a file (*.rtf) that a user uploaded on
server add a few information and save it.
I'm on Linux so I cannot use modules that work only on Windo
24 matches
Mail list logo