[24783] in Perl-Users-Digest
Perl-Users Digest, Issue: 6936 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 31 06:06:19 2004
Date: Tue, 31 Aug 2004 03:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 31 Aug 2004 Volume: 10 Number: 6936
Today's topics:
Re: Appending two arrays horizontally (David Combs)
Re: Appending two arrays horizontally (Anno Siegel)
Re: In search of grammars for parsing (David Combs)
Re: Matching neighbouring words of a pattern using Rege <noreply@gunnar.cc>
Re: OS/2 port of Perl 5.8 not adding CR to \n (Seymour J.)
Re: perl - data structure build to transpose data <dwall@fastmail.fm>
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
share winlyrics to wmp SMI in perl (lechee)
Split and RegEx Help (Vaughn Sargent)
Re: Split and RegEx Help <jurgenex@hotmail.com>
Re: Split and RegEx Help <uri@stemsystems.com>
Re: Split and RegEx Help <jurgenex@hotmail.com>
Re: Split and RegEx Help <uri@stemsystems.com>
Where's the doc. on perl command-line options? (John Doe)
Re: Where's the doc. on perl command-line options? <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: Where's the doc. on perl command-line options? <sholden@flexal.cs.usyd.edu.au>
Re: Where's the doc. on perl command-line options? (Anno Siegel)
Re: Xah Lee's Unixism <amajorel@teezer.fr>
Re: Xah Lee's Unixism <Brian.Inglis@SystematicSW.Invalid>
Re: Xah Lee's Unixism <loic-dev@gmx.net>
Re: Xah Lee's Unixism (Johnny)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 31 Aug 2004 04:54:29 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Appending two arrays horizontally
Message-Id: <ch10a5$gth$1@reader1.panix.com>
In article <8jafh099fcp79jpe5vmbjtb36dnm257ud9@4ax.com>,
Michele Dondi <bik.mido@tiscalinet.it> wrote:
>On 07 Aug 2004 04:09:22 -0400, Scott W Gifford <gifford@umich.edu>
>wrote:
>
>> my @arr3 = map { join(" ",$arr1[$_],$arr2[$_]) } (0..$#arr1);
>
>Well, I'm not a big fan of useless quoting, but
>
> my @arr3 = map "$arr1[$_],$arr2[$_]", 0..$#arr1;
>
>is more clear IMHO.
>
>>Assuming you know in advance they're both the same size:
>
>Also, not difficult to cope with this:
>
> my @arr3 = do {
> no warnings 'uninitialized';
> map "$arr1[$_] $arr2[$_]",
> 0 .. ($#arr1>$#arr2 ? $#arr1 : $#arr2);
> };
>
>(implicitly assuming C<use warnings;> as it "Should"!)
Why the no-warnings stmt?
In case one of the arrays is uninitialized?
Or in case one of the values *within* one of the
arrays is?
Maybe I've been blind, but this is the first
time I've seen a no-warnings used in this kind
of situation. (Well, at least it's rarely seen
in this group's code-pieces.)
Anything to say about whether to do this
in general?
Also -- *why* turn off the warnings, ie why
don't you *want* to know about them (these "errors"?)?
Thanks!
David
------------------------------
Date: 31 Aug 2004 07:18:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Appending two arrays horizontally
Message-Id: <ch18oi$c75$1@mamenchi.zrz.TU-Berlin.DE>
David Combs <dkcombs@panix.com> wrote in comp.lang.perl.misc:
> In article <8jafh099fcp79jpe5vmbjtb36dnm257ud9@4ax.com>,
> Michele Dondi <bik.mido@tiscalinet.it> wrote:
> >On 07 Aug 2004 04:09:22 -0400, Scott W Gifford <gifford@umich.edu>
> >wrote:
> >
> >> my @arr3 = map { join(" ",$arr1[$_],$arr2[$_]) } (0..$#arr1);
> >
> >Well, I'm not a big fan of useless quoting, but
> >
> > my @arr3 = map "$arr1[$_],$arr2[$_]", 0..$#arr1;
> >
> >is more clear IMHO.
> >
> >>Assuming you know in advance they're both the same size:
> >
> >Also, not difficult to cope with this:
> >
> > my @arr3 = do {
> > no warnings 'uninitialized';
> > map "$arr1[$_] $arr2[$_]",
> > 0 .. ($#arr1>$#arr2 ? $#arr1 : $#arr2);
> > };
> >
> >(implicitly assuming C<use warnings;> as it "Should"!)
>
> Why the no-warnings stmt?
>
> In case one of the arrays is uninitialized?
No. An uninitialized array is never a problem, it behaves like an
empty array. The same goes for hashes, it's only scalars where
the distinction makes a difference.
> Or in case one of the values *within* one of the
> arrays is?
Possibly that, but mainly to catch undefined values that come from
*outside* one of the arrays.
The arrays will in general have different lengths and the index runs
over the longer of the two. So the shorter array will be probed beyond
its end and return undefs. The main purpose of "no warnings ..." is
to catch those.
Anno
------------------------------
Date: Tue, 31 Aug 2004 04:40:27 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: In search of grammars for parsing
Message-Id: <ch0vfr$gnk$1@reader1.panix.com>
In article <qhu7h0li4adhvph43cmeema969lfqdr2p6@4ax.com>,
Joe Y Perro <joe_y_perroREMOVETHIS@yahooREMOVETHISALSOcom> wrote:
>Hi,
>
>>
>>- Parse::Yapp includes YappParse.yp, which partially parses most of a YACC
>> grammar. I'd have to modify it to parse the tokens and union
>> declaration.
>
>In the test directory for Yapp, the file stress.t includes a full C++
>grammar.
>
>>
>>== Parsing C/C++ ==
>For C, check the source code for gcc at http://www.gnu.org/
>>
>>- I could try Inline::C::ParseRegExp or Inline::C::ParseRecDescent for C,
>> and Inline::CPP::grammar for C++.
>>- PERCEPS (http://starship.python.net/crew/tbryan/PERCEPS/) is a Perl
>> header file parser. Not sure how well it would work for the head section
>> of a YACC or LEX input file.
>>
>>In the worst case, both the bison and flex distributions have grammars,
>>which I could adapt to suitable input for Parse::RecDescent or
>>Parse::Yapp. But I can't help but think that someone has already done all
>>this work.
>
>I would stick with Yapp. Its more compatible than RecDescent,
>especially if your re-using existing YACC/LEX files. For a project
>last winter I tried to move a YACC grammar to RecDescent, but the
>left/right recursions issues made it too time consuming to fix. Yapp
>worked. Note you will have to write your own lexer routine --
>converting from a LEX file shouldn't be too difficult.
Long, long time ago I sat-in on a couple or three
compiler classes -- used the dragon book.
Now, I never really understood this LR or LALR or
whatever-it-was-called kind of grammar (or parsing?)
that YACC was written for.
Anyway, not only was it hairy as hell, this kind of
parsing, and grammar -- I think that it was also bottom-up.
Now, I could be wrong on all of this -- but the name
recursive *descent* implies top-down, maybe?
If so, YACC and the grammars it was written for (eg, C's)
is what, maybe orthogonal, to recursive-descent? By
their very natures?
Somebody either affirm this, or correct me, set
me straight.
Thanks!
DAvid
------------------------------
Date: Tue, 31 Aug 2004 03:27:49 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Matching neighbouring words of a pattern using Regex
Message-Id: <2pi2p9FkjupmU1@uni-berlin.de>
Tad McClellan wrote:
> Gunnar Hjalmarsson wrote:
>>
>> - '\w*\b\w*' is an impossible combination that can never match
>
> It will match any string with at least one \w character in it:
>
> $_ = 'hi';
> print "matched '$&'\n" if /\w*\b\w*/;
>
>> (check
>> out the description of \b in "perldoc perlre" to learn why).
>
> Check out this part too:
>
> ... counting the imaginary characters off the
> beginning and end of the string as matching a \W
>
> :-)
>
> \W could be the beginning of string in the OP's regex.
Thanks, Tad, I stand corrected (even if it doesn't do what the OP
wanted it to do...).
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 31 Aug 2004 00:32:19 -0300
From: "Shmuel (Seymour J.) Metz" <spamtrap@library.lspace.org.invalid>
Subject: Re: OS/2 port of Perl 5.8 not adding CR to \n
Message-Id: <4133ff54$4$fuzhry+tra$mr2ice@news.patriot.net>
In <cgvs2t$2nst$1@agate.berkeley.edu>, on 08/30/2004
at 06:36 PM, Ilya Zakharevich <nospam-abuse@ilyaz.org> said:
>"Correct"???
That is, I wanted to verify that the Perl at
<http://www.cpan.org/authors/id/I/IL/ILYAZ/os2/582+/> is in fact the
most recnt OS/2 port.
>What bug?
The code
print "testline1a\ntestline1b\n","testline2\n";
print "testline2\n";
Produces the output
testline1a
testline1b
testline2
This occurs even if I
SET PerlIO=:crlf
--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>
Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to spamtrap@library.lspace.org
------------------------------
Date: Tue, 31 Aug 2004 05:44:18 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: perl - data structure build to transpose data
Message-Id: <Xns955611AF95D61dkwwashere@216.168.3.30>
"John W. Krahn" <someone@example.com> wrote:
> shree wrote:
>>
>> I was wondering if anyone can suggest a perl book or website thats
>> filled with illustrative examples of problems involving complex data
>> structures. To me, this is the hardest concept to grasp.
>
> You should probably check out this book and see if it meets your
> requirements: http://www.oreilly.com/catalog/maperl/index.html
On a less advanced level, you (shree) should probably read -- if you haven't
already -- these parts of the Perl docs: perldsc, perllol, perlreftut, and
perlref. (Did I miss any?) "The Perl Cookbook" is full of useful tips; you
might like it, too. I'd also recommend "Learning Perl Objects, References &
Modules", even though it's not exactly what you asked for.
See http://learn.perl.org/ for these and other recommendations.
Oh, and possibly search the Google archives of comp.lang.perl.misc for such
phrases as "hash of hashes", "hash of arrays", "array of hashes", and so on.
Lots of good stuff in the archives -- and lots of crap, too, some of it
posted by me.
------------------------------
Date: Tue, 31 Aug 2004 02:23:19 -0500
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
Message-Id: <36udnbfXJuL6uqncRVn-sw@august.net>
Outline
Before posting to comp.lang.perl.misc
Must
- Check the Perl Frequently Asked Questions (FAQ)
- Check the other standard Perl docs (*.pod)
Really Really Should
- Lurk for a while before posting
- Search a Usenet archive
If You Like
- Check Other Resources
Posting to comp.lang.perl.misc
Is there a better place to ask your question?
- Question should be about Perl, not about the application area
How to participate (post) in the clpmisc community
- Carefully choose the contents of your Subject header
- Use an effective followup style
- Speak Perl rather than English, when possible
- Ask perl to help you
- Do not re-type Perl code
- Provide enough information
- Do not provide too much information
- Do not post binaries, HTML, or MIME
Social faux pas to avoid
- Asking a Frequently Asked Question
- Asking a question easily answered by a cursory doc search
- Asking for emailed answers
- Beware of saying "doesn't work"
- Sending a "stealth" Cc copy
Be extra cautious when you get upset
- Count to ten before composing a followup when you are upset
- Count to ten after composing and before posting when you are upset
-----------------------------------------------------------------
Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
This newsgroup, commonly called clpmisc, is a technical newsgroup
intended to be used for discussion of Perl related issues (except job
postings), whether it be comments or questions.
As you would expect, clpmisc discussions are usually very technical in
nature and there are conventions for conduct in technical newsgroups
going somewhat beyond those in non-technical newsgroups.
The article at:
http://www.catb.org/~esr/faqs/smart-questions.html
describes how to get answers from technical people in general.
This article describes things that you should, and should not, do to
increase your chances of getting an answer to your Perl question. It is
available in POD, HTML and plain text formats at:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
For more information about netiquette in general, see the "Netiquette
Guidelines" at:
http://andrew2.andrew.cmu.edu/rfc/rfc1855.html
A note to newsgroup "regulars":
Do not use these guidelines as a "license to flame" or other
meanness. It is possible that a poster is unaware of things
discussed here. Give them the benefit of the doubt, and just
help them learn how to post, rather than assume
A note about technical terms used here:
In this document, we use words like "must" and "should" as
they're used in technical conversation (such as you will
encounter in this newsgroup). When we say that you *must* do
something, we mean that if you don't do that something, then
it's unlikely that you will benefit much from this group.
We're not bossing you around; we're making the point without
lots of words.
Do *NOT* send email to the maintainer of these guidelines. It will be
discarded unread. The guidelines belong to the newsgroup so all
discussion should appear in the newsgroup. I am just the secretary that
writes down the consensus of the group.
Before posting to comp.lang.perl.misc
Must
This section describes things that you *must* do before posting to
clpmisc, in order to maximize your chances of getting meaningful replies
to your inquiry and to avoid getting flamed for being lazy and trying to
have others do your work.
The perl distribution includes documentation that is copied to your hard
drive when you install perl. Also installed is a program for looking
things up in that (and other) documentation named 'perldoc'.
You should either find out where the docs got installed on your system,
or use perldoc to find them for you. Type "perldoc perldoc" to learn how
to use perldoc itself. Type "perldoc perl" to start reading Perl's
standard documentation.
Check the Perl Frequently Asked Questions (FAQ)
Checking the FAQ before posting is required in Big 8 newsgroups in
general, there is nothing clpmisc-specific about this requirement.
You are expected to do this in nearly all newsgroups.
You can use the "-q" switch with perldoc to do a word search of the
questions in the Perl FAQs.
Check the other standard Perl docs (*.pod)
The perl distribution comes with much more documentation than is
available for most other newsgroups, so in clpmisc you should also
see if you can find an answer in the other (non-FAQ) standard docs
before posting.
It is *not* required, or even expected, that you actually *read* all of
Perl's standard docs, only that you spend a few minutes searching them
before posting.
Try doing a word-search in the standard docs for some words/phrases
taken from your problem statement or from your very carefully worded
"Subject:" header.
Really Really Should
This section describes things that you *really should* do before posting
to clpmisc.
Lurk for a while before posting
This is very important and expected in all newsgroups. Lurking means
to monitor a newsgroup for a period to become familiar with local
customs. Each newsgroup has specific customs and rituals. Knowing
these before you participate will help avoid embarrassing social
situations. Consider yourself to be a foreigner at first!
Search a Usenet archive
There are tens of thousands of Perl programmers. It is very likely
that your question has already been asked (and answered). See if you
can find where it has already been answered.
One such searchable archive is:
http://groups.google.com/advanced_group_search
If You Like
This section describes things that you *can* do before posting to
clpmisc.
Check Other Resources
You may want to check in books or on web sites to see if you can
find the answer to your question.
But you need to consider the source of such information: there are a
lot of very poor Perl books and web sites, and several good ones
too, of course.
Posting to comp.lang.perl.misc
There can be 200 messages in clpmisc in a single day. Nobody is going to
read every article. They must decide somehow which articles they are
going to read, and which they will skip.
Your post is in competition with 199 other posts. You need to "win"
before a person who can help you will even read your question.
These sections describe how you can help keep your article from being
one of the "skipped" ones.
Is there a better place to ask your question?
Question should be about Perl, not about the application area
It can be difficult to separate out where your problem really is,
but you should make a conscious effort to post to the most
applicable newsgroup. That is, after all, where you are the most
likely to find the people who know how to answer your question.
Being able to "partition" a problem is an essential skill for
effectively troubleshooting programming problems. If you don't get
that right, you end up looking for answers in the wrong places.
It should be understood that you may not know that the root of your
problem is not Perl-related (the two most frequent ones are CGI and
Operating System related), so off-topic postings will happen from
time to time. Be gracious when someone helps you find a better place
to ask your question by pointing you to a more applicable newsgroup.
How to participate (post) in the clpmisc community
Carefully choose the contents of your Subject header
You have 40 precious characters of Subject to win out and be one of
the posts that gets read. Don't waste them. Take care while
composing them, they are the key that opens the door to getting an
answer.
Spend them indicating what aspect of Perl others will find if they
should decide to read your article.
Do not spend them indicating "experience level" (guru, newbie...).
Do not spend them pleading (please read, urgent, help!...).
Do not spend them on non-Subjects (Perl question, one-word
Subject...)
For more information on choosing a Subject see "Choosing Good
Subject Lines":
http://www.cpan.org/authors/id/D/DM/DMR/subjects.post
Part of the beauty of newsgroup dynamics, is that you can contribute
to the community with your very first post! If your choice of
Subject leads a fellow Perler to find the thread you are starting,
then even asking a question helps us all.
Use an effective followup style
When composing a followup, quote only enough text to establish the
context for the comments that you will add. Always indicate who
wrote the quoted material. Never quote an entire article. Never
quote a .signature (unless that is what you are commenting on).
Intersperse your comments *following* each section of quoted text to
which they relate. Unappreciated followup styles are referred to as
"top-posting", "Jeopardy" (because the answer comes before the
question), or "TOFU" (Text Over, Fullquote Under).
Reversing the chronology of the dialog makes it much harder to
understand (some folks won't even read it if written in that style).
For more information on quoting style, see:
http://web.presby.edu/~nnqadmin/nnq/nquote.html
Speak Perl rather than English, when possible
Perl is much more precise than natural language. Saying it in Perl
instead will avoid misunderstanding your question or problem.
Do not say: I have variable with "foo\tbar" in it.
Instead say: I have $var = "foo\tbar", or I have $var = 'foo\tbar',
or I have $var = <DATA> (and show the data line).
Ask perl to help you
You can ask perl itself to help you find common programming mistakes
by doing two things: enable warnings (perldoc warnings) and enable
"strict"ures (perldoc strict).
You should not bother the hundreds/thousands of readers of the
newsgroup without first seeing if a machine can help you find your
problem. It is demeaning to be asked to do the work of a machine. It
will annoy the readers of your article.
You can look up any of the messages that perl might issue to find
out what the message means and how to resolve the potential mistake
(perldoc perldiag). If you would like perl to look them up for you,
you can put "use diagnostics;" near the top of your program.
Do not re-type Perl code
Use copy/paste or your editor's "import" function rather than
attempting to type in your code. If you make a typo you will get
followups about your typos instead of about the question you are
trying to get answered.
Provide enough information
If you do the things in this item, you will have an Extremely Good
chance of getting people to try and help you with your problem!
These features are a really big bonus toward your question winning
out over all of the other posts that you are competing with.
First make a short (less than 20-30 lines) and *complete* program
that illustrates the problem you are having. People should be able
to run your program by copy/pasting the code from your article. (You
will find that doing this step very often reveals your problem
directly. Leading to an answer much more quickly and reliably than
posting to Usenet.)
Describe *precisely* the input to your program. Also provide example
input data for your program. If you need to show file input, use the
__DATA__ token (perldata.pod) to provide the file contents inside of
your Perl program.
Show the output (including the verbatim text of any messages) of
your program.
Describe how you want the output to be different from what you are
getting.
If you have no idea at all of how to code up your situation, be sure
to at least describe the 2 things that you *do* know: input and
desired output.
Do not provide too much information
Do not just post your entire program for debugging. Most especially
do not post someone *else's* entire program.
Do not post binaries, HTML, or MIME
clpmisc is a text only newsgroup. If you have images or binaries
that explain your question, put them in a publically accessible
place (like a Web server) and provide a pointer to that location. If
you include code, cut and paste it directly in the message body.
Don't attach anything to the message. Don't post vcards or HTML.
Many people (and even some Usenet servers) will automatically filter
out such messages. Many people will not be able to easily read your
post. Plain text is something everyone can read.
Social faux pas to avoid
The first two below are symptoms of lots of FAQ asking here in clpmisc.
It happens so often that folks will assume that it is happening yet
again. If you have looked but not found, or found but didn't understand
the docs, say so in your article.
Asking a Frequently Asked Question
It should be understood that you may have missed the applicable FAQ
when you checked, which is not a big deal. But if the Frequently
Asked Question is worded similar to your question, folks will assume
that you did not look at all. Don't become indignant at pointers to
the FAQ, particularly if it solves your problem.
Asking a question easily answered by a cursory doc search
If folks think you have not even tried the obvious step of reading
the docs applicable to your problem, they are likely to become
annoyed.
If you are flamed for not checking when you *did* check, then just
shrug it off (and take the answer that you got).
Asking for emailed answers
Emailed answers benefit one person. Posted answers benefit the
entire community. If folks can take the time to answer your
question, then you can take the time to go get the answer in the
same place where you asked the question.
It is OK to ask for a *copy* of the answer to be emailed, but many
will ignore such requests anyway. If you munge your address, you
should never expect (or ask) to get email in response to a Usenet
post.
Ask the question here, get the answer here (maybe).
Beware of saying "doesn't work"
This is a "red flag" phrase. If you find yourself writing that,
pause and see if you can't describe what is not working without
saying "doesn't work". That is, describe how it is not what you
want.
Sending a "stealth" Cc copy
A "stealth Cc" is when you both email and post a reply without
indicating *in the body* that you are doing so.
Be extra cautious when you get upset
Count to ten before composing a followup when you are upset
This is recommended in all Usenet newsgroups. Here in clpmisc, most
flaming sub-threads are not about any feature of Perl at all! They
are most often for what was seen as a breach of netiquette. If you
have lurked for a bit, then you will know what is expected and won't
make such posts in the first place.
But if you get upset, wait a while before writing your followup. I
recommend waiting at least 30 minutes.
Count to ten after composing and before posting when you are upset
After you have written your followup, wait *another* 30 minutes
before committing yourself by posting it. You cannot take it back
once it has been said.
AUTHOR
Tad McClellan <tadmc@augustmail.com> and many others on the
comp.lang.perl.misc newsgroup.
------------------------------
Date: 31 Aug 2004 02:25:50 -0700
From: lecheel@yahoo.com (lechee)
Subject: share winlyrics to wmp SMI in perl
Message-Id: <3f98c481.0408310125.3a1e6715@posting.google.com>
#!/usr/bin/perl
#
# lrc2smi lyrics to plain text (wmp smi) v1.00 (perl)
#
# convert lyrics .lrc to WMP smi
#
# copyright 2004 Lechee.Lai lecheel at yahoo dot com
#
# global variable
use File::Basename;
my $tcount=0;
my $tcontext;
$argc=@ARGV
&convertLRC();
exit 1;
sub convertLRC {
open(FILE, @ARGV[0]) or die "lrc2smi: you must have \"@ARGV[0]\"
for convert :-)\n";
my $out=basename(@ARGV[0],"");
if ($out=~/(.*)\..*/ and !$option{'withextension'})
{$out=~s/(.*)\..*/$1\.smi/;}
else {$out.=".smi";}
$pureLrc = ">$out";
@file = <FILE>;
close (FILE);
open (NEWFILE, $pureLrc) or die "$!";
&SMIbegin();
&SMItitle();
foreach $line (@file) {
chomp ($line);
$line1 = $line;
# if ($line1 =~ /^\[(\d{2})\:(\d{2})\](.*)$/) { # check [nn:nn]
if ($line1 =~ /^(.*)(:)(.*)(])/) { # check *:*]
$line2 = $line1;
if ($line2 =~ /\d(:)+\d+(])/) { # check nnn:nnn]
# if (1) {
$l1 = $line1;
checkTimeStamp($line1);
$noMore=0;
while ($noMore==0) {
if ($l1 =~ /^(.*)\d{2}(])/) { # have vaild
timestamp
$pos = index($l1, "]");
$timestamp = substr($l1, 0, $pos+1);
if ($timestamp =~ /^\[(\d{2})\:(\d{2})\](.*)$/) {
my ($m, $s) = ($1, $2);
my $sec = $s+60*$m;
while (exists $times{$sec}){
$sec += 0.01;
}
&SMItime($sec);
}
if ($tcount) {
print NEWFILE "$tcontext";
}
print NEWFILE "\n";
$l1 = substr($l1,$pos+1);
} else {
$noMore=1;
}
}
} else {
# print "###$line1\n";
}
} else {
# print "---$line\n";
}
}
&SMIend();
close(NEWFILE);
}
sub checkTimeStamp($) {
my ($line) = @_;
$tcount = 0; # initialize for TimeCount
$pos = rindex($line,"]");
$tcontext = substr($line,$pos+1);
if ($pos>5) {
$tcount = 1;
}
# print "...$tcontext\n";
}
sub SMIbegin {
print NEWFILE "<SAMI>\n";
print NEWFILE "<HEAD>\n";
print NEWFIEL "<TITLE>Lechee Lyrics SMI</TITLE>\n";
}
sub SMItitle {
print NEWFILE "<STYLE TYPE=\"text/css\">\n<!--\nP {\n";
print NEWFILE "margin-left:8pt;\n";
print NEWFILE "margin-right:8pt;\n";
print NEWFILE "margin-bottom:24pt;\n";
print NEWFILE "Background-image : url();\n";
print NEWFILE "line-height:48pt;\n";
print NEWFILE "Background-color:#000000;\n";
print NEWFILE "text-align:center;\n";
print NEWFILE "font-size:16pt;\n";
print NEWFILE "font-family:,tahoma,arial,dotum,sans-serif;\n";
print NEWFILE "font-weight:bold;\n";
print NEWFILE "font-style:Normal;\n";
print NEWFILE "color:#ffff00;\n";
print NEWFILE "}\n";
print NEWFILE ".CCUS {Name:English; lang: en-US;\n}\n-->\n";
print NEWFILE "</STYLE>/n</HEAD>\n";
print NEWFILE "<BODY>\n";
}
sub SMIend {
print NEWFILE "</BODY>\n";
print NEWFILE "</SAMI>\n";
}
sub SMItime($) {
my ($tt) = @_;
print NEWFILE "<SYNC Start=";
print NEWFILE $tt;
print NEWFILE "000><P Class=EGCC>";
}
------------------------------
Date: 30 Aug 2004 20:28:20 -0700
From: sulvand@gmail.com (Vaughn Sargent)
Subject: Split and RegEx Help
Message-Id: <e94beb1c.0408301928.5137340@posting.google.com>
Hi,
I have some flat file data coming in from a client that is ~
delimited. I have no control over the incoming data so I'm stuck with
the ~. What I need to do is split the data into fields (which should
be easy using split) however, some text fields may contain a ~ but
it's not the delimiter, it's just part of the text field. All text
fields are enclosed with double quotes. Number and date fields are
not. So I may recieve data such as the following 5 field line:
"Field - One"~234.00~"Field ~ 3"~20040830~"Field 5"
What I want returned is:
Field 1: "Field - One"
Field 2: 234.00
Field 3: "Field ~ 3"
Field 4: 20040830
Field 5: "Field 5"
But using split perl returns:
Field 1: "Field - One"
Field 2: 234.00
Field 3: "Field
Field 4: 3"
Field 5: 20040830
Field 6: "Field 5"
It would also be possible for any text field to contain more than one
~ as a non-delimiter which may or may not be next to each other.
I guess what I would like to tell perl is "Hey, Perl, split this line
for me using ~ as the delimiter but ~ isn't a delimiter if there are
double quotes around it."
I thought it might be possible to use split and tack on a regular
expression. I'm a newbie when it comes to regular expressions.
If anyone can help me out I'd be very greatful.
Vaughn
------------------------------
Date: Tue, 31 Aug 2004 03:44:47 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Split and RegEx Help
Message-Id: <PuSYc.4793$Cj5.2914@trnddc04>
Vaughn Sargent wrote:
> I have some flat file data coming in from a client that is ~
> delimited. I have no control over the incoming data so I'm stuck with
> the ~. What I need to do is split the data into fields (which should
> be easy using split) however, some text fields may contain a ~ but
> it's not the delimiter, it's just part of the text field. All text
> fields are enclosed with double quotes.
You may want to have a look at Text::CSV.
Although it uses a comma as the separator for the data fields it should be
trivial to copy the source code and modify it to use the ~ instead.
jue
------------------------------
Date: Tue, 31 Aug 2004 03:48:20 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Split and RegEx Help
Message-Id: <x7fz64ezon.fsf@mail.sysarch.com>
>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:
JE> Vaughn Sargent wrote:
>> I have some flat file data coming in from a client that is ~
>> delimited. I have no control over the incoming data so I'm stuck with
>> the ~. What I need to do is split the data into fields (which should
>> be easy using split) however, some text fields may contain a ~ but
>> it's not the delimiter, it's just part of the text field. All text
>> fields are enclosed with double quotes.
JE> You may want to have a look at Text::CSV. Although it uses a
JE> comma as the separator for the data fields it should be trivial to
JE> copy the source code and modify it to use the ~ instead.
without even looking, i wager it has an option to set the separator. it
is too easy and such a commonly needed feature to believe it doesn't
support that.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Tue, 31 Aug 2004 04:09:27 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Split and RegEx Help
Message-Id: <XRSYc.3114$XK5.2593@trnddc02>
Uri Guttman wrote:
>>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:
>
>> Vaughn Sargent wrote:
> >> I have some flat file data coming in from a client that is ~
> >> delimited. I have no control over the incoming data so I'm stuck
> with >> the ~. What I need to do is split the data into fields
> (which should >> be easy using split) however, some text fields may
> contain a ~ but >> it's not the delimiter, it's just part of the
> text field. All text >> fields are enclosed with double quotes.
>
>> You may want to have a look at Text::CSV. Although it uses a
>> comma as the separator for the data fields it should be trivial to
>> copy the source code and modify it to use the ~ instead.
>
> without even looking, i wager it has an option to set the separator.
> it is too easy and such a commonly needed feature to believe it
> doesn't support that.
For a second you really scared me because I didn't check, either.
However according to the module doc on CPAN the standard Text::CSV does not
support changing the separator character (I win).
For that you need to use Text::CSV_XS (you win):
new(\%attr)
sep_char
The char used for separating fields, by default a comme. (,)
Now, what do we do with the prices?
jue
------------------------------
Date: Tue, 31 Aug 2004 05:28:18 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Split and RegEx Help
Message-Id: <x71xhng9mi.fsf@mail.sysarch.com>
>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:
JE> Uri Guttman wrote:
>>>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:
>>
>>> Vaughn Sargent wrote:
>> >> I have some flat file data coming in from a client that is ~
>> >> delimited. I have no control over the incoming data so I'm stuck
>> with >> the ~. What I need to do is split the data into fields
>> (which should >> be easy using split) however, some text fields may
>> contain a ~ but >> it's not the delimiter, it's just part of the
>> text field. All text >> fields are enclosed with double quotes.
>>
>>> You may want to have a look at Text::CSV. Although it uses a
>>> comma as the separator for the data fields it should be trivial to
>>> copy the source code and modify it to use the ~ instead.
>>
>> without even looking, i wager it has an option to set the separator.
>> it is too easy and such a commonly needed feature to believe it
>> doesn't support that.
JE> For a second you really scared me because I didn't check, either.
JE> However according to the module doc on CPAN the standard Text::CSV does not
JE> support changing the separator character (I win).
JE> For that you need to use Text::CSV_XS (you win):
JE> new(\%attr)
JE> sep_char
JE> The char used for separating fields, by default a comme. (,)
JE> Now, what do we do with the prices?
well, i say it is a push (pun intended!).
odd how the xs version which usually requires more work has the option.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 31 Aug 2004 00:14:25 -0700
From: workingstiff19@hotmail.com (John Doe)
Subject: Where's the doc. on perl command-line options?
Message-Id: <440d3e16.0408302314.221477e0@posting.google.com>
For example, I need to know what "perl -an" does. It's not in the
"man perl" page. Could not find it at perl.org or Perlmonks.
Google-searched comp.lang.perl.* for things like "command line
switches," "command line arguments," and "command line options," only
to find info on argument processing. [SARCASM] I admit that anyone
with half a brain should be able to divine which of the 90 (count 'em,
ninety) core documentation modules has what I seek: [/SARCASM]
perl
perltoc
perlreftut
perldsc
perllol
perlrequick
perlretut
perlboot
perltoot
...etcetera, but maybe one of you gurus can clue me in. :-)
------------------------------
Date: Tue, 31 Aug 2004 09:26:14 +0200
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Where's the doc. on perl command-line options?
Message-Id: <Xns95566082AF206elhber1lidotechnet@62.89.127.66>
workingstiff19@hotmail.com (John Doe) wrote:
> For example, I need to know what "perl -an" does. [...]
perldoc perlrun
--
Cheers,
Bernard
------------------------------
Date: 31 Aug 2004 07:30:54 GMT
From: Sam Holden <sholden@flexal.cs.usyd.edu.au>
Subject: Re: Where's the doc. on perl command-line options?
Message-Id: <slrncj8a9e.78u.sholden@flexal.cs.usyd.edu.au>
On 31 Aug 2004 00:14:25 -0700, John Doe <workingstiff19@hotmail.com> wrote:
> For example, I need to know what "perl -an" does. It's not in the
> "man perl" page. Could not find it at perl.org or Perlmonks.
> Google-searched comp.lang.perl.* for things like "command line
> switches," "command line arguments," and "command line options," only
> to find info on argument processing. [SARCASM] I admit that anyone
> with half a brain should be able to divine which of the 90 (count 'em,
> ninety) core documentation modules has what I seek: [/SARCASM]
> perl
If you actually read that one you'll find the line:
perlrun Perl execution and options
Since "-an" is an option that seems to a pointer to the place to
look. If you don't know what an "option" (in the domain of
"execution") is then your OS documentation has failed).
> perltoc
This one contains:
perlrun - how to execute the Perl interpreter
SYNOPSIS
DESCRIPTION
#! and quoting on non-Unix systems
OS/2, MS-DOS, Win95/NT, Macintosh, VMS
Location of Perl
Command Switches
-0[octal/hexadecimal], -a, -C [number/list], -c, -d,
-d:foo[=bar,baz], -Dletters, -Dnumber, -e commandline,
-Fpattern, -h, -i[extension], -Idirectory, -l[octnum],
-m[-]module, -M[-]module, -M[-]'module ...',
-[mM][-]module=arg[,arg]..., -n, -p, -P, -s, -S, -t, -T,
-u, -U, -v, -V, -V:name, -w, -W, -X, -x directory
Which not only points to the appropriate documentation but contains the
two switches in the description (-a and -n).
> perlreftut
> perldsc
> perllol
> perlrequick
> perlretut
> perlboot
> perltoot
> ...etcetera, but maybe one of you gurus can clue me in. :-)
None of those have anything to do with the example question, so
looking in them is just silly.
The first two places were the obvious starting points, since they
contain references to the places where the real documentation is,
and as shown above contain what you want if you bother reading them.
You aren't supposed to randomly select a few of the "90" manuals.
You check the overview and the table of contents, just like you
would with any other reference material. You don't just turn to
random pages when trying to find a car mechanic in the phone book,
do you?
--
Sam Holden
------------------------------
Date: 31 Aug 2004 07:36:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Where's the doc. on perl command-line options?
Message-Id: <ch19qq$dcv$1@mamenchi.zrz.TU-Berlin.DE>
John Doe <workingstiff19@hotmail.com> wrote in comp.lang.perl.misc:
> For example, I need to know what "perl -an" does. It's not in the
perldoc perlrun
> "man perl" page. Could not find it at perl.org or Perlmonks.
> Google-searched comp.lang.perl.* for things like "command line
> switches," "command line arguments," and "command line options," only
> to find info on argument processing. [SARCASM] I admit that anyone
> with half a brain should be able to divine which of the 90 (count 'em,
> ninety) core documentation modules has what I seek: [/SARCASM]
The table of contents is perltoc. Looking for "Command Switches" there
finds perlrun.
Anno
------------------------------
Date: Tue, 31 Aug 2004 01:12:55 +0000 (UTC)
From: Andre Majorel <amajorel@teezer.fr>
Subject: Re: Xah Lee's Unixism
Message-Id: <slrncj7hhh.2pt.amajorel@atc5.vermine.org>
On 2004-08-30, Antony Sequeira <usemyfullname@hotmail.com> wrote:
> Andre Majorel wrote:
>> On 2004-08-28, Rob Warnock <rpw3@rpw3.org> wrote:
>>
>>>Pascal Bourguignon <spam@mouse-potato.com> wrote:
>>>+---------------
>>>| $ telnet xahlee.org 80;
>>>| Trying 208.186.130.4...
>>>| Connected to xahlee.org.
>>>| Escape character is '^]'.
>>>| GET / HTTP/1.1
>>>|
>>>| HTTP/1.1 400 Bad Request
>>>| Date: Fri, 27 Aug 2004 01:35:52 GMT
>>>| Server: Apache/2.0.50 (Fedora)
>>>| ^^^^^^^^^^^^^^^^^^^^^^
>>>+---------------
>>>
>>>So are you complaining about the fact that his hosting provider
>>>preloaded RedHat Fedora with Apache 2.0 for him?
>>
>>
>> There is no shortage of Windows-based hosting companies, so why
>> didn't he go there ? Whatever your opinions, it's best to put
>> your money where your mouth is if you expect to be taken
>> seriously.
>
> Windows (MS) is not 'Unixism'?
If by unixism, you mean any operating system that has a
hierarchical filesystem and byte stream files, yes. But that
would include quite a few other non-Unix operating systems,
including Mac OS 9, Prologue and probably everything else this
side of CP/M (DOS 1.x shall be deemed to be CP/M).
--
André Majorel <URL:http://www.teaser.fr/~amajorel/>
Conscience is what hurts when everything else feels so good.
------------------------------
Date: Tue, 31 Aug 2004 04:23:11 GMT
From: Brian Inglis <Brian.Inglis@SystematicSW.Invalid>
Subject: Re: Xah Lee's Unixism
Message-Id: <p7v7j0plcfbden593l1irfprmfkp4d3k51@4ax.com>
On Tue, 31 Aug 2004 01:12:55 +0000 (UTC) in alt.folklore.computers,
Andre Majorel <amajorel@teezer.fr> wrote:
>On 2004-08-30, Antony Sequeira <usemyfullname@hotmail.com> wrote:
>> Windows (MS) is not 'Unixism'?
>
>If by unixism, you mean any operating system that has a
>hierarchical filesystem and byte stream files, yes. But that
>would include quite a few other non-Unix operating systems,
>including Mac OS 9, Prologue and probably everything else this
>side of CP/M (DOS 1.x shall be deemed to be CP/M).
DOS 2.x+ shall be deemed to be CP/M+!
--
Thanks. Take care, Brian Inglis Calgary, Alberta, Canada
Brian.Inglis@CSi.com (Brian[dot]Inglis{at}SystematicSW[dot]ab[dot]ca)
fake address use address above to reply
------------------------------
Date: Tue, 31 Aug 2004 06:30:08 +0200
From: Loic Domaigne <loic-dev@gmx.net>
Subject: Re: Xah Lee's Unixism
Message-Id: <2pid4pFl4d08U1@uni-berlin.de>
>>Windows (MS) is not 'Unixism'?
>
>
> It's VMS'ism !
Without all the security aspects, of course...
Loic.
------------------------------
Date: 30 Aug 2004 21:33:57 -0700
From: spam_depository2004@yahoo.com (Johnny)
Subject: Re: Xah Lee's Unixism
Message-Id: <2a56f6a3.0408302033.622bf4e2@posting.google.com>
Pascal Bourguignon <spam@mouse-potato.com> wrote in message news:<87hdqptl96.fsf_-_@thalassa.informatimago.com>...
>
> $ telnet xahlee.org 80;
> Trying 208.186.130.4...
> Connected to xahlee.org.
> Escape character is '^]'.
> GET / HTTP/1.1
>
> HTTP/1.1 400 Bad Request
> Date: Fri, 27 Aug 2004 01:35:52 GMT
> Server: Apache/2.0.50 (Fedora)
> ^^^^^^^^^^^^^^^^^^^^^^
Xah probably couldn't find any LispM based servers. Can you blame him?
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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.
#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 V10 Issue 6936
***************************************