hi,
Does anyone know of a module I could use to constantly capture output within a timeframe? Basically, I want to capture everything that a console is spitting out for 60 seconds. Then I'm planning to search through the output to look for a specific phrase. Any tips would be much appriciated...
stevexff,
you're right, i think there's some wierd characters that i'm not seeing. When I open the processed file up in windows notepad, the blanks are gone. But when I open it up in an editor such as textpad or editpad, the blanks show up. I tried your code, but it didn't seem to have any...
yeah, the results appear to be the same with or without an array
open (INFILE, "<tmp1");
open RESULTS, ">results";
while (<INFILE>) {
chomp;
print RESULTS "$_\n" unless /^\s*$/;
}
close INFILE;
close ERASE_BLANK;
to be more accurate, both sets of code remove some blank...
thanks for your responses. with your comments, I melded everything together to create this, and as fas as I can see, it looks fine
open FILENAME, "file1";
while(<FILENAME>)
{
next if /^\s*$/;
chomp;
push @myarray, $_;
}
close FILENAME;
open FILENAME_TWO, ">results"...
#!/usr/bin/perl
@mylist = ( 'one',
'', # ignore
'three',
'', # ignore
'five' );
foreach $value (@mylist) {
print "$value\n" unless $value =~ m/^$/;
}
Its wierd, but I ran this on a file with 1000 lines and it worked...
you guys have all been a big help. I have one more question on regular expressions though. I want to make an if statement that will print out the line if a word is in the first pair of parenthesis. for example, these would print out:
1. (blah blah WORD) blah blah blah blah
2. (WORD) blah blah...
so how would I remove blank lines from a file?
for example,
open FILENAME, "temp";
@mylist = <FILENAME>;
close FILENAME;
where would i put perl -lne 'print unless /^\s*$/' ?
thanks,
gammaman
i tried adding the \], but it's still displaying the ]. for example:
input: [testtest] test test test [testtest]
output: ] test test test [testtest]
for($i=0;$i<@mylist;$i++)
{
@mylist[$i] =~ s/[^\]]*//;
}
did i put it in the right spot?
thanks,
gammaman
using perl, how would i get it to erase everything up to and including the first bracket [ ?
I have this, but it only erases up to the [. I need the bracket removed as well.
for($i=0;$i<@mylist;$i++)
{
@mylist[$i] =~ s/[^]]*//;
}
any ideas?
thanks,
gammaman
hi,
I have a windows version of perl installed, and I realized that I need a sed function that's like the unix version. Does perl have a sed? if so, would you call it the same as you would do in unix? ie. " sed -e '/^ *$/d' input" ?
thanks,
gammaman
thanks for the reply. I tried the code, and it worked if I had the files in the same directory. Is it possible to sort it with different files and different directories? For example, this is the outcome of the above code:
C:\foldera\file1
C:\foldera\file10
C:\foldera\file2
C:\folderbcd\file3...
hi,
i'm having trouble with concatenation in perl. What I need to do is put the input of a file into an array. Then I want to join certain indices in the array. For example:
open FILENAME, "testtest";
@mylist = <FILENAME>;
close FILENAME;
$temp = @mylist[0] . @mylist[1];
print "$temp";
The...
hi,
I have a file that lists files and filepath such as this:
C:\foldera\file1
C:\folderb\file2
...
C:\folderc\file10
C:\folderd\file11
I'm trying to figure out a way to sort these so that they will be sorted in ascending order. I tried using perl's sort:
@sorted_array = sort { $a <=> $b }...
hi,
this is probably really simple, but I haven't figured this out. All I want to do is execute file1.pl which will then execute file2.pl. In unix, I would probably just call "file2.pl" but I'm using perl in windows XP. what command do i need?
thanks,
gammaman1
Hi,
I'm trying to verify this line of code:
select( ( select( STDOUT ), $| = 1 )[ 0 ] );
this line is in a file that takes in 3 arguments.
From what I read from my oreilly book, does this mean that select will return the output filehandle if there is at least 1 arguement?
thanks,
gammaman1
wow, windows has grep? I never heard of findstr before.
Anyways, I tried Mike's solution, and it seems to work fine if I use a program with little output. But when I do it for the program I'm using, cleartool, it outputs this error message:
grep: writing output: Invalid argument
I tried...
Thanks for the replies; They've given me more ideas. The problem is that the PERL program I'm writing has to run on windows XP. I have a windows version of grep installed. So what I'm trying to do is this:
1. run the program
2. pipe the results into a grep
3. then pipe that result into another...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.