--- Lawrence Statton XE2/N1GAK <[EMAIL PROTECTED]>
wrote:
> > --- Lawrence Statton XE2/N1GAK
> <[EMAIL PROTECTED]>
> > I am using Spreadsheet::WriteExcel to populate
> certain
> > columns which is working, but in column A for
> example
> > I am using the method write_col which requires a
> > reference,
>
>
> Not just "a reference" but an ARRAY reference for
> all the values that
> will go into that column (or a reference to an array
> of arrayrefs to
> write a rectangular area in one shot). The example
> about a fifth of
> the way through the Spreadsheet::WriteExcel pod
> shows it pretty clearly.
>
> > I am printing the absolute path
> > /home/dbsmith/passwd.dubhpr01.sun when all I need
> to
> > print is sun and in column B all I will need is
> > dubhpr01 or the hostname.
>
> So stop printing what you don't need, and start
> printing what you do
> need :) :) :) This code is not writing itself --
> you have to take a
> smidgeon of responsibility for its output.
>
>
> > For this reason I am trying
> > to use a regexp to grab $1 and $2 or sun and
> dubhpr01
> > then use write_col method. This is not working
> and in
> > my test code I want to know what data structure to
> > use.
> >
>
> Are you sure that write_col is the method you want
> to use in this
> case?
>
> > use strict;
> > use warnings;
> > use Data::Dumper;
> > my $string =
> qw(/home/dbsmith/passwd.dubhpr01.sun);
> > my ($host,@OS) = $string =~
> m|\.(\w+\d+)\.(\w+)$|i;
> > my $aref = \$host;
> > my $aref2 = [EMAIL PROTECTED];
>
> Slow down a bit -- think about what you are writing.
> I don't want to
> seem bitchy, but you often post code that looks like
> you just keep
> throwing code into the file willy-nilly trying to
> see what sticks.
> This code CLEARLY has that feel.
>
> >
> > #print $1,"\n";
> > #print $2,"\n";
> > if (ref ($aref) eq "SCALAR") {
> > print "yes\n";
> > }
> > print "newline\n";
> >
> > if (ref ($aref2) eq "ARRAY") {
> > print "YES\n";
> > }
> > print ${$aref},"\n";
> > print @{$aref2}[0],"\n";
> >
> > __OUTPUT__
> >
> > yes
> > newline
> > YES
> > dubhpr01
> > sun
> >
> > so my question 1 is what is @{$aref2}[0] and
>
> $aref2 is [ 'sun' ]
> @{$aref2} is ( 'sun' )
> @{$aref2}[0] is 'sun'
>
>
> Perhaps the reason you find yourself getting
> confusing output is your
> confusing variablenames. "aref2" says nothing about
> the data it
> contains, and is dangerously similar to "aref". If
> you are debugging
> something, you are going to see what SHOULD be there
> instead of what
> IS there.
>
> > why isn't write_col writing its data from my code
> > below:
> >
> > ##-- Write data from ref and format cells A2 and
> down
> > --##
> >
> > my $string =
> qw(/home/dbsmith/passwd.dubhpr01.sun);
> > my @host = $string =~ m|\.(\w+\d+)$|i;
> > my $aref = [EMAIL PROTECTED];
> >
> > print @{$aref},"\n";
> > if (ref ($aref) eq "ARRAY") {
> > print "YES\n";
> >
> $worksheet->write_col('A2',$aref,$sheet_format);
> > }
>
> It worked for me. (Outside of the fact I had to
> redact the
> $sheet_format because you didn't post a complete
> runnable program.)
>
> >
> > I then tried
> >
> >
> $worksheet->write_col('A2',@{$aref},$sheet_format);
> >
> > and I get error:
> > [error redacted]
>
> Well, the documentation pretty clearly calls for an
> arrayref in the
> second argument to write_col, so I have no idea why
> you tried passing
> in an array.
>
> >
> >
> > thank you
> > derek
> >
>
I know its an ARRAY reference why u think I wrote eq
"ARRAY".
I am not 100% sure write_col is the method I need,
that is why I post emails to this list, but I need to
write data in each respective column so using
write_col seems logical.
Sorry u think that, but I do think about what I write
and how to get to my end goal and yes you do sound
bitchy and rude! My apoligies I am not a Perl know it
all but this list is for posting questions so why do
people like u have to make things more difficult by
being negative?
yes the code I provided with the OUTPUT was only test
code or as u state it "willy nilly." I did not want to
post all 186 lines so I took out what is not working
which is know as a snippett.
If you seem to have all the Perl knowledge then get
this code working and send me the output BECAUSE IT IS
NOT WORKING FOR ME!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>