in reply to Re^2: parsing metadata
in thread parsing metadata

Hi Both , Thanks !

Yes they are iRods meta data. But they are printed on screen and I don't want to push them to a file and create more overhead. I was trying something along like this:

foreach my $re(@results){ next if $re =~/^AVUs defined/; warn $re; my $attribute= $1 if($re =~ /^attribute:\s+(.*)/); + my $value = $1 if($re =~ /^value: (.*)/); + | warn $attribute,$value;
And I get
attribute: md5 EVAL_ERROR: Use of uninitialized value $value in warn at Access.pl lin +e 125. A problem occurred at /nfs/users/nfs_a/aj6/CGP/Fluidigm/perl/scripts/L +oadGenotypingResults.pl line 61.

Replies are listed 'Best First'.
Re^4: parsing metadata
by AppleFritter (Vicar) on Sep 05, 2014 at 15:51 UTC

    There's no need to push the results to a file; we're only reading from DATA here since it's convenient for self-contained example scripts. Just use backticks or the qx operator - as you already have, in fact.

    As for the error message you're getting, it doesn't seem to be related to the snippet you shared. In fact, the line

    my $value = $1 if($re =~ /^value: (.*)/); + | warn $attribute,$value;

    That said - you're declaring $attribute and $value inside the loop here, meaning that they will go out of scope and be created anew with each iteration, so at any given time, at most one of them is going to have a defined value.

    The solution is to move the declarations (my $attribute; and my $value;) out of the loop. Even then, be careful that in each iteration, they both just represent the last attribute and value seen, meaning that a) they'll be uninitialized until a attribute: and a value: line has been encountered, and b) they'll go out of sync if you have seen a new attribute: line but not its corresponding value: line yet, so be careful what you do with them at which time.

Re^4: parsing metadata
by Anonymous Monk on Sep 05, 2014 at 16:07 UTC
    Sorry ! My mistake didn't declare the attribute outside. Solved. Thanks