in reply to using sub routines and solving an issue i have with passing variables

I think we need more information. You already know how to call a subroutine with a parameter, you do so in the second line of your program. What exactly is it you need help with?

1 Peter 4:10
  • Comment on Re: using sub routines and solving an issue i have with passing variables

Replies are listed 'Best First'.
Re^2: using sub routines and solving an issue i have with passing variables
by james28909 (Deacon) on Sep 30, 2014 at 20:17 UTC
    actually if the first sub pulls out a section of a file and names it "$data" how would i pass $data to all three subs?
    sub tear_down{ my ($dataFile) = @_; open my $file, '<', $dataFile || die "$!"; my count = 3; for ( my $i = 1 ; $i <= $count ; $i++ ) { seek to bytes in file; read x bytes into $data ; parse_file_1($data) ###### but how would i loop so first $data goes to parse_file_1, seco +nd $data would go to parse_file_2 ect? ###### would i have to send it to another sub that could count each o +ne? and if count = 1 send to parse_file_1 ###### and if count=2 then send to parse_file_2 ect ect? cz nested lo +ops give me unexpected results alot of times } }
    im just trying to get my head around it is all :)
    EDIT: DERP i think i figured it out. cz the counter in the first sub could delegate which sub it goes to i am pretty sure. and then there still would only be if statements and not nested loops. or i could also add checks in each sub for the specific data coming to it. and just set it up so all data gets passed to all three subs for each loop. but that sounds like it would be a bad thing. i think if $count = x statements would be better