perl array question from going through hash

suppose my @{$data1{$callid}}; cotains

one two three
three five six
one two three

of random patterns but each item is separated by white space or tab,

Below code extract and get rid of the whitespace perfectly so that it shows now like this

onetwothree
threefivesix
onetwothree

    39  foreach $callid (sort keys %data1) {
    40       my @fields = @{$data1{$callid}};
    41 
    42       for my $element (@fields) {
    43           $element =~ s/\s+//g;
    44           print "$element";
 
    48       }
    50       print "\n";

but I wanted to do it so that certain length of output woudln't show, such as less than 5, so I thought I could do this,

    39  foreach $callid (sort keys %data1) {
    40       my @fields = @{$data1{$callid}};
    41  #     print "$callid\n";
    42       for my $element (@fields) {
    43           $element =~ s/\s+//g;
    44            #print "$element";
    45           # next if (length($element) < 15) ;
    46           # print "length($element)";
    47           my @element = join(//,$element);
    48       }
    49       print "@element";
    50       print "\n";

I first did the 45 and 46 but then I realize that I am doing the length on the field(not for the record), so I just try to gather back all the record in array, but I am not having much luck...

Hi.

I suggest you check at the step where you are about to print it. If the length is less than 5, skip the print, otherwise print the item. As a side note, are you sure you want the results of the join to go into an array rather than a scalar? Perhaps I don't understand what you wanted there. Possibly even better would be to join the elements of the array into a scalar then eliminate the spaces with a single (global) substitute ... cheers, drl

When you ask for help, please, always try to post a complete program, if applicable, while reducing your code to the simplest case possible leaving just enough to illustrate your question. Also, please state what the expected action/output is.

And what did you actually try to say it didn't work?