Re: Warning: Use of uninitialized value

2010-01-30 Thread 7
On Sat, Jan 30, 2010 at 4:27 PM, Rob Dixon wrote: > Why are you replying to me? My post did use the three-argument form of > open(). Also: > > - It is bad form to use upper case letters for lexical variables > "Perl Best Practices" disagrees with you. > - Passing / / as the first parameter of

Re: Warning: Use of uninitialized value

2010-01-30 Thread Uri Guttman
> "BW" == Bob Williams writes: BW> Hi Rob, Many thanks. That does what I want :) Now I need to study BW> your code to learn why. and you need to learn to bottom post. you wrote one line and quoted 80 lines which have already been seen by others. google for bottom posting and learn why it

Re: Warning: Use of uninitialized value

2010-01-30 Thread Bob Williams
Hi Rob, Many thanks. That does what I want :) Now I need to study your code to learn why. Bob Rob Dixon wrote: > Hi Bob > > I suggest you forget about regular expressions and use the library > function split() instead. Take a look at the code below. > > HTH, > > Rob > > > > use warnings;

Re: Warning: Use of uninitialized value

2010-01-30 Thread John W. Krahn
[ Please do not top post. ] 7 wrote: a) open (BHF_FILE, " The modern way to open a file is to: 1) Use the three argument form of open(). 2) Create a variable for the file handle. open (my $BHF_FILE, '<', '/home/bob/tmp/md4music'); You should *always* verify that the file was opened correct

Re: Warning: Use of uninitialized value

2010-01-30 Thread Rob Dixon
Why are you replying to me? My post did use the three-argument form of open(). Also: - It is bad form to use upper case letters for lexical variables - Passing / / as the first parameter of split() will split on the first single space in the string. It is better to use ' ' instead which dis

Re: Warning: Use of uninitialized value

2010-01-30 Thread 7
a) > open (BHF_FILE, ") { #do something with $line } close $BHF_FILE; b) Take a look at this code: use strict; use warnings; use 5.010; my $line = 'hello world goodbye'; my @pieces = split / /, $line, 2; for (@pieces) { say; } --output:-- hello world goodbye At the command line,

Re: Warning: Use of uninitialized value

2010-01-30 Thread Rob Dixon
Hi Bob I suggest you forget about regular expressions and use the library function split() instead. Take a look at the code below. HTH, Rob use warnings; use strict; my (@ukchecksum, @uktrackname); open my $bhf_file, '<', '/home/bob/tmp/md5music' or die "Could not open md5music: $!";

Re: AW: Warning: Use of uninitialized value

2010-01-30 Thread Jim Gibson
At 7:29 PM + 1/29/10, Bob Williams wrote: Thanks. There's a lot in your version for a newbie to learn, but unfortunately, it still gives the same error :( It helps if you post the actual code generating the error. You should also trim the accumulated text to remove non-relevant portions.

Re: XML and representations

2010-01-30 Thread Rob Dixon
You misunderstand my solution Bruce. If you set the options as I described, you will have a hash element that looks like 'phone2' => undef instead of the awkward 'phone2' => {} This would be my preference instead of suppressing the empty element altogether, which leaves no indication at

Re: XML and representations

2010-01-30 Thread Bruce Ferrell
Thanks Rob, I'm glad you validated the solution I found. I figured out that if the empty tag was suppressed, I could test for the tag being present or not. Bruce On 01/30/2010 04:16 AM, Rob Dixon wrote: > Hello Bruce > > Take a closer look at the docs, and try > > my $xml = XMLin($data, Supp

Re: XML and representations

2010-01-30 Thread Rob Dixon
Hello Bruce Take a closer look at the docs, and try my $xml = XMLin($data, SuppressEmpty => undef); HTH, Rob Bruce Ferrell wrote: I have a wee problem I can seem to solve. I don't want to get into should XML::Simple be used, it's not relevant to my question... I don't think. Below is so

Re: AW: Warning: Use of uninitialized value

2010-01-30 Thread Bob Williams
Steve Bertrand wrote: > Thomas Bätzler wrote: >> Bob Williams asked: >>> I am trying to split the lines in a file into two halves (at the first >>> space) each half going into an array. The code I have written is below. >> >>> ---Code--- >>> #!/usr/bin/perl >>> use warnings; >>> #use strict; >>