in reply to Re: $1 into an array
in thread $1 into an array
I tried what you had stated above and could not get it to work. The file looks like:Many times it will only be 1 line long of data but it could be up to three. I need to extract the 1 and 5 and put it into a new file. Currently I only need to pull the first line, but in the near future I need unlimited. This code works great for one line. I like the idea of just reading the line and then outputting it directly into the file, however when doing two lines, whether I use the \n or not, I only end up with the very last line (ie: 5). The code that works beautifully for one line is:Label Location Pool Name Protection [NFK100L2] [MSL6000 Trinity: 1] MSL6000 01/19/2004 [NFK101L2] [MSL6000 Trinity: 5] MSL6000 01/19/2004Any comments on how to edit this to write out more than one slot number to the out file is appreciated! Thanks! Ben#!/usr/bin/perl -w use strict; system ("c:\\Perl\\DataPro\\convert.bat"); open(DPSLOTFILE, "< c:\\Perl\\DataPro\\newreport.txt") or die "Can't o +pen file: $!"; open(OUTFILE, "> c:\\Perl\\DataPro\\output.txt") or die "Can't open fi +le: $!"; while ( <DPSLOTFILE> ) { my $dpdrivloc = "MSL6000 Trinity"; if ( /\Q$dpdrivloc\E:\s*(\d+)/ ) { print OUTFILE "$1"; } } close OUTFILE; close DPSLOTFILE; open (OUTFILE, "< c:\\Perl\\DataPro\\output.txt") or die "Can't open f +ile: $!"; my $slotnumber = <OUTFILE>; print "$slotnumber"; system("c:\\Perl\\DataPro\\omnimm -eject \"MSL6000 Trinity\" $slotnumb +er -location \"blahblahblah\""); close OUTFILE;
- Comment on Re: Re: $1 into an array
- Select or Download Code