#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0

    Perl file and split questions


    Code:
    my ($bumpFileVolume,$bumpFileDir,$name) = File::Spec->splitpath($bumpFile);
    my @workDirArr = ($bumpFileVolume,$bumpFileDir);
    my $workDir = File::Spec->catdir(@workDirArr);
    chdir $workDir or die "$0 failed to chdir to working dir $workDir";
    
    system ("sort -k 1,1 -k 4n -T $workDir $name >tempLoc_$name")==0 or die "$0 failed to sort $name";
    open (BRK, "tempLoc_$name") or die "$0 failed to open file tempLoc_$name";
    open (OUTTWO, ">loc_analyze_$name") or die "$0 failed to open file loc_analyze_$name";
    I'm a little confused as to whats happening here. What does it mean to create the variable $name attach it to the file I assume is $bumpfile and then use in as the part of loc_analyze_$name or tempLoc_$name? Are they creating a new file or simply opening up an old one?


    Also for


    Code:
    #LINE: while (@bumps){
    LINE:    while (<FIL>) { 
    	my $line2 = $_;
    	chomp $line2;        
    	my @parts = split;
    	my $rom_ref = $parts[0];
    	my $signal = $parts[1];

    I'm assuming the array parts is from FIL being split. Is this correct?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Location
    Paris area, France
    Posts
    843
    Rep Power
    496
    $name is the name of tghe file stripped of its path (directory) information.

    The second code sniopopet is reading the file line by line and splitting each line inti an array (split on the soace character).

IMN logo majestic logo threadwatch logo seochat tools logo