Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Searching for two elements in two different lines

by hdb (Prior)
on Aug 30, 2013 at 08:32 UTC ( #1051571=note: print w/replies, xml ) Need Help??


in reply to Searching for two elements in two different lines

Just some humble comments:

foreach (@array_1) { chomp $_; }

can be written as

chomp @array_1;

Generally, there seems to be too much chomping.

Instead of

foreach my $element(@array_1) { if ($element !~ /^\s*$/) { if (($element =~ m/$output/) && ($element =~ m/$input/)) { #print +out all the matching output lines

you could

foreach my $element (grep { /$output/ && /$input/ } @array_1) {

Instead of

$join_1 = join (" ", "$input_1","$V_output","$marc_data","$marc_add"," +$stage_1")); push (@array_2,$join_1);

you could

push @array_2, "$input_1 $V_output $marc_data $marc_add $stage_1";

Instead of joining it into one string and then splitting it later again (hopefully the data does not contain any spaces...), you could store it in an array of arrays like this:

push @array_2, [ $input_1, $V_output, $marc_data, $marc_add, $stage_1 +]; # and later foreach (@array_2) { my ($input_2,$output_2,$data,$address,$stage_output_1) = @$_;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1051571]
help
Chatterbox?
[trahulprajapati]: Hi All
[trahulprajapati]: can anyone please help me to login to a form which uses javascript ?

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2017-06-22 17:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (525 votes). Check out past polls.