Hello All. I have a question about this procedure. I am trying to extract these 12 values of text from a text file. I am trying to get my first two hash values and this is the procedure that handles that. Thanks Charles for all your help and mentoring. I appreciate your time and consideration. When I comment out the "shift @fields;" in CODE1 and run it, I get the results at RESULT1. When I comment out the "#push @fields; #, ( '' ) x ( 4 - @fields );" in CODE2, I get RESULTS2.
My question is why? What is happening in these lines of code. I dont understand why you need "my $line = shift;" or what this is doing? I understand what is happening up until "shift @fields" to the end of the sub procedure. What I am trying to get is RESULT3 below. Any pointers on where I can find information on shift, and push @fields, ( " ) x ( 4 - @fields ); I would like to learn what this is doing and how to get the result I want. Thanks All. William Martell [CODE1] sub line1fields { my $line = shift; #why do I have to shift here. I don't understand what this is doing. # collapse all spaces $line =~ s/\s//g; my @fields = split /AdNumber:|DatePosted:/, $line; # delete extra first field #shift @fields; #why do you have to delete this extra first field. WHere is it coming from?? # pad missing fields push @fields, ( '' ) x ( 4 - @fields ); return @fields; } [/CODE1] [RESULT1] "ad_number","date_posted","contact","telephone","email","address","mapsco"," financial_terms","sq_ft","income_property","price","description" "","5141","","","","","","","","","","" "","5050","","","","","","","","","","" "","5038","","","","","","","","","","" "","5037","","","","","","","","","","" "","5003","","","","","","","","","","" "","4998","","","","","","","","","","" "","4988","","","","","","","","","","" "","4987","","","","","","","","","","" [/RESULT1] ############################################################################ ############# sub line1fields { my $line = shift; # collapse all spaces $line =~ s/\s//g; my @fields = split /AdNumber:|DatePosted:/, $line; # delete extra first field shift @fields; #why do you have to delete this extra first field. WHere is it coming from?? # pad missing fields #push @fields; #, ( '' ) x ( 4 - @fields ); return @fields; } "ad_number","date_posted","contact","telephone","email","address","mapsco"," financial_terms","sq_ft","income_property","price","description" "","04/19/2004","","","","","","","","","","" "","04/06/2004","","","","","","","","","","" "","04/04/2004","","","","","","","","","","" "","04/04/2004","","","","","","","","","","" "","03/29/2004","","","","","","","","","","" "","03/28/2004","","","","","","","","","","" "","03/27/2004","","","","","","","","","","" "","03/27/2004","","","","","","","","","","" ############################################################################ #################################### [RESULT3] "ad_number","date_posted","contact","telephone","email","address","mapsco"," financial_terms","sq_ft","income_property","price","description" "5141","04/19/2004","","","","","","","","","" "5050","04/06/2004","","","","","","","","","" "5038","04/04/2004","","","","","","","","","" "5037","04/04/2004","","","","","","","","","" "5003","03/29/2004","","","","","","","","","" "4998","03/28/2004","","","","","","","","","" "4988","03/27/2004","","","","","","","","","" "4987","03/27/2004","","","","","","","","","" [/RESULT3] ############################################################################ #################################### I could also really use help understanding why and how you use "%$ad", and "@$ad". Any PERLDOC pointers here would also be appreciated. My understanding of these is the they both refer to the context of the data. But beyond that I am confused. foreach my $value ( values %$ad ) { return join ',', @$ad{ @field_order }; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>