RE: Omitting duplicate IDs in output file

2006-05-10 Thread FlashMX
I need some help. I can't figure out how to omit duplicate IDs in the output file. #!/usr/local/bin/perl require 5.000; my %tags = (); my $input = $ARGV[0]; my $output = $ARGV[1]; open (FILE, "< $input") or die "cannot open $input: $!\n"; open (OUTPUTFILE, "> $output") or die "cannot open

Re: Removing duplicate IDs

2006-05-08 Thread FlashMX
Hi, I have a script that sorts the IDs with numerials first followed by alphas. Everything works ok except that there are some IDs in the input file that are duplicates. How can I "omit" and duplicate IDs from the output file? Below is my script and a sample input and output file generated fr

Re: Setup of ActivePerl Modules HELP!

2005-05-10 Thread FlashMX
Hi, I have a Perl script that requires the following module to be installed. use File::Find; open(IN,$File::Find::name) or ... WHen I ran the PPM and did a search for "Find" I couldn't find the module "File-Find"? Which one do I have to install? This is what gets listed: 26. File-Find-Du

Re: searching and replacing

2005-03-11 Thread FlashMX
Why does this syntax not work? The $1 does not come out. if (/([0-9.]{6}) set/) { s/$1 set/\n-50.2 v \n$1 set/; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: searching and replacing

2005-03-11 Thread FlashMX
On Fri, 11 Mar 2005 10:57:19 -0500, FlashMX wrote: >On Fri, 11 Mar 2005 07:53:30 -0800, John W. Krahn wrote: > >>John W. Krahn wrote: >>> FlashMX wrote: >>> >>>> I need to modify some existing code. The below line checks a file I'm >>>&

Re: searching and replacing

2005-03-11 Thread FlashMX
On Fri, 11 Mar 2005 07:53:30 -0800, John W. Krahn wrote: >John W. Krahn wrote: >> FlashMX wrote: >> >>> I need to modify some existing code. The below line checks a file I'm >>> reading in and does a search/replace based on the match. Currently >>

Re: searching and replacing

2005-03-11 Thread FlashMX
>FlashMX wrote: >> Cool...that worked...thanks >> >> I forgot to mention that one the match is found I do a search and replace >> >>if (/[0-9.]{6} setgray/) { >> s/.9 set/-50.2 v \n.9 set/; >> >> T

Re: searching and replacing

2005-03-11 Thread FlashMX
into the s/ So... if (/[0-9.]{6} setgray/) { s/NUMBER_FROM_ABOVE set/-50.2 v \nNUMBER_FROM_ABOVE set/; >On Fri, 11 Mar 2005 09:44:16 -0500, Wiggins d'Anconia wrote: > >>FlashMX wrote: >>> Hi, >>> >>> I need to modif

re: searching and replacing

2005-03-11 Thread FlashMX
Hi, I need to modify some existing code. The below line checks a file I'm reading in and does a search/replace based on the match. Currently I'm looking for... if (/0 set/) { ...etc. Because the "00" can change to different numbers (but always 6 figures which could include a period) h

Splitting large file into little chunks based on tagging (example & script inc.)

2005-01-24 Thread FlashMX
Hi, I have a large file that I want to split into smaller chunks based on a start and end text (...) My script works only partially. It only saves the first occurence of my match and then closes the script. How can I get it to keep ripping throught the file saving into individual files. My file

re: Splitting large file into little chunks based on tagging (example & script inc.)

2005-01-24 Thread FlashMX
Hi, I have a large file that I want to split into smaller chunks based on a start and end text (...) My script works only partially. It only saves the first occurence of my match and then closes the script. How can I get it to keep ripping throught the file saving into individual files. My file

Re: Reading external file. Open files from listing and do a search and replace then continue...

2004-11-30 Thread FlashMX
On Tue, 30 Nov 2004 14:42:05 -0500 (EST), Chris Devers wrote: >On Tue, 30 Nov 2004, FlashMX wrote: > >> On Tue, 30 Nov 2004 14:35:54 -0500 (EST), Chris Devers wrote: >> >> >"Teach a man to fish..." >> >> Or buy it at the market. > >Oh, so

Re: Reading external file. Open files from listing and do a search and replace then continue...

2004-11-30 Thread FlashMX
On Tue, 30 Nov 2004 20:31:43 +0100, Gunnar Hjalmarsson wrote: >[ Please do not top-post! ] > >FlashMX wrote: >> Gunnar Hjalmarsson wrote: >>> If that's the only code you are able to put together for >>> accomplishing the task you described in another messa

Re: Reading external file. Open files from listing and do a search and replace then continue...

2004-11-30 Thread FlashMX
On Tue, 30 Nov 2004 14:35:54 -0500 (EST), Chris Devers wrote: >On Tue, 30 Nov 2004, FlashMX wrote: > >> Yea...ok fine...Whats the purpose of this "beginners" list anyway. >> >> To put it bluntly Gunnar. Your attitude sucks! > >We're here to help

Re: Reading external file. Open files from listing and do a search and replace then continue...

2004-11-30 Thread FlashMX
Yea...ok fine...Whats the purpose of this "beginners" list anyway. To put it bluntly Gunnar. Your attitude sucks! On Tue, 30 Nov 2004 20:11:03 +0100, Gunnar Hjalmarsson wrote: >FlashMX wrote: >> Got it so far. >> >> open CHECKFILE, "< file.

re: Reading external file. Open files from listing and do a search and replace then continue...

2004-11-30 Thread FlashMX
Got it so far. open CHECKFILE, "< file.in" or die qq(Cannot open file "file.in": $!); @filecontent = ; foreach $line (@filecontent) { print " $line"; } close (INFILE); The input file (list of files) looks something like this: P: 1 N: 11222 P

re: Reading external file. Open files from listing and do a search and replace then continue...

2004-11-30 Thread FlashMX
I've been able to read and output the external file containing the file listing. I've been told to do a "foreach" Would this go after the "while" or in place of? open READFILE, "< file.in" or die qq(Cannot open file "file.in": $!); while ($line = ) { print $line; } } c

re: HELP...what am I doing wrong?

2004-11-30 Thread FlashMX
--Original Message Text--- From: FlashMX Date: Tue, 30 Nov 2004 07:42:55 -0500 Hi Charles, You input has helped greatly...thanks Things have kinda changed in the last few days in the way I need to do my script. Previsouly I was reading in an external file. Checking for a certain match and

re: Using built in Grep

2004-11-25 Thread FlashMX
I need to search for a certain string in a datafile and execute some other code if a match is found. Do I have to read in the file before I can perform a grep? I thought the grep works like it would from a command line? grep "string to search" -- To unsubscribe, e-mail: [EMAIL PROTECTED

Re: Search and substutiing text and adding in a carriage return?

2004-11-25 Thread FlashMX
Nevermind...got it. On Thu, 25 Nov 2004 09:30:39 -0500, FlashMX wrote: >On Thu, 25 Nov 2004 15:16:32 +0100, Gunnar Hjalmarsson wrote: > >>FlashMX wrote: >>> How can I enter in a carriage return when doing a text substitution? >> >>Suppose you mean a newline...

Re: Search and substutiing text and adding in a carriage return?

2004-11-25 Thread FlashMX
On Thu, 25 Nov 2004 15:16:32 +0100, Gunnar Hjalmarsson wrote: >FlashMX wrote: >> How can I enter in a carriage return when doing a text substitution? > >Suppose you mean a newline... Yes. >The right side of the s/// operator works as a double-quoted string. >Accordingl

re: Search and substutiing text and adding in a carriage return?

2004-11-25 Thread FlashMX
Hi, How can I enter in a carriage return when doing a text substitution? while ( ) { if (/FIND_MATCH/) { s/AAA/BBB CCC/; } Input file === 111 222 333 AAA 444 555 666 Output file 111 222 333 BBB CCC 444 555 666 Is it possible to have the output like so (with a carriag

Re: Using grep to check contents of file

2004-11-25 Thread FlashMX
g to find IS in the "input.file" file. I'm missing something... my $file = 'input.file'; if (grep(/FIND MATCH/i, $file)) { Found a match...run code } else { No match found } On Thu, 25 Nov 2004 14:01:46 +0100, Gunnar Hjalmarsson wrote: >FlashMX wrote: >> Is

Re: Using grep to check contents of file

2004-11-25 Thread FlashMX
Is this correct? I need to run GREP to check file(s) for some text and if I find a match then execute my code. my $file = 'input.file'; if (grep(/FIND MATCH/i, $file)) { Found a match...run code } else { No match found } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comman

re: open a file for input

2004-11-24 Thread FlashMX
if (grep(?XXX?, $line)) { $line =~ s/XXX /111 XXX /g; } print OUTFILE $line; } close(OUTFILE); close(INFILE); #rename($ofile, $ifile); On Wed, 24 Nov 2004 12:29:13 -0500 (EST), Chris Dever

re: open a file for input

2004-11-24 Thread FlashMX
Hi, I'm trying to understand the logic. When you open a file each line is read in one at a time. At that point you can do whatever you want to that line. In my case a search and replace. Can I do two search and replaces on the same line or would I have to open the file again for a second pass?

Re: Using regular expressions

2004-11-24 Thread FlashMX
. Is this correct? If this is the case how else could I do a grep to do a search and replace without using all the resources? On Wed, 24 Nov 2004 07:00:24 -0500, FlashMX wrote: > >Could you give an example of using grep on a array to do a replace? > > >On Wed, 24 Nov 2004 10:0

Re: Using regular expressions

2004-11-24 Thread FlashMX
s are in the array >@match_lines, and then after doing a pattern match, you are just >printing the values to the output file. >Your script has not replaced anything. >Use grep function to replace all the contents of an array and write the >array back to the output file. > > >--P

re: Using regular expressions

2004-11-23 Thread FlashMX
Hi, The code below opens a file and writes the contents to a temporary file. I need to do a search and replace of certain matches in the files and I thought I might be able to use regular expressions. Being new to perl and now trying expressions has almost put me over the edge. When I run the

Re: File manipulation

2004-11-23 Thread FlashMX
On Tue, 23 Nov 2004 09:44:00 -0500 (EST), Chris Devers wrote: >On Tue, 23 Nov 2004, FlashMX wrote: > >> I'm trying to do this script on my own as suggested by someone in this >> group. > >Glad to hear it :-) > >> I'm getting confused on the login. >

File manipulation

2004-11-23 Thread FlashMX
I'm trying to do this script on my own as suggested by someone in this group. I have the book "Teach yourself Perl in 21 days" So far I've been able to open the file and execute a grep to search for certain text and then display the hits. I'm getting confused on the login. I need to open the o

Re: Using Perls built in GREP

2004-11-22 Thread FlashMX
A fee? Anyone take an apple? On Mon, 22 Nov 2004 15:02:38 -0500 (EST), Chris Devers wrote: >On Mon, 22 Nov 2004, FlashMX wrote: > >> I need to open an external file, search for a hook like "start here" >> insert a line of code then keep searching until I find anothe

Re: Using Perls built in GREP

2004-11-22 Thread FlashMX
I need to open an external file, search for a hook like "start here" insert a line of code then keep searching until I find another hook called "end" then insert another line of code. Keep ripping the file by searching for "start"..."end" insterting the start code and end code until the end of

Reading external file and writing out individual files

2004-11-09 Thread FlashMX
Hi, How would I go about reading in an external file and then based on the search criteria write out individual files. Basically I want to split one big chunk into smaller chunks. The file gets opened and then I want to search for the first occurence of and pickup up everything until I hit (the