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
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
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
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
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
> > > 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";
> > }
> > }
> >
>
> > 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
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
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 () {
> 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
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
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
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
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
14 matches
Mail list logo