retty simple script now, it does no
> filtering at all, yet. It just grabs the message stream from STDIN,
> copies it to a file and prints it back to STDOUT.
>
> But, with an extra space prepended to each line after the first one.
> The extra space is in both the saved file and the
, yet. It just grabs the message stream from STDIN,
copies it to a file and prints it back to STDOUT.
But, with an extra space prepended to each line after the first one.
The extra space is in both the saved file and the STDOUT stream.
I know it's got to be something simple, but wh
K Pfeiffer <[EMAIL PROTECTED]> wrote:
> @words = ;
>
> I'm intentionally not chomping the words.
> I expect @words to look like: qw# aaa\n bbb\n ccc\n # but when I
> print the list I get:
>
> aaa
> bbb
> ccc
>
> (With a space at the beginning of the second and each following
> line.) Why??
Elias Assmann writes:
[...]
> Let me guess: you printed them like print "@words"; -- right? When you
> interpolate an array in double quotes, a space is inserted between
> elements. Try it this:
[...]
Ja, das war es! (Thanks!)
--
Kevin Pfeiffer <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail:
Hi Perl Gang,
While doing one of the very basic exercises out of the beginning of Learning
Perl I'm stuck:
#!/usr/bin/perl -w
use strict;
my @words;
print "Enter a list of words, one on each line (CTRL-D when complete): \n";
@words = ;
I'm intentionally not chomping the words.
I expect @words
On Sun, 13 Oct 2002, K Pfeiffer wrote:
> @words = ;
> I expect @words to look like: qw# aaa\n bbb\n ccc\n # but when I print the
> list I get:
I bet they actually do look like that.
> aaa
> bbb
> ccc
Let me guess: you printed them like print "@words"; -- right? When you
interpolate an array
e. See perlreftut for
a good/breif explaination of using references.
> 1. How do I do a reverse sort of column 4?
Change this: $a->[0] <=> $b->[0]
To this: $b->[0] <=> $a->[0]
Rob
-Original Message-
From: Bryan R Harris [mailto:[EMAIL PROTECTED]]
Sent: Wedn
Please forgive my ignorance, but I can't figure out what this is doing.
This routine correctly sorts @lines (array of lines with tab delimited
fields) by column 4.
# Step 3 - assumes columns 3 and 4 contain numeric data
my @sorted = map { $_->[2] }
sort { $a->[0] <=> $b->[0] || $a-
The following sort-code came from an old CPAN page. It seems to work just
fine (it sorts a tab-delimited text file by the 3rd column), but if I have
warnings (-w) turned on the compiler throws a whole bunch of "Use of
uninitialized value" warnings about the line that starts "@newrefs ".
What
Bryan R Harris wrote:
>
> > Bryan R Harris wrote:
> > >
> > > I suppose it does look a little bizarre. Actually, my goal is a little
> > > more complex. We have a simulation that outputs data files, but often up
> > > to 90% of the data is redundant. So I'm trying to write a filter for the
> >
I have to sort before I remove the lines at the top because the lines that
have the zeros in column 5 are not at the top. The whole point of the task
is not to sort the data, but to filter unneeded data. Some zeroes in
column 5 are okay, but the redundant ones are the ones at the top after
sort
Bryan R Harris wrote:
>
> I suppose it does look a little bizarre. Actually, my goal is a little
> more complex. We have a simulation that outputs data files, but often up
> to 90% of the data is redundant. So I'm trying to write a filter for the
> data. I have to:
>
> 1. open and load the
I suppose it does look a little bizarre. Actually, my goal is a little
more complex. We have a simulation that outputs data files, but often up
to 90% of the data is redundant. So I'm trying to write a filter for the
data. I have to:
1. open and load the file
2. strip all comments (marked
On Apr 8, Bryan R Harris said:
>$file = "somefile.dat";
>open (FILE, $file) || die("Couldn't open $file: $!\n");
>@_ = ;
>close(FILE);
>while ($_[1] =~ /^[#\n]/) { push(@comments, shift(@_)); }
>print "@comments";
This is a rather bizarre way to do this task, by the way. It also fails
in some
On Monday, April 8, 2002, at 05:10 PM, Bryan R Harris wrote:
> open (FILE, $file) || die("Couldn't open $file: $!\n");
> @_ = ;
> close(FILE);
> while ($_[1] =~ /^[#\n]/) { push(@comments, shift(@_)); }
> print "@comments";
seems unnecessary to create an array then print each element.
just p
On Apr 8, Bryan R Harris said:
>I read in a file, then strip all lines that start with "#" or "\n". When I
>print them out, though, the first line is left justified correctly but the
>rest have a single space in front of them. Any ideas why?
The reason is because you did:
>print "@comments";
-
From: Bryan R Harris [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 08, 2002 5:10 PM
To: [EMAIL PROTECTED]
Subject: extra space
This list is for beginners, right? =)
I read in a file, then strip all lines that start with "#" or "\n". When I
print them out, though, th
This list is for beginners, right? =)
I read in a file, then strip all lines that start with "#" or "\n". When I
print them out, though, the first line is left justified correctly but the
rest have a single space in front of them. Any ideas why?
$file = "somefile.dat";
open (FILE, $file) ||
18 matches
Mail list logo