Re: trying to match variable names

2003-03-07 Thread John W. Krahn
Rob Dixon wrote: > > John W. Krahn wrote: > > Greg Carrara wrote: > > > > > > Hello, > > > > Hello, > > > > > I'm trying to write a script that reads a file line by line and if > > > the line contains a space it puts quotation marks around it and > > > writes it to another file. I mostly have thi

RE: trying to match variable names

2003-03-07 Thread Carrara, Greg
You're right! I posted before I realized. But thanks to all who responded. I can do exactly what I need! -Original Message- From: Mark Anderson [mailto:[EMAIL PROTECTED] Sent: Thursday, March 06, 2003 5:47 PM To: Carrara, Greg; [EMAIL PROTECTED] Subject: RE: trying to match var

Re: trying to match variable names

2003-03-07 Thread Rob Dixon
John W. Krahn wrote: > Greg Carrara wrote: > > > > Hello, > > Hello, > > > I'm trying to write a script that reads a file line by line and if > > the line contains a space it puts quotation marks around it and > > writes it to another file. I mostly have this working except that > > in the case of

Re: trying to match variable names

2003-03-06 Thread John W. Krahn
Greg Carrara wrote: > > Hello, Hello, > I'm trying to write a script that reads a file line by line and if the line > contains a space it puts quotation marks around it and writes it to another > file. I mostly have this working except that in the case of the lines that > contain the space it p

RE: trying to match variable names

2003-03-06 Thread david
Greg Carrara wrote: > > unless (open(INFILE, "accounts.txt")) { > > die ("Cannot open input file accounts.txt.\n"); > } > > unless (open(OUTFILE, ">nospace.txt")) { > > die ("Cannot open output file nospace.txt.\n"); > } > > $line = ; > > while ($line ne "") { > > if ($line

RE: trying to match variable names

2003-03-06 Thread Bakken, Luke
> > > line. My guess is that > > > print OUTFILE ($line); > > > also feeds a CR. Is there a way around this? > > > while () { > > chomp; > > if (/ /) { > > print OUTFILE "\"$line\"\n"; > > } > > else { > > print OUTFILE $line, "\n"; > > } > > } > > >

RE: trying to match variable names

2003-03-06 Thread Mark Anderson
> > I'm trying to write a script that reads a file line by line and if the line > > contains a space it puts quotation marks around it and writes it to another > > file. I mostly have this working except that in the case of the lines that > > contain the space it puts the quotation mark at the

RE: trying to match variable names

2003-03-06 Thread Mark Anderson
You probably should have started a new thread for this discussion. > I'm trying to write a script that reads a file line by line and if the line > contains a space it puts quotation marks around it and writes it to another > file. I mostly have this working except that in the case of the lines th

RE: trying to match variable names

2003-03-06 Thread Pete Emerson
The EOLN character is not being stripped out, so you're getting it before your quote. chomp it to remove it. Here's my version: #!/usr/bin/perl -w use strict; open INFILE, "accounts.txt" or die "Can't open INFILE: $!"; open OUTFILE, ">nospace.txt" or die "Can't open OUTFILE: $!"; while () {

RE: trying to match variable names

2003-03-06 Thread Bakken, Luke
> Hello, > I'm trying to write a script that reads a file line by line > and if the line > contains a space it puts quotation marks around it and writes > it to another > file. I mostly have this working except that in the case of > the lines that > contain the space it puts the quotation mark

RE: trying to match variable names

2003-03-06 Thread Carrara, Greg
Hello, I'm trying to write a script that reads a file line by line and if the line contains a space it puts quotation marks around it and writes it to another file. I mostly have this working except that in the case of the lines that contain the space it puts the quotation mark at the beginning of

Re: trying to match variable names

2003-03-06 Thread John W. Krahn
Daniel Mueller wrote: > > hi group! Hello, > i'm currently trying to match all variables in a file, the regex i use looks > like this : > > m/([\$|\@|\%]\w+)/g > > it matches as far as i can see what i want but it also matches stuff like > this : > > |SOMETEXT > > why is this? what am i doin

Re: trying to match variable names

2003-03-06 Thread Stefan Lidman
Daniel Mueller wrote: > > hi group! > > i'm currently trying to match all variables in a file, the regex i use looks > like this : > > m/([\$|\@|\%]\w+)/g You seem to have mixed two ways to do it m/([EMAIL PROTECTED])/g; or m/((?:\$|\@|%)\w+)/g; /Stefan -- To unsubscribe, e-mail: [EMAIL

Re: trying to match variable names

2003-03-06 Thread Pete Emerson
Daniel, Inside [ ] means "any of the following", so you don't use the | as an OR in this situation. Take the | out and you should be fine. Here's my example: #!/usr/bin/perl -w use strict; my $variable1; my @variable2; my %variable3; $variable1=1; @variable2=(1,2,3); %variable3=(1,2,3,4); # |SOME