[25910] in Perl-Users-Digest
Perl-Users Digest, Issue: 8136 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 31 21:05:30 2005
Date: Tue, 31 May 2005 18:05:05 -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 May 2005 Volume: 10 Number: 8136
Today's topics:
Re: numbers and strings and regex? <geoff.cox@notquitecorrectfreeuk.com>
Re: numbers and strings and regex? <geoff.cox@notquitecorrectfreeuk.com>
Re: numbers and strings and regex? <nobull@mail.com>
Parsing Tracklisting - discussion <klubbheads@Remove-ME-rogers.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 31 May 2005 19:42:03 GMT
From: Geoff Cox <geoff.cox@notquitecorrectfreeuk.com>
Subject: Re: numbers and strings and regex?
Message-Id: <7bfp915t5q9qaj996ub34jah51t7r0vbqa@4ax.com>
On 30 May 2005 20:51:43 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:
Anno,
Thanks for the code - I will try it out in a minute.
Brian suggested approach below which works fine but am not clear whta
the $exnum = 0+$1; does?
Geoff
if ($name =~ /\.*?\d{2}-(\d{2})\.jmx$/i) {
# print ("\$1 = $1 \n");
my $exnum = 0+$1;
------------------------------
Date: Tue, 31 May 2005 19:43:44 GMT
From: Geoff Cox <geoff.cox@notquitecorrectfreeuk.com>
Subject: Re: numbers and strings and regex?
Message-Id: <vffp9112g6jngnf3d24j40oj10k5benkec@4ax.com>
On Mon, 30 May 2005 18:30:42 +0100, Brian McCauley <nobull@mail.com>
wrote:
> if ($name =~ /\d{2}-(\d{2})\.jmx$/i) {
> my $exnum = 0+$1;
> }
Brian,
this work fine but I'm not clear what the
0+$1;
does?
Geoff
------------------------------
Date: Tue, 31 May 2005 22:05:52 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: numbers and strings and regex?
Message-Id: <d7ijjh$2fa$1@slavica.ukpost.com>
Geoff Cox wrote:
> On Mon, 30 May 2005 18:30:42 +0100, Brian McCauley <nobull@mail.com>
> wrote:
>
>> my $exnum = 0+$1;
>
> this work fine but I'm not clear what the
>
> 0+$1;
>
> does?
OK, let's break if down...
0 is the number zero.
+ is the numeric addition operator.
$1 is the captured string and since the capture was (\d{2}) it will be
string like '01' or '07' or '42' or something like that.
Adding zero to a number does not change it.
But Perl has automatic type coercion so adding zero to a string tells
Perl to coerce the string into a number.
Hense 0+'42' is the number 42 and 0+'07' is the number 7.
------------------------------
Date: Tue, 31 May 2005 19:55:29 -0500
From: moltar <klubbheads@Remove-ME-rogers.com>
Subject: Parsing Tracklisting - discussion
Message-Id: <Xns9667D50501A2486745413465432435464@216.196.97.142>
I am writing a subroutine to parse DJ mix tracklistings into artist, track name and additional
information. I think It could be even a great module if it all works out well. So far my solution is pretty
ugly, but that is why I decided to raise the discussion over here with hundreds of Perl Gurus.
A tracklist consist of several lines of artist and song names, sometimes additional information is
provided such as label, or "remix by", etc... Examples are at the end of message. I want to parse it into
separate instances ($artist, $track, $extra).
I had several ideas to tuckle this problem.
1) A set of if's to satisfy individual cases. Obvisoly one regex cannot cut it.
2) Array of regex'es going from most common to less common track listing patterns. Loop and
execute regex pattern per line.
3) more not so bright ideas that I won't mention.
So far my solution looks something like the following. It's still in works. It's clumsy and dirty. I am
looking for something more logical and elegant.
sub parse_tracklist_item {
my $line = shift;
if ($line =~ / [-:]+ /) {
# plug - tuff rinse - blue angel
# dj krush - meiso ( dj crystral's drug deal vocal mix) - mo' wax
return ($line, $1, $2, $3) if $line =~ /^(.+?) [-:]+ ([^(]+?) [-:]+ ([^\(]+)?/;
# Artist - Track (Extra)
# J-Cut - They Don’t Know (Advanced Dub)
return ($line, $1, $2, $3) if $line =~ /^(.+?) [-:]+ ([^(]+) [\(\[]\s*([^)]+)\s*[\)\]]( - .*)?/;
# Duo Infernele - Positive Vibes
# T Power - Delta
return ($line, $1, $2, $3) if $line =~ /^(.+?) [-:]+ (.+?)$/;
} elsif ($line =~ /-/) {
# Qwest feat. Jamal-Where My Thugs At? (A-Sides Remix)
# NRG-I Need Your Lovin (Remix)
return ($line, $1, $2, $3) if ($line =~ /^([^\-]+)\-([^\(]+)\s*\(?([^)]+)?\)?/);
}
# Get The Record Straight (Pieter K)
# Amen Bizness (Macc + Chris Inperspective)
# Are You Someone'S Prayer? (Fanu): Miracle Rmx.
return ($line, $1, $2, $3) if ($line =~ /^([^\(]+) \(([^)]+)\)(?:\:(.*))?/);
# stricken roots / fex
# the way (evil nine remix) / dylan rhymes + pearlshot accapella
if ($line =~ m|([^(]+)(:?\s*\(([^)]+)\)\s*)? / (.+)|) {
return ($line, $1, $3, $2);
}
return ($line, $line);
}
_____________________________________________________________________
Here are a few real examples of track listing variations that I found around the net. This is of course not
limited to what people can come up with.
Zinc - Star Of Polaris (Bingo Dub)
J-Cut - They Don’t Know (Advanced Dub)
* 01 - plug - tuff rinse - blue angel
* 02 - dj krush - meiso ( dj crystral's drug deal vocal mix) - mo' wax
Duo Infernele - Positive Vibes
T Power - Delta
Are You Someone'S Prayer? (Fanu): Miracle Rmx.
Amen Bizness (Macc + Chris Inperspective)
Get The Record Straight (Pieter K)
Omni Trio>>Rollin Heights>>Moving Shadow 044
ED Rush & Nico>>Bludclot>>No U Turn
DJ Hype>>Shot In The Dark>> Sub Base Records 020
intersperce - equanimity - looking good records (9m 43s)
makoto - voices - good looking records (4m 41s)
Qwest feat. Jamal-Where My Thugs At? (A-Sides Remix)
Kane and Dynamic Duo-Doc Stoppa
NRG-I Need Your Lovin (Remix)
N20 Jungle Tools 3.5-Crunch
Hive/Echo/Tejada-FearAndLoathing
Loxy/Keaton-JudgementDay
Cause4Concern-Volcam-Subtitles
Hexer-UndergroundResistance-KrushGrooves
08_Break - Submerged :: SUBTITLES039
09_Ryme Tyme & Trace - Move 2005 (Universal Project Remix) :: 1210008
ASC - Alternate Souce [Gamma Ray MP3 release]
Twister - Watercolour [Scientific MP3 release]
Future Prophecies - Voice of Loneliness
Ink and J-Dubb - War Machine
Charlie - The Prodigy - XL Recordings
Hold It Down - 2 Bad Mice - Moving Shadow
Technical Itch - Soldiers - Penetration - 29.00
Stakka & Gridlock - Hit n Run - Cargo - 32.10
Black Sun Empire :: B’Negative (Ill Skillz rmx) :: Ill Skillz
Blame :: Cyberun :: 720 Degrees
4hero : 9 by 9 (MIST vocal rmx)
MIST & Jenna G : Lover
High Contrast : Music is everything (Influx datum rmx)
D.Kay :: Platinum (Ill.Skillz RMX)
Jammin :: Kinda Funky (Shimon RMX)
------------------------------
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 8136
***************************************