How to use perl %hash in BF step?
I want to execute the following perl script within a BF step, how shall I write it? It seems doesn't accept %hash.
|
2 answers
Hi Jirong,
"map" expects an array and returns an array. See: http://perldoc.perl.org/functions/map.html It is possible to return a hash by using the "=>" syntax. "split" is a way of converting a scalar string value into an array by chopping it up at places that match the regulr expression. So generally you would write: Is "$fh" a file handle? If it is then you need to read from the file handle first: my $line = <$fh>; #Read a line form the file. my @array = split (/=|\s+/, $line); # Split the line on equals or spaces. my %hash = map { get_a_key_for($_) => $_ } @array; # Create a dictionary for each element of the line I hope this helps, Simon |
Thanks for your reply, Simon.
My question was how to properly write perl variables within the BF steps, as described in this technote. $var have to be written as $$var. So how about %hash? do I need to write it as %%hash?
Thanks
Jirong
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.