[9190] in Perl-Users-Digest
Perl-Users Digest, Issue: 2807 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 4 14:07:15 1998
Date: Thu, 4 Jun 98 11:00:40 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 4 Jun 1998 Volume: 8 Number: 2807
Today's topics:
Re: Best tool? (Charlie Stross)
Help! 5.004 sol bin <rieck@motion.sv.sc.philips.com>
Re: HELP! Parsing text files for tables <jdporter@min.net>
Re: map in void context regarded as evil - suggestion <danboo@negia.net>
Re: pattern match ptimmins@netserv.unmc.edu
Re: pattern match (Tad McClellan)
Perl and Javascript conflicts <khan@nes.nlm.nih.gov>
Re: Perl on Windows32 <andy@onyx.interactive.net>
Perl Script for DNS Admin from web <robert.setterlund@a1smtp.frb.org>
Re: question re: sytanx for interpolation of obj->metho <jdporter@min.net>
Reg. Expressions - Allowing Punctuation <maggie@appliedic.com>
Re: Reg. Expressions - Allowing Punctuation <rootbeer@teleport.com>
Regular Expressions (David Siebert)
Re: searching (Charlie Stross)
Re: seek advice on simple first program <dappelzo@NMSU.Edu>
Re: Specialized Split <jdporter@min.net>
Re: splitting via LEADING whitespace <Dave.Cross@gb.swissbank.com>
Re: splitting via LEADING whitespace <jdporter@min.net>
Re: Taking data out of strings <jdporter@min.net>
Re: Use of HTML, POD, etc in Usenet (was: Re: map in vo (Abigail)
Re: Use of HTML, POD, etc in Usenet (was: Re: map in vo <cmcurtin@interhack.net>
Re: Use of HTML, POD, etc in Usenet (was: Re: map in vo <rsi@lucent.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 04 Jun 1998 15:59:37 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: Re: Best tool?
Message-Id: <slrn6ndh42.jjv.charlie@cs.ed.datacash.com>
In the name of Kibo the Compassionate, the Merciful,
on 03 Jun 1998 11:02:48 +1000,Stuart Cooper
the supplicant <stuartc@ind.tansu.com.au> implored:
>Perhaps some readers have amusing stories of the knowledge of Perl in the
>recruitment world they can share with us.
Persistently asking for people who can program in "pearl" (and the
concomittant sin of assuming Perl programmers are dyslexic :) springs
to mind.
But the best I can think of is the recruitment person who tried to
see if I was interested in a job. My CV said: "Perl/UNIX/web/database,
based in Edinburgh, short/medium term contracts only, not willing to
move, not willing to touch Windows". The vacancy they were trying to
fill was for a Visual Basic programmer to work in Ipswitch for a year.
(Clue: Ipswitch is about as close to Edinburgh as Visual Basic is to
Perl.)
-- Charlie
"Computers depreciate faster than you expect, even when you take
Charlie's Depreciation Hypothesis into account"
-- Charlie's Depreciation Hypothesis
------------------------------
Date: Thu, 04 Jun 1998 08:59:04 -0700
From: Alf Rieckmann <rieck@motion.sv.sc.philips.com>
Subject: Help! 5.004 sol bin
Message-Id: <3576C448.6384527C@motion.sv.sc.philips.com>
Hi,
does anybody know where I can find a perl5.004xx binary for solaris.
Thanks for Help
--
Alf
mailto:Alf.Rieckmann@sv.sc.philips.com
------------------------------
Date: Thu, 04 Jun 1998 16:18:57 GMT
From: John Porter <jdporter@min.net>
Subject: Re: HELP! Parsing text files for tables
Message-Id: <3576C974.36AE@min.net>
sfynn@my-dejanews.com wrote:
>
> I need to parse news releases (formatted text files) which sometimes have
> tabular data in them. I need to place this data into a Foxpro database, which
> is no problem, except that there is no normal format for these tables. Some
> are delineated by spaces, some tabs, some made pretty with ASCII.. So my
> problem is that I can't detect when data is actually a table or not.
I don't know about Foxpro, but MicroS**t Excel has some pretty good
ability to parse arbitrarily formatted text. Of course, it would
be a manual job, not automated; but if you've got a cheap data entry
person who knows Excel, that might be a good solution. Then they
could export the table as something like CSV, which both Foxpro and Perl
have no problem dealing with.
hth,
John Porter
------------------------------
Date: Thu, 04 Jun 1998 11:35:09 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: map in void context regarded as evil - suggestion
Message-Id: <3576BEAD.71306277@negia.net>
Earl Hood wrote:
>
> In article <357434CC.7FCF9C89@negia.net>,
> Dan Boorstein <danboo@negia.net> wrote:
>
> >POD is great.
> >POD is good.
> >Let us thank it C<for> our effective C<and>
> >relevant documentation C<format>.
>
> Then label your post as text/x-pod, or equivalent media-type.
why? my desired effect was for people to see the ASCII representation
of the POD. leaving out the label gets me this with minimal effort.
--
Dan Boorstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: Thu, 04 Jun 1998 16:39:49 GMT
From: ptimmins@netserv.unmc.edu
Subject: Re: pattern match
Message-Id: <6l6ikl$j6v$1@nnrp1.dejanews.com>
In article <35766717.82A66AA3@something.com>,
Iqbal gandham <iqbal@etc.prestel.co.uk> wrote:
>
> Hi
>
> I have a text file full of lines like below
>
> NW1*, NW8*, SE1, SE11, SE17, SE5, SW1, SW10, SW11, SW1A,
> SW1E, SW1H, SW1P, SW1V, SW1W, SW1X, SW1Y, SW3, SW4, SW5, SW6,
> SW7, SW8, W1*, W1A*, W1E*, W1H*, W1M*, W1N*, W1P*, W1R*,
> W1V*, W1X*, W1Y*, W2*, W8*, W9*;D5482.htm
>
> What I have is a web page where users enter in a string. I want to see
> which line contains a match, and then goto that file listed at the end.
>
> Firstly how do I either match on teh first three or four chracters,
> cause as you can see some like SW8 only have 3 charcaters in it, so if
> someone enters SW83 2ER, I need that to match just as if someone entered
> SW1V 2ER. I cant match on just the first two chracters because some SW*
> point to other files.
>
> Also whats the quickest way od doing such a match, I presume its not to
> grep, and tyen split on the semi colon, it is quicker to read the file
> into a array or something.
>
> I think what I need to do is to first match the first 3 characters, and
> then match the fourth.
>
> One last thing, if I have a wildcard in the file eg NW8*, how do I get
> it to match if someone enters in NW81 3WE, because it will see NW8* in
> the file, and not match.
... snip ...
So really, you have three main things to do:
1. find a line that matches (I would use a regex to do this)
2. pull out the file listed at the end (I would use a regex to do this too)
3. send your user the file (I would use
print "Location:http://your.path.com/$send_file\n";
to do this; the $send_file is in reference to the match made in part 2)
Potential problems:
what if you have more than one line in your text file that contains a match?
Do you send your user the file at the end of the first line that matches? the
last line that matches? eg, what if one line of your file contains NW1* and
another line of your file contains NW10? well anything that will match NW10
will match NW1*, by definition, so you're stuck with trying to figure out
which line to use to determine which file to send.
I would try to hard-code something into your web form where you are
controlling the item being searched for (eg, using dropdown menus or
checkboxes, etc) and reading it into a variable called $find_this in your cgi
handler. This will make designing the regex to match the line much easier,
something like:
while (<YOUR_DATA_FILE_HANDLE>) {
if (/$find_this.*\;(.*\.htm)/) {
$send_file = $1;
}
}
print "Location:http://your.path.com/$send_file\n";
Hope this helps.
Patrick Timmins
U. Nebraska Medical Center
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Thu, 4 Jun 1998 08:36:30 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: pattern match
Message-Id: <us76l6.15a.ln@localhost>
Iqbal gandham (iqbal@etc.prestel.co.uk) wrote:
: I have a text file full of lines like below
: NW1*, NW8*, SE1, SE11, SE17, SE5, SW1, SW10, SW11, SW1A,
: SW1E, SW1H, SW1P, SW1V, SW1W, SW1X, SW1Y, SW3, SW4, SW5, SW6,
: SW7, SW8, W1*, W1A*, W1E*, W1H*, W1M*, W1N*, W1P*, W1R*,
: W1V*, W1X*, W1Y*, W2*, W8*, W9*;D5482.htm
I assume that this is one "real" line that just got word-wrapped
for email.
[
I wonder why
W1A*, W1E*, W1H*, W1M*, W1N*, W1P*, W1R*, W1V*, W1X*, W1Y*
are even put in the list, since anything that would match them
would also be matched by the 'W1*' pattern...
]
: What I have is a web page where users enter in a string. I want to see
: which line contains a match, and then goto that file listed at the end.
^^^^^^^^^^^^^^^^
I think there might be some confusion here about what is the
*string* to be searched and what is the *pattern* that should
be searched for in that *string*.
Since the comma separated things above contain 'wildcards', then
they must be some form of *pattern*, leaving the user entered value
as the *string* to try and match against that pattern.
Can your statement above be rephrased as:
I want to see which line contains a *pattern* that matches the
*string* that the user entered.
??
If so, then you might want to check out 'perlfaq6':
"How do I efficiently match many regular expressions at once?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 4 Jun 1998 12:52:49 -0400
From: Kushal Khan <khan@nes.nlm.nih.gov>
Subject: Perl and Javascript conflicts
Message-Id: <Pine.GSO.3.95.980604125053.19011B-100000@nes>
I'm editing a previously created Perl script by adding some Javascript
into it and they do not seem to be communicating well. At the end of my
calendar.cgi Perl script, when my form is being submitted, it calls itself
again and sends whatever necessary variables it needs passed. But in my
Javascript, I have certain situations where I use the
window.location.pathname to call the calendar.cgi script with whatever
necessary variables it needs passed. It seems, however, in these
situations that the JavaScript should call the script that the Perl script
"overrides" it and ignores the JavaScript's window.location.pathname
reassignment. So I then put an alert after the window.location.pathname
line to see if Javascript needs more "time".. Apparently, that worked, and
now its not being ignored.. Of course, this is not what I want in my
actual script. Is there someway I can prevent the Perl script from
calling itself and make it rely of the JavaScript code exclusively? Any
help would be greatly appreciated.
-Kushal Khan.
------------------------------
Date: 04 Jun 1998 13:42:37 -0400
From: Andy Murren <andy@onyx.interactive.net>
Subject: Re: Perl on Windows32
Message-Id: <i567iht65u.fsf@onyx.interactive.net>
|As an individual who has ported *many* scripts from various Unix environments
|to Windows NT IIS servers, I can say from experience that the above line is
|literally typical Unix vs. Windows BS.
You are correct about the @INC; however, I was refering to differences
between Unix and NT such as the lack of support for pipes on NT. If
you have a form that emails the form data, you cannot just open a pipe
to the mail program, you have to do all of the work yourself. There
are other differences also, IIS need to be bypassed using nonparse
headers if you want to use a Location: header, etc. etc. etc.
--
Andy Murren IBS Interactive
http://www.interactive.net amurren@interactive.net
------------------------------
Date: Thu, 04 Jun 1998 12:59:57 -0400
From: Robert Setterlund <robert.setterlund@a1smtp.frb.org>
Subject: Perl Script for DNS Admin from web
Message-Id: <3576D28D.35C15C84@a1smtp.frb.org>
I recently obtained a script (webdns) that enables DNS administration
via a web browser. I have tried to run this on a system that is running
Solaris for x86 v2.6 and Perl 5.0. I am having a number of problems
with Perl syntex. Is any one familiar with this script? It was written
in 1994 at MIT. Or, does someone know of another script that will admin
a DNS and actually run on my system.
------------------------------
Date: Thu, 04 Jun 1998 16:10:07 GMT
From: John Porter <jdporter@min.net>
To: Matthew.Wickline@usa.net
Subject: Re: question re: sytanx for interpolation of obj->method in qq context
Message-Id: <3576C885.3989@min.net>
[posted and emailed]
Matthew.Wickline@usa.net wrote:
>
> please cc via email. thx :)
If you post to usenet asking for help, you should be willing to get your
resposes there too.
> In the past, the following two types of print commands have given me identical
> results. Is this a freakish coincidence of the particular circumnstance, or
> *should* they return identical results?
>
> $obj->data("this is data!\n");
> print "${\$obj->data}";
> my $foo = $obj->data; print $foo;
>
> I ask because I now find myself in a situation where the first sort of syntax
> no longer seems to work: it prints "2" w/o a \n. I can get the longer-winded
> way (with the temp variable) to work, but I always thought the first way
> should work.
Keep in mind that these two things do not have identical semantics.
In particular, the first way, i.e.
${ \ $obj->data }
calls data() with a list context, whereas the second way obviously
supplies a scalar context. Perhaps the definition of the data()
method has changed, so that it does something else in list context.
I was unable to duplicate your error. My test code was this:
package Obj;
sub data {
my $self = shift;
print( wantarray ? "list context\n" : "scalar context\n" );
defined $_[0] and $self->{d} = $_[0];
$self->{d};
}
package main;
my $obj = bless {}, 'Obj';
$obj->data(" (data)\n");
print "${\$obj->data}";
my $foo = $obj->data; print $foo;
prints:
scalar context # the assignment
list context
(data)
scalar context
(data)
What version of perl are you using?
Did you write the data() method?
John Porter
------------------------------
Date: Thu, 04 Jun 1998 11:02:44 -0500
From: Maggie Strevell <maggie@appliedic.com>
Subject: Reg. Expressions - Allowing Punctuation
Message-Id: <3576C523.3A4A06E9@appliedic.com>
I am using the following line of code to escape metacharacters
from being passed into the script by a form. Some of the
input includes punctuation like , and '. How can I modify
the existing string to allow , and '. Is there any security
issue that I should know that would cause me to not allow
a , and a ' to be passed to the script?
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C",hex ($1))/eg;
Maggie Strevell
maggie@appliedic.com
------------------------------
Date: Thu, 04 Jun 1998 16:21:28 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Reg. Expressions - Allowing Punctuation
Message-Id: <Pine.GSO.3.96.980604090933.13600i-100000@user2.teleport.com>
On Thu, 4 Jun 1998, Maggie Strevell wrote:
> I am using the following line of code to escape metacharacters
> from being passed into the script by a form.
> $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C",hex ($1))/eg;
Why are you using hand-me-down code like that rather than a well-tested
and well-documented module?
> Some of the input includes punctuation like , and '. How can I modify
> the existing string to allow , and '.
In what way does that code not allow those punctuation marks? Maybe I'm
misunderstanding the question.
> Is there any security issue that I should know that would cause me to
> not allow a , and a ' to be passed to the script?
Yes there is. If you don't know whether there's a security issue or not,
_that_ is a security issue. :-)
Seriously, it depends entirely upon what you're doing with that data. If
you're writing it to /dev/null, there's no problem. If you're sending it
to the shell, there might be a problem. If you're putting it into a file
which shouldn't contain commas and single quotes, then there's certainly a
problem.
Check out the perlsec manpage and the WWW Security FAQ. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 4 Jun 1998 17:47:55 GMT
From: dsiebert@gate.net (David Siebert)
Subject: Regular Expressions
Message-Id: <6l6mkb$1q48$1@news.gate.net>
I have the hardest time with these.
I need to extract the text form between two tags
<hw> and </hw>
help please.
------------------------------
Date: Thu, 04 Jun 1998 16:11:50 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: Re: searching
Message-Id: <slrn6ndhr0.jjv.charlie@cs.ed.datacash.com>
In the name of Kibo the Compassionate, the Merciful,
on Thu, 04 Jun 1998 15:09:16 -0700,Dean Jenkins
the supplicant <jenkinsrd@cf.ac.uk> implored:
>Justin Archie wrote:
>
>> Another thing i want to do is if the script detects a URL or
>> email address that it automatically sets up a link with that http://,
>> gopher://, plus the url in it.
>
> #find and encode URLs
> $line =~ s/(http:\/\/[^ \t\n]*)/<a href=\"$1\">$1<\/a>/ig;
> $line =~ s/mailto:([^ \t\n]*)/<a href=\"mailto:$1\">$1<\/a>/ig;
> $line =~ s/(ftp:\/\/[^ \t\n]*)/<a href=\"$1\">$1<\/a>/ig;
> $line =~ s/(news:[^ \t\n]*)/<a href=\"$1\">$1<\/a>/ig;
This won't work for all cases. F'r'xample, unless I'm misremembering
the RFCs, it's legal to have a newline in the tagged text of a URL.
To do this properly, you probably want to make friends with the
LWP module -- specifically HTML::Parser -- and learn how to walk
the tree it creates from an HTML document. (There's some example
code showing how to do this in the LWP pod documentation, and some
more code at http://www.antipope.org/charlie/webbook/robot/,
although the latter is fairly ancient stuff; LWP has changed a
bit since then.)
-- Charlie
"Computers depreciate faster than you expect, even when you take
Charlie's Depreciation Hypothesis into account"
-- Charlie's Depreciation Hypothesis
------------------------------
Date: Thu, 4 Jun 1998 11:28:57 -0600
From: "Darrell A." <dappelzo@NMSU.Edu>
To: John Porter <jdporter@min.net>
Subject: Re: seek advice on simple first program
Message-Id: <Pine.GSO.3.96.980604112559.27304C-100000@dante>
i too had a question for my first perl program. i am using a SUN Unix
machine here at work and i have attempted to initiate my program by using
this command that i got from a website....chmod +x filename? this isn't
working?!!i understand how to write a program..kindof, but i need to
knowhow to save it as a program file on UNIX to be able to recall it later
for testing. any suggestions for this UNIX/SUN user? i would much
appreciate it.
darrell a.
------------------------------
Date: Thu, 04 Jun 1998 15:55:49 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Specialized Split
Message-Id: <3576C52A.7E0F@min.net>
Jeffrey Horn wrote:
>
> I am looking for a slick way to split on a given character/pattern
> only if that character/pattern does not fall between opening and closing
> parens.
>
> Thus if I were to split on /\+\-/
>
> (1-3)+(2+5)
>....
Any regex solution is necessarily going to be limited to simple
situations such as the example above. Typically, when someone
wants to do something like this, what they really want is a
parser for nestable expressions. The result of such a parse is
a tree.
Below is a simple routine which parses parenthesized expressions.
It parses from the inside out. Each expr found is replaced by
a single-char token (in the range 128-255); a hash stores the
association of tokens to expressions; this hash is later used to
reverse the substitution.
Altough this subroutine performs the task described by Jeffrey Horn,
it could be generalized to allow other operations on the parse tree.
However, it is probably not suitable for more complex tasks.
One limitation is that expressions can only nest to a depth of
127; and if any characters in the range 128-255 appear in the input,
it totally hoses the routine. Note also that it splits the
input expression on the character class [-+*/], not just [+].
sub top_level_parts {
local $_ = shift;
my %t;
my $n = 128;
while ( /\([^()]+\)/gs ) {
my $c = chr($n++);
s/\([^()]+\)/$c/s;
$t{$c} = $&;
}
map {
1 while s/[\200-\277]/$t{$&}/eg;
$_
} split m{[=/+*]};
}
# simple usage example:
print join("\n",top_level_parts(<>)),"\n";
Hope this helps,
John Porter
(my email is temporarily down)
------------------------------
Date: Thu, 4 Jun 1998 15:25:45 GMT
From: David Cross-cmt <Dave.Cross@gb.swissbank.com>
Subject: Re: splitting via LEADING whitespace
Message-Id: <eq0bts99ojq.fsf@gb.swissbank.com>
Scott,
Not sure what you mean by 'splitting via leading white space'. Leading
white space is white space before your data starts, and in your sample
data you don't have any.
What you seem to be doing is splitting on one or more spaces which
obviously splits in the way that you're seeing. With your sample data
you'll get the effect that you want by splitting on two spaces
(assuming, as you say, that there aren't any tabs).
Try:
@tableArray = split(/ +/, %tableScalar);
Yuor data looks like it might have fixed width fields. In that
case you might be better looking at field sizes rather than their
separators.
hth,
Dave...
sdinitto@kronos.com (Scott DiNitto) writes:
[Given this data]
> NAME DATE TIME MESSAGE LEFT
>
> John Doe 6-3-98 10:11 This is a message
> Ronald Regan 6-3-98 12:03 My diaper's leaking again
> Eric Cartman 6-4-98 06:09 YOU WILL RESPECT MY
> AUTHORIT-AY!
[and doing this]
> @tableArray = split (/ +/, $tableScalar);
[I get this]
> @tableArray[0] "John"
> @tableArray[1] "Doe"
> @tableArray[2] "6-3-98"
> @tablearray[3] "10:11"
> @tableArray[4] "This"
> @tableArray[5] "is"
> @tableArray[6] "a"
> @tableArray[7] "message"
[When I really want this]
> @tableArray[0] "John Doe"
> @tableArray[1] "6-3-98"
> @tableArray[2] "10:11"
> @tableArray[3] "This is a message"
[What should I do?]
--
If I wasn't so busy writing status reports,
my status report might just become a progress report.
Dave.Cross@gb.swissbank.com
------------------------------
Date: Thu, 04 Jun 1998 17:05:19 GMT
From: John Porter <jdporter@min.net>
Subject: Re: splitting via LEADING whitespace
Message-Id: <3576D572.49B0@min.net>
Scott DiNitto wrote:
>
> I want to be able to split an ascii table that looks lhis:
>
> NAME DATE TIME MESSAGE LEFT
>
> John Doe 6-3-98 10:11 This is a message
> Ronald Regan 6-3-98 12:03 My diaper's leaking again
> Eric Cartman 6-4-98 06:09 YOU WILL RESPECT MY
> AUTHORIT-AY!
>
>[yadda yadda]
My solution, below, creates an array, @records, which has entries
corresponding to lines of the input (not including the header or
blank lines).
Each entry in @records is a hash(ref); each hash contains entries
with keys identical to the column headers (i.e. in this case
namely 'NAME', 'DATE', 'TIME', 'MESSAGE LEFT').
Hope this suits your needs. Study and learn (and correct 'em where
you see 'em).
#!/home/porter/local/bin/perl -w
my @records;
my @field;
my $pattern;
my @fpat;
for (<DATA>) {
s/\s+$//; # strip all trailing whitespace;
next unless length;
if ( @field ) {
my %rec;
@rec{ @field } = /$pattern/;
push @records, \%rec;
}
else {
# determine fields
while ( /(.*?)(\s{2,}|$)/g ) {
last unless length($1);
push @field, $1;
push @fpat, '(.{'.length($&).'})';
}
$fpat[-1] = '(.*)';
$pattern = '^' . join('',@fpat);
}
}
for my $r ( @records ) {
for ( sort keys %$r ) {
print " $_=$r->{$_}\n";
}
print "\n";
}
__DATA__
NAME DATE TIME MESSAGE LEFT
John Doe 6-3-98 10:11 This is a message
Ronald Regan 6-3-98 12:03 My diaper's leaking again
Eric Cartman 6-4-98 06:09 YOU WILL RESPECT MY
AUTHORIT-AY!
------------------------------
Date: Thu, 04 Jun 1998 16:33:32 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Taking data out of strings
Message-Id: <3576CE01.1D34@min.net>
Ala Qumsieh wrote:
>
> Marek Jedlinski wrote:
>
> > Ray Rarey <rayr@accessus.net> wrote:
> >
> > >For our school, we have a website that lists all the people that made
> > >the honor roll (about 1,600, so I want to make the pages with perl) and
> > >each line of data in the files is written like this:
> > >LAST NAME, FIRST NAME GRAD. YEAR GPA
> > >I want to get perl to read the files, take out each line one at a time,
> > >and print the person's names in a table cell, their grad year in a
> > >cell, and their gpa in a cell.
> >
> > You didn't say _precisely_ how your data is formatted in the original file.
>
> I think he did:
No, I have to respectfully disagree. He gave the names of the columns;
that's all.
> Why not just split on "one or more spaces" from the beginning?
Because spaces might (or might not) occur in any of the fields.
How could we possibly know, since he did not indicate what the
data actually looks like?
Van Der Veer, Martijn Rilke 1932 3.9
We certainly can't go by the headers he gave, since
"LAST NAME", "FIRST NAME" and "GRAD. YEAR" all have spaces in them!
Ray, would you mind posting some of that data? Thanks.
John Porter
------------------------------
Date: 4 Jun 1998 16:34:50 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Use of HTML, POD, etc in Usenet (was: Re: map in void context regarded as evil - suggestion)
Message-Id: <6l6iba$i0c$1@client3.news.psi.net>
Rajappa Iyer (rsi@lucent.com) wrote on MDCCXXXVIII September MCMXCIII in
<URL: news:xny1zt5wag5.fsf@placebo.ho.lucent.com>:
++ abigail@fnx.com (Abigail) writes:
++
++ > Zenin (zenin@bawdycaste.org) wrote on MDCCXXXVII September MCMXCIII in
++ > ++ What's wrong with using
++ > ++ ---------------------------------------------------------------
++ > ++ instead of <hr>?
++ >
++ > Standards.
++
++ Aah... so HTML is more standard than ASCII? Thanks for this nugget.
You're comparing apples and salt water here. I've yet to see an
ASCII table that defines symbols for emphasis or horizontal lines.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: 04 Jun 1998 13:39:53 -0400
From: Matt Curtin <cmcurtin@interhack.net>
To: rsi@lucent.com
Subject: Re: Use of HTML, POD, etc in Usenet (was: Re: map in void context regarded as evil - suggestion)
Message-Id: <864sy1t6ae.fsf@scooter.cis.ohio-state.edu>
Rajappa Iyer <rsi@lucent.com> writes:
> > Standards.
>
> Aah... so HTML is more standard than ASCII? Thanks for this nugget.
HTML is just as standard as ASCII. It's an open, published standard.
--
Matt Curtin cmcurtin@interhack.net http://www.interhack.net/people/cmcurtin/
------------------------------
Date: 04 Jun 1998 13:56:25 -0400
From: Rajappa Iyer <rsi@lucent.com>
Subject: Re: Use of HTML, POD, etc in Usenet (was: Re: map in void context regarded as evil - suggestion)
Message-Id: <xny7m2xuk3a.fsf@placebo.ho.lucent.com>
abigail@fnx.com (Abigail) writes:
> Rajappa Iyer (rsi@lucent.com) wrote on MDCCXXXVIII September MCMXCIII in
> <URL: news:xny1zt5wag5.fsf@placebo.ho.lucent.com>:
> ++ abigail@fnx.com (Abigail) writes:
> ++
> ++ > Zenin (zenin@bawdycaste.org) wrote on MDCCXXXVII September MCMXCIII in
> ++ > ++ What's wrong with using
> ++ > ++ ---------------------------------------------------------------
> ++ > ++ instead of <hr>?
> ++ >
> ++ > Standards.
> ++
> ++ Aah... so HTML is more standard than ASCII? Thanks for this nugget.
>
> You're comparing apples and salt water here. I've yet to see an
> ASCII table that defines symbols for emphasis or horizontal lines.
Excuse me, but we were talking about standards (as opposed to
conventions) weren't we?
Yes, there are no adequate ways to express emphasis or emotions
(emoticons notwithstanding) in ASCII, but guess what? That's part of
the point. Tone is usually conveyed by the appropriate choice of
words. And where there's a compelling need for emphasis, Usenet has
had conventions for a long time (e.g. *emphasis*, _emphasis or
italics_, SHOUTING etc.) Again, just in case, the point is not clear:
Usenet posts are ostensibly meant for human consumption; given that
these humans are expected only to have a reader which displays ASCII,
posts marked up with markup languages are rude, inconsiderate and
anti-social. It's right up there with sending M$ Word documents as
attachment.
--
Rajappa Iyer <rsi@lucent.com> #include <std_disclaimer.h>
We're too busy mopping the floor to turn off the faucet.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 2807
**************************************