[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Problem on multiple splits

Posted on 2003-12-02
4
Medium Priority
?
381 Views
Last Modified: 2008-03-17
this code is for monitoring netbackup jobs. Here is a portion of my code:

$error=`/usr/openv/netbackup/bin/admincmd/bperror -l -t backstat -d $newtime`;

print ALLERROR "$error\n";
close(ALLERROR);

open(ALLERROR,"$all_errors") || die "Can't open infile: $!\n";

while(<ALLERROR>){

 ($junk1, $junk2, $junk3, $junk4, $media, $dt, $junk7, $junk8, $client, $junk10, $junk11, $junk12, $junk13, $policy, $junk15, $schedule, $junk17, $junk18, $nbstatus) =split(" ",$_);

############################ Start: Find Oracle jobs and their owners ########################################################

if  ( $nbstatus==0 | nbstatus==1 && $schedule =~  "ORACLE" )  {
                                                             
next if /^(\s)*$/;  # skip blank lines

@owner=`/usr/openv/netbackup/bin/admincmd/bpdbjobs -report -all_columns | grep $dt | grep -v grep | awk -F',' '{print $20}'`;

 ($jk1, $jk2, $jk3, $jk4, $jk5, $jk6, $jk7, $jk8, $jk9, $jk10, $jk11, $jk12, $jk13, $jk14, $jk15, $jk16, $jk17, $jk18, $jk19, $own) =split(/\,/,$_);


The first split works. The second splitl does not. For the second split I only what the 20th field, $own. However if I do a print $jk1 I get the entire line for the frist split, ie

junk1, $junk2, $junk3, $junk4, $media, $dt, $junk7, $junk8, $client, $junk10, $junk11, $junk12, $junk13, $policy, $junk15, $schedule, $junk17, $junk18, $nbstatus


Thougths?


0
Comment
Question by:MatthewF
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 19

Expert Comment

by:Kim Ryan
ID: 9862372
$_ will still be set to the contents of the curre line in file ALLERROR. What data do you want to use for the second split?
Also, it is quicker to say:
(@values) =split(/\,/,$_);
$last_value = pop(values); # get last value of array


0
 

Author Comment

by:MatthewF
ID: 9862966
The second split:
@owner=`/usr/openv/netbackup/bin/admincmd/bpdbjobs -report -all_columns | grep $dt | grep -v grep | awk -F',' '{print $20}'`;

 ($jk1, $jk2, $jk3, $jk4, $jk5, $jk6, $jk7, $jk8, $jk9, $jk10, $jk11, $jk12, $jk13, $jk14, $jk15, $jk16, $jk17, $jk18, $jk19, $own) =split(/\,/,$_);


I want to return $own. I didnt try to use a pop becuase the array of owener is generally 30+ fields, not all which are always populated. ie
The first 10 fields

1,2,3,4,,6,7,8,9,10,
or
1,2,3,4,,6,,8,,10,

etc, etc

0
 
LVL 19

Accepted Solution

by:
Kim Ryan earned 525 total points
ID: 9863056
The problem is you are not linking @owner to the data to split on, its still using the current line
form the filehandle. I think you may want something like:

$owner=`/usr/openv/netbackup/bin/admincmd/bpdbjobs -report -all_columns | grep $dt | grep -v grep | awk -F',' '{print $20}'`;

 ($jk1, $jk2, $jk3, $jk4, $jk5, $jk6, $jk7, $jk8, $jk9, $jk10, $jk11, $jk12, $jk13, $jk14, $jk15, $jk16, $jk17, $jk18, $jk19, $own) =split(/\,/,$owner);

0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 225 total points
ID: 9863894
#It's also easier to say
$own = (split/\,/,$owner)[19];
 
($media, $dt, $client, $policy, $schedule, $nbstatus)=(split)[5,6,9,14,16,19];
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question