Re: reg exp continued need pulled from reference

2006-12-13 Thread Derek B. Smith
--- Lawrence Statton XE2/N1GAK <[EMAIL PROTECTED]>
wrote:
> If you're dealing with variable length strings,
> separated by some kind
> of character, then regexp is the tool you want, not
> substr.
> 
> This snippet will work so long as hostname and
> platform name are made
> up of \w ... if not, substitute in an appropriate
> character class.
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> foreach my $filename (qw (
>  /home/dbsmith/passwd.dubhpr01.sun
>  /some/other/path/passwd.fizzbox.hpux
>  /yet/another/path/passwd.gronko.aix
>  /still/more/paths/to/passwd.foohost.linux
>   )
>) {
>   my ($hostname, $platform) = $filename =~
> m|\.(\w+)\.(\w+)$|;
>   print "Hostname: $hostname, Platform:
> $platform\n";
> }


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, 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.  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.


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];

#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
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);
}

I then tried 

$worksheet->write_col('A2',@{$aref},$sheet_format);

and I get error:

Not an array ref in call to write_row()No such file or
directory at uid_check.pl line 121
main::__ANON__('Not an array ref in call to
write_row()No such file or direct...') called at
/opt/perl/lib/5.8.2/Carp.pm line 191
Carp::croak('Not an array ref in call to
write_row()No such file or directory') called at
/opt/perl/lib/site_perl/5.8.2/Spreadsheet/WriteExcel/Worksheet.pm
line 1354
   
Spreadsheet::WriteExcel::Worksheet::write_col(1,0,'Spreadsheet::WriteExcel::Format=HASH(0x40610804)')
called at uid_check.pl line 121


thank you
derek

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: reg exp continued need pulled from reference

2006-12-13 Thread Charles K. Clarkson
Derek B. Smith  wrote:


: I then tried

Try something simpler, not more complex. Test this case.

my @hosts = ( 'sun' );
$worksheet->write_col( 'A2', [EMAIL PROTECTED], $sheet_format );


If it fails testing then there may be a problem with
write_col() or with the setup for the object $worksheet.

If it does test okay then the problem may be in the
data manipulation just before the call to write_col().



HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
Free Market Advocate
Web Programmer

254 968-8328

http://www.clarksonenergyhomes.com/

Don't tread on my bandwidth. Trim your posts.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: reg exp continued need pulled from reference

2006-12-13 Thread Lawrence Statton XE2/N1GAK
> --- 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
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: reg exp continued need pulled from reference

2006-12-13 Thread Derek B. Smith
--- 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]
 




RE: reg exp continued need pulled from reference

2006-12-13 Thread Derek B. Smith
--- "Charles K. Clarkson" <[EMAIL PROTECTED]>
wrote:

> Derek B. Smith 
> wrote:
> 
> 
> : I then tried
> 
> Try something simpler, not more complex. Test
> this case.
> 
> my @hosts = ( 'sun' );
> $worksheet->write_col( 'A2', [EMAIL PROTECTED], $sheet_format
> );
> 
> 
> If it fails testing then there may be a problem
> with
> write_col() or with the setup for the object
> $worksheet.
> 
> If it does test okay then the problem may be in
> the
> data manipulation just before the call to
> write_col().
> 
> 
> 
> HTH,
> 
> Charles K. Clarkson
> -- 

that worked, thank you...will keep trying.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: reg exp continued need pulled from reference

2006-12-13 Thread Dr.Ruud
Lawrence Statton XE2/N1GAK schreef:

> @{$aref2}[0] is  'sun'

ITYM: 

  ${$aref2}[0] is  'sun'

-- 
Affijn, Ruud

"Gewoon is een tijger."

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: reg exp continued need pulled from reference

2006-12-14 Thread Lawrence Statton XE2/N1GAK
Ahh, good catch 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: reg exp continued need pulled from reference

2006-12-15 Thread oryann9
"Dr.Ruud" <[EMAIL PROTECTED]> wrote:Lawrence Statton XE2/N1GAK schreef:

> @{$aref2}[0] is 'sun'

ITYM: 

${$aref2}[0] is 'sun'

-- 
Affijn, Ruud

"Gewoon is een tijger."

-- 

   
  Ok everyone, I have thought about this one and tried various code changes but 
cannot get what I want.
   
  My problem: redundant UIDs in password files.
  My solution: 
   
  #1 store passwd files in a globbed array
  #2 create array reference from globbed array
  #3 open array ref, create hash with more than one value per key. Keys are 
regexps from filenames
  #4 read in every line of passwd files from reference. Values in hash need to 
be passwd entries
  For example: key => servernames.platform (dubhpr01.hpux)
  values => filelds from passwd file (name,uid,gid,comments)
  #5 Once hash is built, traverse through searching for usernames that have 
unlike UIDs from all files, then print these to an xls using 
SpreadSheet::WriteExcel.
   
  In my code I have completed 1,2 and 3. Started 4 but I am printing the array 
reference address as opposed to printing the actual values. What am I doing 
wrong and any tips would be nice?  thank you
   
  _OUTPUT_
   
  KEY dubhst14.hpux
  ELEMENTS/home/dbsmith/passwd.dubhst14.hpux
  DUB VALUES  root
   
  KEY dubhdv05.hpux
  ELEMENTS/home/dbsmith/passwd.dubhdv05.hpux
  DUB VALUES root


  dubhst14.hpux => ARRAY(0x4002b0f8)
dubhdv05.hpux => ARRAY(0x4059c9a4)
dubhadm3.hpux => ARRAY(0x4059c8f0)
dwhetls2.hpux => ARRAY(0x4002c164)
dubhadm1.hpux => ARRAY(0x4059c8a8)
oftappp1.hpux => ARRAY(0x405a2084)
dubhpr28.hpux => ARRAY(0x4002e1bc)
cic2.hpux => ARRAY(0x4059c6f8)

   
  #!/usr/bin/perl
  
##-- Initialize environment --##
  use strict;
use warnings;
use diagnostics;
use Spreadsheet::WriteExcel;
#use Data::Dumper;
   
  $ENV{"PATH"} = qq(/usr/bin:/bin:/home/dbsmith:/home/dbsmith/McGaw);
delete @ENV{qw (IFS CDPATH ENV KSH_ENV BASH_ENV)};
   
  ##-- Central DIE routine --##
  open (LOG, ">>/tmp/uid_ck.log") or warn "uid_ck.log did not open $!";
  my $overide = $SIG{__DIE__};## get error handler currently assigned 2 die
$SIG{__DIE__} = sub {
   my $error = shift;   ## error now holds the mesg passed to die
   $overide->($error) if ( ref $overide );
   print LOG ($error);
};
   
  ##-- BEGIN MAIN --##
   
  my @dublinaray  = glob("/home/dbsmith/passwd.*");
my $dublin_aref = [EMAIL PROTECTED];
my @mcgawaray   = glob("/home/dbsmith/McGaw/passwd.*");
my $mcgaw_aref  = [EMAIL PROTECTED];
my (%dublin_hosts,%mcgaw_hosts) = ();
my ($dub_key,$dub_values,$mcg_key,$mcg_values);
parse_file();
   
  sub parse_file {
  foreach my $element ( @{$dublin_aref} ) {
   { local *FILE;
open (FILE, "+<$element") or die "dublin reference did not open: $!";
local $/  = undef;
($dub_key)= $element =~ m|\.(\w+\.\w+)\z|i;
($dub_values) = split /:/, ;
push ( @{$dublin_hosts{$dub_key}}, $dub_values );
print "KEY\t",$dub_key,"\n\n";
print "ELEMENTS\t",$element,"\n\n";
print "DUB VALUES\t",$dub_values,"\n\n";
   }
}
  
while ( ($dub_key,$dub_values) = each %dublin_hosts ) {
print "$dub_key => $dub_values\n";
}
  
  #foreach my $host (sort keys %dublin_hosts) {
#print "$host: @{$dublin_hosts{$dub_key}}\n";
#}
  
#foreach my $element2 ( @{$mcgaw_aref} ) {
#   { local *FILE2;
# open (FILE2, "+<$element2") or die "mcgaw reference did not open: $!";
# local $/ = undef;
# ($mcg_key) = $element2 =~ m|\.(\w+\.\w+)\z|i;
# push (@{$mcgaw_hosts{$mcg_key}}, $mcg_values );
# print "\n$element2\n\n";
# print ;
#   }
#}

  } ##-- END SUB --##
   
   
  
 

 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: reg exp continued need pulled from reference

2006-12-15 Thread oryann9
oryann9 <[EMAIL PROTECTED]> wrote:
"Dr.Ruud" wrote: Lawrence Statton XE2/N1GAK schreef:

> @{$aref2}[0] is 'sun'

ITYM: 

${$aref2}[0] is 'sun'

-- 
Affijn, Ruud

"Gewoon is een tijger."

-- 


Ok everyone, I have thought about this one and tried various code changes but 
cannot get what I want.

My problem: redundant UIDs in password files.
My solution: 

#1 store passwd files in a globbed array
#2 create array reference from globbed array
#3 open array ref, create hash with more than one value per key. Keys are 
regexps from filenames
#4 read in every line of passwd files from reference. Values in hash need to be 
passwd entries
For example: key => servernames.platform (dubhpr01.hpux)
values => filelds from passwd file (name,uid,gid,comments)
#5 Once hash is built, traverse through searching for usernames that have 
unlike UIDs from all files, then print these to an xls using 
SpreadSheet::WriteExcel.

In my code I have completed 1,2 and 3. Started 4 but I am printing the array 
reference address as opposed to printing the actual values. What am I doing 
wrong and any tips would be nice? thank you

_OUTPUT_

KEY dubhst14.hpux
ELEMENTS /home/dbsmith/passwd.dubhst14.hpux
DUB VALUES root

KEY dubhdv05.hpux
ELEMENTS /home/dbsmith/passwd.dubhdv05.hpux
DUB VALUES root


dubhst14.hpux => ARRAY(0x4002b0f8)
dubhdv05.hpux => ARRAY(0x4059c9a4)
dubhadm3.hpux => ARRAY(0x4059c8f0)
dwhetls2.hpux => ARRAY(0x4002c164)
dubhadm1.hpux => ARRAY(0x4059c8a8)
oftappp1.hpux => ARRAY(0x405a2084)
dubhpr28.hpux => ARRAY(0x4002e1bc)
cic2.hpux => ARRAY(0x4059c6f8)


#!/usr/bin/perl

##-- Initialize environment --##
use strict;
use warnings;
use diagnostics;
use Spreadsheet::WriteExcel;
#use Data::Dumper;

$ENV{"PATH"} = qq(/usr/bin:/bin:/home/dbsmith:/home/dbsmith/McGaw);
delete @ENV{qw (IFS CDPATH ENV KSH_ENV BASH_ENV)};

##-- Central DIE routine --##
open (LOG, ">>/tmp/uid_ck.log") or warn "uid_ck.log did not open $!";
my $overide = $SIG{__DIE__}; ## get error handler currently assigned 2 die
$SIG{__DIE__} = sub {
my $error = shift; ## error now holds the mesg passed to die
$overide->($error) if ( ref $overide );
print LOG ($error);
};

##-- BEGIN MAIN --##

my @dublinaray = glob("/home/dbsmith/passwd.*");
my $dublin_aref = [EMAIL PROTECTED];
my @mcgawaray = glob("/home/dbsmith/McGaw/passwd.*");
my $mcgaw_aref = [EMAIL PROTECTED];
my (%dublin_hosts,%mcgaw_hosts) = ();
my ($dub_key,$dub_values,$mcg_key,$mcg_values);
parse_file();

sub parse_file {
foreach my $element ( @{$dublin_aref} ) {
{ local *FILE;
open (FILE, "+<$element") or die "dublin reference did not open: $!";
local $/ = undef;
($dub_key) = $element =~ m|\.(\w+\.\w+)\z|i;
($dub_values) = split /:/, ;
push ( @{$dublin_hosts{$dub_key}}, $dub_values );
print "KEY\t",$dub_key,"\n\n";
print "ELEMENTS\t",$element,"\n\n";
print "DUB VALUES\t",$dub_values,"\n\n";
}
}

while ( ($dub_key,$dub_values) = each %dublin_hosts ) {
print "$dub_key => $dub_values\n";
}

#foreach my $host (sort keys %dublin_hosts) {
# print "$host: @{$dublin_hosts{$dub_key}}\n";
#}

#foreach my $element2 ( @{$mcgaw_aref} ) {
# { local *FILE2;
# open (FILE2, "+<$element2") or die "mcgaw reference did not open: $!";
# local $/ = undef;
# ($mcg_key) = $element2 =~ m|\.(\w+\.\w+)\z|i;
# push (@{$mcgaw_hosts{$mcg_key}}, $mcg_values );
# print "\n$element2\n\n";
# print ;
# }
#}

} ##-- END SUB --##




  Incorrect problem statement.  Should read 
   
  My Problem: unalike UIDs in password files for users. example joe.brown uid 
on server a is 1222 and uid on server b is 1198.


 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: reg exp continued need pulled from reference

2006-12-15 Thread oryann9
oryann9 <[EMAIL PROTECTED]> wrote:oryann9 <[EMAIL PROTECTED]> wrote:
"Dr.Ruud" wrote: Lawrence Statton XE2/N1GAK schreef:

> @{$aref2}[0] is 'sun'

ITYM: 

${$aref2}[0] is 'sun'

-- 
Affijn, Ruud

"Gewoon is een tijger."

-- 


Ok everyone, I have thought about this one and tried various code changes but 
cannot get what I want.

My problem: redundant UIDs in password files.
My solution: 

#1 store passwd files in a globbed array
#2 create array reference from globbed array
#3 open array ref, create hash with more than one value per key. Keys are 
regexps from filenames
#4 read in every line of passwd files from reference. Values in hash need to be 
passwd entries
For example: key => servernames.platform (dubhpr01.hpux)
values => filelds from passwd file (name,uid,gid,comments)
#5 Once hash is built, traverse through searching for usernames that have 
unlike UIDs from all files, then print these to an xls using 
SpreadSheet::WriteExcel.

In my code I have completed 1,2 and 3. Started 4 but I am printing the array 
reference address as opposed to printing the actual values. What am I doing 
wrong and any tips would be nice? thank you

_OUTPUT_

KEY dubhst14.hpux
ELEMENTS /home/dbsmith/passwd.dubhst14.hpux
DUB VALUES root

KEY dubhdv05.hpux
ELEMENTS /home/dbsmith/passwd.dubhdv05.hpux
DUB VALUES root


dubhst14.hpux => ARRAY(0x4002b0f8)
dubhdv05.hpux => ARRAY(0x4059c9a4)
dubhadm3.hpux => ARRAY(0x4059c8f0)
dwhetls2.hpux => ARRAY(0x4002c164)
dubhadm1.hpux => ARRAY(0x4059c8a8)
oftappp1.hpux => ARRAY(0x405a2084)
dubhpr28.hpux => ARRAY(0x4002e1bc)
cic2.hpux => ARRAY(0x4059c6f8)


#!/usr/bin/perl

##-- Initialize environment --##
use strict;
use warnings;
use diagnostics;
use Spreadsheet::WriteExcel;
#use Data::Dumper;

$ENV{"PATH"} = qq(/usr/bin:/bin:/home/dbsmith:/home/dbsmith/McGaw);
delete @ENV{qw (IFS CDPATH ENV KSH_ENV BASH_ENV)};

##-- Central DIE routine --##
open (LOG, ">>/tmp/uid_ck.log") or warn "uid_ck.log did not open $!";
my $overide = $SIG{__DIE__}; ## get error handler currently assigned 2 die
$SIG{__DIE__} = sub {
my $error = shift; ## error now holds the mesg passed to die
$overide->($error) if ( ref $overide );
print LOG ($error);
};

##-- BEGIN MAIN --##

my @dublinaray = glob("/home/dbsmith/passwd.*");
my $dublin_aref = [EMAIL PROTECTED];
my @mcgawaray = glob("/home/dbsmith/McGaw/passwd.*");
my $mcgaw_aref = [EMAIL PROTECTED];
my (%dublin_hosts,%mcgaw_hosts) = ();
my ($dub_key,$dub_values,$mcg_key,$mcg_values);
parse_file();

sub parse_file {
foreach my $element ( @{$dublin_aref} ) {
{ local *FILE;
open (FILE, "+<$element") or die "dublin reference did not open: $!";
local $/ = undef;
($dub_key) = $element =~ m|\.(\w+\.\w+)\z|i;
($dub_values) = split /:/, ;
push ( @{$dublin_hosts{$dub_key}}, $dub_values );
print "KEY\t",$dub_key,"\n\n";
print "ELEMENTS\t",$element,"\n\n";
print "DUB VALUES\t",$dub_values,"\n\n";
}
}

while ( ($dub_key,$dub_values) = each %dublin_hosts ) {
print "$dub_key => $dub_values\n";
}

#foreach my $host (sort keys %dublin_hosts) {
# print "$host: @{$dublin_hosts{$dub_key}}\n";
#}

#foreach my $element2 ( @{$mcgaw_aref} ) {
# { local *FILE2;
# open (FILE2, "+<$element2") or die "mcgaw reference did not open: $!";
# local $/ = undef;
# ($mcg_key) = $element2 =~ m|\.(\w+\.\w+)\z|i;
# push (@{$mcgaw_hosts{$mcg_key}}, $mcg_values );
# print "\n$element2\n\n";
# print ;
# }
#}

} ##-- END SUB --##




  Incorrect problem statement.  Should read 
   
  My Problem: unalike UIDs in password files for users. example joe.brown uid 
on server a is 1222 and uid on server b is 1198.

  __

   
  I looked in the cookbook and as I tried to implement is below.  Am I on the 
right road?
   
  5.7. Hashes with Multiple Values Per KeyProblem   You want to store more 
than one value for each key.

Solution  Store an array reference in $hash{$key}, and put the values into 
that array.



 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: reg exp continued need pulled from reference

2006-12-18 Thread D. Bolliger
oryann9 am Montag, 18. Dezember 2006 16:55:
> Hello...
>   I have thought about this one and tried various code changes but cannot
> get what I want.
>
> My problem: mismatched UIDs in password files.
> My solution:
>
> #1 store passwd files in a globbed array
> #2 create array reference from globbed array
> #3 open array ref, create hash with more than one value per key. Keys are
> regexps from filenames #4 read in every line of passwd files from
> reference. Values in hash need to be passwd entries For example: key =>
> servernames.platform (dubhpr01.hpux)
> values => filelds from passwd file (name,uid,gid,comments)
> #5 Once hash is built, traverse through searching for usernames that have
> unlike UIDs from all files, then print these to an xls using
> SpreadSheet::WriteExcel.
>
> In my code I have completed 1,2 and 3. Started 4 but I am printing the
> array reference address as opposed to printing the actual values. What am I
> doing wrong and any tips would be nice?
>
> _OUTPUT_
>
> KEY dubhst14.hpux
> ELEMENTS /home/dbsmith/passwd.dubhst14.hpux
> DUB VALUES root
>
> KEY dubhdv05.hpux
> ELEMENTS /home/dbsmith/passwd.dubhdv05.hpux
> DUB VALUES root
>
>
> dubhst14.hpux => ARRAY(0x4002b0f8)
> dubhdv05.hpux => ARRAY(0x4059c9a4)
> dubhadm3.hpux => ARRAY(0x4059c8f0)
[snipped]
> #!/usr/bin/perl
>
> ##-- Initialize environment --##
> use strict;
> use warnings;
> use diagnostics;
> use Spreadsheet::WriteExcel;
[snipped]
>  print "$dub_key => $dub_values\n";
[snipped]

Derek,

I guess the reason why you got no answer when you posted the identical 
question in a recent thread is because, at least

- your question(s) is/are unclear
- your code is not trimmed - even not from comments

Anyway. When you print $dub_values and it shows up as an array ref as 

ARRAY(0x4002c164)

and you want the values of this arrayref, you have to dereference it in some 
way.

Start with printing out @$dub_values.

Or assign it before if you want bigger freedom to format the values:

my @[EMAIL PROTECTED];
# handle @dub_values_arr

Hope this helps

Dani
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: reg exp continued need pulled from reference

2006-12-18 Thread oryann9


"D. Bolliger" <[EMAIL PROTECTED]> wrote:  
I guess the reason why you got no answer when you posted the identical 
question in a recent thread is because, at least

- your question(s) is/are unclear
- your code is not trimmed - even not from comments

Anyway. When you print $dub_values and it shows up as an array ref as 

ARRAY(0x4002c164)

and you want the values of this arrayref, you have to dereference it in some 
way.

Start with printing out @$dub_values.

Or assign it before if you want bigger freedom to format the values:

my @[EMAIL PROTECTED];
# handle @dub_values_arr

Hope this helps

Dani

  
How are my quesitons unclear???  Man I take a beating from this help list.  I 
have seen many questions asked that are just "bone-headed" questions or people 
are too lazy to research and I do not feel my questions fall in these 
categories.
   
  I stated " I am printing the array reference address as opposed to printing 
the actual values. 
What am I doing wrong and any tips would be nice?"
   
  How is that unclear?  


 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: reg exp continued need pulled from reference

2006-12-18 Thread D. Bolliger
oryann9 am Montag, 18. Dezember 2006 19:52:
> "D. Bolliger" <[EMAIL PROTECTED]> wrote:
[snipped]
> How are my quesitons unclear???
[snipped]

I answered offlist. Sorry to all for the noise of this notice.

Dani

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: reg exp continued need pulled from reference

2006-12-19 Thread oryann9
"D. Bolliger" <[EMAIL PROTECTED]> wrote:oryann9 am Montag, 18. Dezember 
2006 19:52:
> "D. Bolliger" wrote:
[snipped]
> How are my quesitons unclear???
[snipped]

I answered offlist. Sorry to all for the noise of this notice.

Dani
  
  thank god!
  

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: reg exp continued need pulled from reference

2006-12-19 Thread oryann9

Anyway. When you print $dub_values and it shows up as an array ref as 

ARRAY(0x4002c164)

and you want the values of this arrayref, you have to dereference it in some 
way.

Start with printing out @$dub_values.

Or assign it before if you want bigger freedom to format the values:

my @[EMAIL PROTECTED];
# handle @dub_values_arr

Hope this helps

Dani
 
   
  I don't mean to sound negative, but did you even look at my code?  I know how 
to dereference and I was just printing this in my debugging efforts.
  dublin_aref = [EMAIL PROTECTED]
  Again, @dublin_arry contains a glob like so: glob("/home/oryann9/passwd.*)
  dub_values are the values within the hash %dublin_hosts while dub_key is the 
regexp from the filenames that is the key within the hash %dublin_hosts.
   
  As an example, each key is the regexp of each file name from the array 
reference: passwd.dubhpr01.hpux after being parsed by my regexp I get 
dubhpr01.hpux
   
  Each values are the various fields in the passwd files.
   
  My Goal is below
   
  key=>dubhpr01.hpux
  values=>name,uid,gid,comments
   
   
  Here is the snippet of code I am working on now:
   
  1 use strict;
  2 use warning;
  3 use diagnostics;
  4
  5 my @dublinaray  = glob("/home/oryann9/passwd.*");
6 my $dublin_aref = [EMAIL PROTECTED];
7 my (%dublin_hosts) = ();
8 my ($dub_key,$dub_values,);
  9
10 parse_file();
  11
  12
  13 sub parse_file {
  14   foreach my $element ( @{$dublin_aref} ) {
15   { local *FILE;
16   open (FILE, "+<$element") or die "dublin reference did not open: $!";
17   local $/  = undef;
18($dub_key)= $element =~ m|\.(\w+\.\w+)\z|i;
19   ($dub_values) = split /:/, ;
20push ( @{$dublin_hosts{$dub_key}}, $dub_values );
21print Dumper("KEY\t",$dub_key,"\n\n");
22print Dumper("ELEMENTS\t",$element,"\n\n");
23print Dumper("DUB VALUES\t",$dub_values,"\n\n");
24   }
25}
  26while ( ($dub_key,$dub_values) =  each %dublin_hosts ) {
27print Dumper("$dub_key => $dub_values\n");
28}
29
30 } ##-- END SUB --##
   
  Here is my question
   
  I have a line of code like so: "$dub_key => $dub_values\n";

that prints 
   
  dubhpr28.hpux => ARRAY(0x4002e1bc)

but I want to have printed out the values contained in the $dub_values 
arrayref instead of its address.

What do I have to change to achieve this?
  
 
  thank you
   

 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: reg exp continued need pulled from reference

2006-12-19 Thread oryann9


oryann9 <[EMAIL PROTECTED]> wrote:

Here is my question

I have a line of code like so: "$dub_key => $dub_values\n";

that prints 

dubhpr28.hpux => ARRAY(0x4002e1bc)

but I want to have printed out the values contained in the $dub_values 
arrayref instead of its address.

What do I have to change to achieve this?


thank you



   
  I got it working...never mind.
  I shall be back... : )
   
  thank you


 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com