[30718] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1963 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 4 16:09:43 2008

Date: Tue, 4 Nov 2008 13:09:12 -0800 (PST)
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, 4 Nov 2008     Volume: 11 Number: 1963

Today's topics:
    Re: /^From:.*?([\w.-]+@[\w.-]+)/ <someone@example.com>
    Re: An odd sort requirement - data munging <veatchla@yahoo.com>
    Re: An odd sort requirement - data munging <cwilbur@chromatico.net>
    Re: An odd sort requirement - data munging <uri@stemsystems.com>
    Re: An odd sort requirement - data munging <cartercc@gmail.com>
    Re: An odd sort requirement - data munging <jurgenex@hotmail.com>
    Re: An odd sort requirement - data munging <glennj@ncf.ca>
    Re: An odd sort requirement - data munging <cartercc@gmail.com>
    Re: An odd sort requirement - data munging <uri@stemsystems.com>
    Re: An odd sort requirement - data munging <uri@stemsystems.com>
    Re: Perl Presentation <cartercc@gmail.com>
    Re: Perl Presentation <tadmc@seesig.invalid>
    Re: Perl Presentation <RedGrittyBrick@spamweary.invalid>
    Re: Perl Presentation <cwilbur@chromatico.net>
    Re: Perl Presentation <cartercc@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 04 Nov 2008 08:33:55 -0800
From: "John W. Krahn" <someone@example.com>
Subject: Re: /^From:.*?([\w.-]+@[\w.-]+)/
Message-Id: <RP_Pk.58039$sh3.13185@newsfe01.iad>

Uri Guttman wrote:
>>>>>> "A" == April  <xiaoxia2005a@yahoo.com> writes:
> 
>   A> ? seems a pretty interesting quatifier in re.  it relates to both
>   A> optional and non-greedy.
> 
> that is wrong thinking. one is a quantifier (0 or 1 of the previous
> thing). the other is a modifier (makes the previous quantifier
> non-greedy). don't assume any sort of relationship because of the use of
> ? for both of those roles.
> 
> <yes, i am back! :)

Welcome back.  ;-)

> verizon screwed over my usenet feed and i finally
> switched to a free text one>

Don't you just hate it when that happens.  :-(



John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


------------------------------

Date: Tue, 04 Nov 2008 08:46:00 -0600
From: l v <veatchla@yahoo.com>
Subject: Re: An odd sort requirement - data munging
Message-Id: <v4CdncQ91Yy1_Y3UnZ2dnUVZ_tzinZ2d@supernews.com>

cartercc wrote:
> I have a series of date related values, such as 01/2007, 02/2007,
> 03/2008, 04/2006, etc. These values represent a column in various
> files that range from several dozen rows deep to almost 1M rows deep.
> My job is to create reports from a collection of these types of files.
> 
> I create a number of refs to hashes that have the general appearance
> of this:
> $h{$k1}{$k2}{$k3} => data (generally but not always a simple count).
> 
> I write to an outfile generally like this:
> foreach $k1 (sort keys %h) {
>   foreach $k2 (sort keys %{$h{$k1}}) (
>     print OUTFILE " <k1>$k1</k1> <k2>$k2</k2> <val>$h{$k1}{$k2}</val>
> \n";
>   }
> }
> 
> When I run this, it works perfectly, sorting the date values into
> perfect numerical order. When something's so perfect, you know it's
> wrong!
> 
> Here's the problem: the ordering of the dates isn't numerical, the
> proper order is- 03/2005, 04/2005 ... 01/2006, 02/2006
> 03/2006, 04/2006 ... 01/2007, 02/2007
> 03/2007, 04/2007 ... 01/2008, 02/2008
> 
> Here's another view of the problem - when I print data for a year, the
> ordering is:
> 03/07, 04/07, 05/07 ... 01/07, 02/07
> 
> What I would like to do is overload the sort operator (call it
> 'sort_y') to sort in this non-numerical order. Can this be done? Can
> it be done perhaps in C and compiled to run in Perl? Can it be done
> algorithmetically by passing sort a function of some kind? I've tried
> this, and the logic is very clumsy and full of stupid relational
> operators and elsifs.
> 
> The former solution was to copy the data into Excel and manually cut
> and paste the columns in the correct order. Some of these reports are
> enormous (25 cols by 2500 rows) and I don't want to do this. This took
> a lot of time and was very much error prone.
> 
> Thanks, CC.

I'd switch how you store the date in hour hash and reformat for the 
report.  For example, if you store your date as yyyy/mm or yyyymm, your 
"sort keys" will do the job.  Then just reformat it back to mm/yyyy for 
your report.


-- 

Len


------------------------------

Date: Tue, 04 Nov 2008 11:26:19 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: An odd sort requirement - data munging
Message-Id: <864p2no3tg.fsf@mithril.chromatico.net>

>>>>> "cc" == cartercc  <cartercc@gmail.com> writes:

    cc> What I would like to do is overload the sort operator (call it
    cc> 'sort_y') to sort in this non-numerical order. Can this be done?

perldoc -f sort, and notice that sort takes an optional code block or
function name.  

Charlton


-- 
Charlton Wilbur
cwilbur@chromatico.net


------------------------------

Date: Tue, 04 Nov 2008 11:34:33 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: An odd sort requirement - data munging
Message-Id: <x7r65r1mcm.fsf@mail.sysarch.com>

>>>>> "c" == cartercc  <cartercc@gmail.com> writes:

  c> I have a series of date related values, such as 01/2007, 02/2007,
  c> 03/2008, 04/2006, etc. These values represent a column in various
  c> files that range from several dozen rows deep to almost 1M rows deep.
  c> My job is to create reports from a collection of these types of files.

  c> I create a number of refs to hashes that have the general appearance
  c> of this:
  c> $h{$k1}{$k2}{$k3} => data (generally but not always a simple count).

you don't need to build up such a hash tree to sort this data. it will
slow you down. you can sort directly on the fields but we don't know the
original record format (a single long string?).

  c> I write to an outfile generally like this:
  c> foreach $k1 (sort keys %h) {
  c>   foreach $k2 (sort keys %{$h{$k1}}) (

those are string comparisons (the default for sort).

  c> When I run this, it works perfectly, sorting the date values into
  c> perfect numerical order. When something's so perfect, you know it's
  c> wrong!

you say numerical order (but use string compares as i said above)

  c> Here's the problem: the ordering of the dates isn't numerical, the
  c> proper order is- 03/2005, 04/2005 ... 01/2006, 02/2006
  c> 03/2006, 04/2006 ... 01/2007, 02/2007
  c> 03/2007, 04/2007 ... 01/2008, 02/2008


  c> Here's another view of the problem - when I print data for a year, the
  c> ordering is:
  c> 03/07, 04/07, 05/07 ... 01/07, 02/07

can you show the code for this sort?

  c> The former solution was to copy the data into Excel and manually cut
  c> and paste the columns in the correct order. Some of these reports are
  c> enormous (25 cols by 2500 rows) and I don't want to do this. This took
  c> a lot of time and was very much error prone.

25 cols x 2500 rows is not enormous for perl.

try using Sort::Maker for this. you just define how you want each key
extracted (using a regex or substr or any code) from your record and how
to sort it (numeric/string, up/down). in your case i would say use a
string sort since you have padded numbers. then make sure you sort the
keys in the order you want - year first, and then month. you will get a
clean and fast sort without all of your extra code and not needing to
use external programs.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Tue, 4 Nov 2008 09:16:19 -0800 (PST)
From: cartercc <cartercc@gmail.com>
Subject: Re: An odd sort requirement - data munging
Message-Id: <22445d2b-1b27-4739-90c3-b849210a9b8f@q26g2000prq.googlegroups.com>

Thanks, Uri,

On Nov 4, 11:34=A0am, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "c" =3D=3D cartercc =A0<carte...@gmail.com> writes:
>
> =A0 c> I have a series of date related values, such as 01/2007, 02/2007,
> =A0 c> 03/2008, 04/2006, etc. These values represent a column in various
> =A0 c> files that range from several dozen rows deep to almost 1M rows de=
ep.
> =A0 c> My job is to create reports from a collection of these types of fi=
les.
>
> =A0 c> I create a number of refs to hashes that have the general appearan=
ce
> =A0 c> of this:
> =A0 c> $h{$k1}{$k2}{$k3} =3D> data (generally but not always a simple cou=
nt).
>
> you don't need to build up such a hash tree to sort this data. it will
> slow you down. you can sort directly on the fields but we don't know the
> original record format (a single long string?).

Actually, this is a general solution to a number of different
problems. The keys could represent a number of different types, such
as states, cities, course names (e.g., ART 109, BIO 225, MAT 4556),
people names, and so on. The common factor is that every type of field
is both unique and sortable, so I can use the same data structure
regardless of the type of data.

With particular reference to this sort problem, it's the only one type
that can't be sorted normally, which is the out-of-order date types.

> =A0 c> I write to an outfile generally like this:
> =A0 c> foreach $k1 (sort keys %h) {
> =A0 c> =A0 foreach $k2 (sort keys %{$h{$k1}}) (
>
> those are string comparisons (the default for sort).

You are right. Actually, isn't it an ASCII sort? When I sort character
values, case makes a difference.

> =A0 c> When I run this, it works perfectly, sorting the date values into
> =A0 c> perfect numerical order. When something's so perfect, you know it'=
s
> =A0 c> wrong!
>
> you say numerical order (but use string compares as i said above)

True -- excuse my casualness.

> =A0 c> Here's the problem: the ordering of the dates isn't numerical, the
> =A0 c> proper order is- 03/2005, 04/2005 ... 01/2006, 02/2006
> =A0 c> 03/2006, 04/2006 ... 01/2007, 02/2007
> =A0 c> 03/2007, 04/2007 ... 01/2008, 02/2008
>
> =A0 c> Here's another view of the problem - when I print data for a year,=
 the
> =A0 c> ordering is:
> =A0 c> 03/07, 04/07, 05/07 ... 01/07, 02/07
>
> can you show the code for this sort?

There is no code other than that shown above. I have the data in a
hash of hash refs. What I meant was -- the INSTITUTIONAL ordering is
different than the NUMERIC ordering. What it prints is, "1 2 3 4 5".
What I want it to print is "3 4 5 1 2". And, I want it to print this
only for this kind of string, not for other strings that might contain
numeric characters, such as zip codes, area codes, ID numbers, etc.

> =A0 c> The former solution was to copy the data into Excel and manually c=
ut
> =A0 c> and paste the columns in the correct order. Some of these reports =
are
> =A0 c> enormous (25 cols by 2500 rows) and I don't want to do this. This =
took
> =A0 c> a lot of time and was very much error prone.
>
> 25 cols x 2500 rows is not enormous for perl.

Right. However, it is for manual processing. This is why I want a
scripted solution. My scripted solution is about 95% complete, and if
I could solve this problem it would be close to 100%.

> try using Sort::Maker for this. you just define how you want each key
> extracted (using a regex or substr or any code) from your record and how
> to sort it (numeric/string, up/down). in your case i would say use a
> string sort since you have padded numbers. then make sure you sort the
> keys in the order you want - year first, and then month. you will get a
> clean and fast sort without all of your extra code and not needing to
> use external programs.

Thanks, I'll look at this.

And in replying to your message, an idea occurred to me.

The central component in all these strings is the slash: /. If I write
a function that takes a key as the parameter such as "2006/03" and
returns a string such as "2006/1/03", then I could control exactly how
the sort would work. When I was finished with the report, I could run
it through another function that would substitute "/1/" with just "/"
and that would solve the problem.

Thanks, CC.


------------------------------

Date: Tue, 04 Nov 2008 09:23:41 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: An odd sort requirement - data munging
Message-Id: <7tv0h4tv1mmg195cfjtqciltshs7bajdqs@4ax.com>

cartercc <cartercc@gmail.com> wrote:
>I have a series of date related values, such as 01/2007, 02/2007,
>03/2008, 04/2006, etc. These values represent a column in various
>files that range from several dozen rows deep to almost 1M rows deep.
>My job is to create reports from a collection of these types of files.
>
>I create a number of refs to hashes that have the general appearance
>of this:
>$h{$k1}{$k2}{$k3} => data (generally but not always a simple count).

After scratching my head for some time I am guessing that probably $k1
contains the month and $k2 contains the year.
If you had provided a minimal, self-contained script as requested in the
posting guidelines it would have been much easier to identify your data
structure.

>I write to an outfile generally like this:
>foreach $k1 (sort keys %h) {
>  foreach $k2 (sort keys %{$h{$k1}}) (
>    print OUTFILE " <k1>$k1</k1> <k2>$k2</k2> <val>$h{$k1}{$k2}</val>
>\n";
>  }
>}
>Here's the problem: the ordering of the dates isn't numerical, the
>proper order is- 03/2005, 04/2005 ... 01/2006, 02/2006
>03/2006, 04/2006 ... 01/2007, 02/2007
>03/2007, 04/2007 ... 01/2008, 02/2008

Well, that is what you are asking for. Assuming $k1 and $k2 are month
and year respectively then you are sorting your data by month and within
each month by year.
You could just reverse those two, sorting by year first and then within
each year by month.

Another solution would be to write a custom compare function. You will
have to pass the pair of year and month for each of $a and $b as those
are actually the number you want to sort. And then once you get that
sorted list just loop through it and print the corresponding values from
the data set.
I'd be interested in coding it but I'm not good enough to do it without
any testing and since you didn't provide any self-contained program that
could be used a test bed that's not an option. 

Yet another solution would be to change your data structure. Your HoHoA
has the granularity of the time spans reversed. Had you put year as the
top value, then your algorithm above would have worked naturally. 

>What I would like to do is overload the sort operator (call it
>'sort_y') to sort in this non-numerical order. Can this be done? 

Why would you want to do that? Why don't you simply write your own
custom compare function and use that instead of the default <=>?

>Can
>it be done perhaps in C and compiled to run in Perl? Can it be done
>algorithmetically by passing sort a function of some kind? 

Dah, did you even read the man page for sort()? That's what the first
argument of sort() is all about!

jue


------------------------------

Date: 4 Nov 2008 17:34:50 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: An odd sort requirement - data munging
Message-Id: <slrngh11tr.dl.glennj@smeagol.ncf.ca>

At 2008-11-04 09:07AM, "cartercc" wrote:
>  Here's the problem: the ordering of the dates isn't numerical, the
>  proper order is- 03/2005, 04/2005 ... 01/2006, 02/2006
>  03/2006, 04/2006 ... 01/2007, 02/2007
>  03/2007, 04/2007 ... 01/2008, 02/2008

An example of the Schwartzian Transform (look it up in wikipedia):

    my @dates = qw( 
        03/2005 04/2005 01/2006 02/2006 03/2006 04/2006
        01/2007 02/2007 03/2007 04/2007 01/2008 02/2008);
    # or @dates = keys %somehash

    my @sorted =
        map  { $_->[0] }
        sort { $a->[1] <=> $b->[1] }
        map  { [$_, substr($_,3,4) . substr($_,0,2)] } @dates;

-- 
Glenn Jackman
    Write a wise saying and your name will live forever. -- Anonymous


------------------------------

Date: Tue, 4 Nov 2008 10:31:45 -0800 (PST)
From: cartercc <cartercc@gmail.com>
Subject: Re: An odd sort requirement - data munging
Message-Id: <f48b5980-12ce-4987-b703-ae0aec5fae09@1g2000prd.googlegroups.com>

On Nov 4, 12:23=A0pm, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> cartercc <carte...@gmail.com> wrote:
> >I have a series of date related values, such as 01/2007, 02/2007,
> >03/2008, 04/2006, etc. These values represent a column in various
> >files that range from several dozen rows deep to almost 1M rows deep.
> >My job is to create reports from a collection of these types of files.
>
> >I create a number of refs to hashes that have the general appearance
> >of this:
> >$h{$k1}{$k2}{$k3} =3D> data (generally but not always a simple count).
>
> After scratching my head for some time I am guessing that probably $k1
> contains the month and $k2 contains the year.
> If you had provided a minimal, self-contained script as requested in the
> posting guidelines it would have been much easier to identify your data
> structure.

No. $k1, etc., contains ANYTHING that's sortable and unique. It can
contain names, like "Exner, J", "New York," or "Baltimore" or numbers
(telephone, area code, ID numbers) or other values. The contents of
the keys are not relevant to the code or to the question.

> >Here's the problem: the ordering of the dates isn't numerical, the
> >proper order is- 03/2005, 04/2005 ... 01/2006, 02/2006
> >03/2006, 04/2006 ... 01/2007, 02/2007
> >03/2007, 04/2007 ... 01/2008, 02/2008
>
> Well, that is what you are asking for. Assuming $k1 and $k2 are month
> and year respectively then you are sorting your data by month and within
> each month by year.
> You could just reverse those two, sorting by year first and then within
> each year by month.

Actually, no. Here is a sample of a data file:
"07/T1","A27","117"
"07/T1","D01","3"
"07/T1","EA27","30"
"07/T1","EF20","52"
 ...
"08/T5","V26","17"
"08/T5","W03","11"
"08/T5","W04","4"
"08/T5","W05","1"

Hee is a sample of another data file:
1222413	G07	07/T2	07/RFA 07/T2
1247990	FH1	08/T4	08/RSP 08/T4
1094529	EARMY	05/T4	05/T4 05/T5 07/T1 07/RFA 07/T2
1247991	V24	08/T4	08/RSP 08/T4

As you can see, the 'date' values are unary values and I don't have
any real need to split them.

> Another solution would be to write a custom compare function. You will
> have to pass the pair of year and month for each of $a and $b as those
> are actually the number you want to sort. And then once you get that
> sorted list just loop through it and print the corresponding values from
> the data set.
> I'd be interested in coding it but I'm not good enough to do it without
> any testing and since you didn't provide any self-contained program that
> could be used a test bed that's not an option.

I just posted a half-assed idea of a solution that would require
processing the file two more times to convert and unconvert this field
to something that would sort naturally. I would like to see a custom
compare function, and if you want, I can send you sample data files
(they contain no confidential or sensitive information) and a script
that I use to product an OUTFILE. I've spend a non-trivial amount of
time thinking about it, and I can't see a solution.

> Yet another solution would be to change your data structure. Your HoHoA
> has the granularity of the time spans reversed. Had you put year as the
> top value, then your algorithm above would have worked naturally.

No, because of this:
Calendar year -
07/01, 07/02, 07/03, ...
Reporting year -
07/03, 07/04, ... 07/01, 07/02
Academic year -
07/01, 07/02 ... 08/04, 08/05

Please note that the Academic year crosses year boundries, i.e., from
2007 to 2008, while the Reporting year crosses month boundries, i.e.,
'03' starts the series and '01','02' ends the series.


> Dah, did you even read the man page for sort()? That's what the first
> argument of sort() is all about!

Actually, no, I didn't. I know that sort can take a function as an
argument, but I was focused on the algorithm, not the implementation.
But I'm headed that way now.

CC


------------------------------

Date: Tue, 04 Nov 2008 14:30:30 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: An odd sort requirement - data munging
Message-Id: <x74p2nwap5.fsf@mail.sysarch.com>

>>>>> "c" == cartercc  <cartercc@gmail.com> writes:

  >> you don't need to build up such a hash tree to sort this data. it will
  >> slow you down. you can sort directly on the fields but we don't know the
  >> original record format (a single long string?).

  c> Actually, this is a general solution to a number of different
  c> problems. The keys could represent a number of different types, such
  c> as states, cities, course names (e.g., ART 109, BIO 225, MAT 4556),
  c> people names, and so on. The common factor is that every type of field
  c> is both unique and sortable, so I can use the same data structure
  c> regardless of the type of data.

but then you still have issues with key processing (getting the order
you want) and sort key ordering. this is why my module can help.

  >> those are string comparisons (the default for sort).

  c> You are right. Actually, isn't it an ASCII sort? When I sort character
  c> values, case makes a difference.

yes, sort use asciibetical sorting. you can fold case by extracting
string keys and upper/lower casing them all.

  >> can you show the code for this sort?

  c> There is no code other than that shown above. I have the data in a
  c> hash of hash refs. What I meant was -- the INSTITUTIONAL ordering is
  c> different than the NUMERIC ordering. What it prints is, "1 2 3 4 5".
  c> What I want it to print is "3 4 5 1 2". And, I want it to print this
  c> only for this kind of string, not for other strings that might contain
  c> numeric characters, such as zip codes, area codes, ID numbers, etc.

oh, i didn't get you wanted an internal wacky ordering. the easiest
thing to do is to extract your keys and map them through a hash which
converts them to an order value that you want. something like this
(highly untested):

# based on the order you show above.

my %sort_ordering = (
	1	=> 3,
	2	=> 4,
 ...

) ;

and a basic sort would be like this:

	@sorted = sort { $sort_ordering{$a} cmp $sort_ordering{$b} } @input ;

switch cmp for <=> as desired.

  >> try using Sort::Maker for this. you just define how you want each key
  >> extracted (using a regex or substr or any code) from your record and how
  >> to sort it (numeric/string, up/down). in your case i would say use a
  >> string sort since you have padded numbers. then make sure you sort the
  >> keys in the order you want - year first, and then month. you will get a
  >> clean and fast sort without all of your extra code and not needing to
  >> use external programs.

  c> Thanks, I'll look at this.

sort::maker will simplify key extraction and custom ordering. you would
build a ordering hash as above but put that conversion in the key
extract code. something like this:

	my $sorter = make_sorter( 'GRT',
		string => '$sort_ordering{get_the_key($_)}'
	) ;

get_the_key is either direct code or a call to (ahem!) get the key from
$_.

  c> The central component in all these strings is the slash: /. If I write
  c> a function that takes a key as the parameter such as "2006/03" and
  c> returns a string such as "2006/1/03", then I could control exactly how
  c> the sort would work. When I was finished with the report, I could run
  c> it through another function that would substitute "/1/" with just "/"
  c> and that would solve the problem.

that is the conversion hash i spoke of. it can be a sub too if the
conversion needs more work or such. actually with sort::maker you would
sort on multiple keys each having its own sort ordering hash as
needed. then you don't need an extraction sub which is slower.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Tue, 04 Nov 2008 14:34:42 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: An odd sort requirement - data munging
Message-Id: <x7zlkfuvxp.fsf@mail.sysarch.com>

>>>>> "GJ" == Glenn Jackman <glennj@ncf.ca> writes:

  GJ> At 2008-11-04 09:07AM, "cartercc" wrote:
  >> Here's the problem: the ordering of the dates isn't numerical, the
  >> proper order is- 03/2005, 04/2005 ... 01/2006, 02/2006
  >> 03/2006, 04/2006 ... 01/2007, 02/2007
  >> 03/2007, 04/2007 ... 01/2008, 02/2008

  GJ> An example of the Schwartzian Transform (look it up in wikipedia):

  GJ>     my @dates = qw( 
  GJ>         03/2005 04/2005 01/2006 02/2006 03/2006 04/2006
  GJ>         01/2007 02/2007 03/2007 04/2007 01/2008 02/2008);
  GJ>     # or @dates = keys %somehash

  GJ>     my @sorted =
  GJ>         map  { $_->[0] }
  GJ>         sort { $a->[1] <=> $b->[1] }
  GJ>         map  { [$_, substr($_,3,4) . substr($_,0,2)] } @dates;


and sort::maker can generate an ST and spit out the code for you or you
can use the code ref it creates. it also removes redundancy (duplicate
key code and hides all the sort/map/sort syntax. and it can generate GRT
sorts which are much faster than the ST.

another trick is to pregenerate sorters for various key sets and print
them out off line. then paste in those sorters (name the subs) and call
the desired one based on the data set being sorted. then you don't need
to hand code all the sort variants of key sets.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Tue, 4 Nov 2008 07:56:00 -0800 (PST)
From: cartercc <cartercc@gmail.com>
Subject: Re: Perl Presentation
Message-Id: <98177cb6-5d95-46fa-bd74-af18c14c67b1@l33g2000pri.googlegroups.com>

On Nov 4, 6:59=A0am, Ali Shirvani <aj.shirv...@gmail.com> wrote:
> Hi all,
> I'm a student of computer engineering, and I want to have a talk on
> Perl for *Programming Languages Course*. Is there any resource that
> specified the concepts of programming language theory that Perl based
> on them?
>
> Thanks,
> --
> Shirvani Ali

Shirvani --

There is an absolute wealth on Perl online. I don't really think that
your objective is achievable, but don't take this in a negative sense.
I am a database manager for a large public university, and I use Perl
on a daily basis to produce reports that can't be touched by any
database. I also have an advanced degree in SW and will finish my PhD
in SW next year (I hope) and can tell you from experience that Perl
and academics do not mix.

If you have a paper or presentation for a course, that's probably
about a ten page paper or a 15 minute presentation, which is very
limited to discuss any topic, much less a topic as big as Perl. I
would NOT focus on the technical or the computer science aspects of
Perl. Instead, I would focus on the practical aspects. After all, PERL
stands for PRACTICAL Extraction and Reporting Language.

Look at CPAN. Pick half a dozen different topics. You might consider
database, XML, networking, interface with Microsoft applications, CGI,
bioinformatics, text processing, etc. Talk about how Perl lends itself
to very different types of problems, and talk about the vast number of
modules that have been developed to solve these problems with Perl.
Use the source code for one to illustrate what you mean.

For filler, you can talk briefly about the history of Perl, or you can
talk about the variety of open employment positions that mention Perl
(search dice.com).

CC


------------------------------

Date: Tue, 4 Nov 2008 07:56:48 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Perl Presentation
Message-Id: <slrngh0l50.gh7.tadmc@tadmc30.sbcglobal.net>

Ali Shirvani <aj.shirvani@gmail.com> wrote:

> I'm a student of computer engineering, and I want to have a talk on
> Perl for *Programming Languages Course*. Is there any resource that
> specified the concepts of programming language theory that Perl based
> on them?


What is unique about Perl are its concepts of *natural* language theory:

    http://www.wall.org/~larry/natural.html


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Tue, 04 Nov 2008 16:16:27 +0000
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: Perl Presentation
Message-Id: <4910755d$0$10548$db0fefd9@news.zen.co.uk>


Ali Shirvani wrote:
> Hi all,
> I'm a student of computer engineering, and I want to have a talk on
> Perl for *Programming Languages Course*. Is there any resource that
> specified the concepts of programming language theory that Perl based
> on them?

I'd read the presentations that Larry Wall gave on the "State of the 
Onion". See "Culture" in http://www.wall.org/~larry/perl.html

Actually this is good advice regardless of the question. It is always 
pleasant to be entertained whilst being educated.

-- 
RGB


------------------------------

Date: Tue, 04 Nov 2008 11:24:05 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Perl Presentation
Message-Id: <868wrzo3x6.fsf@mithril.chromatico.net>

>>>>> "cc" == cartercc  <cartercc@gmail.com> writes:

    cc> I also have an advanced degree in SW and will finish my PhD in
    cc> SW next year (I hope) and can tell you from experience that Perl
    cc> and academics do not mix.

I expect the numerous academics who actually use Perl (Damian Conway,
for one) and the people who use Perl to get work done (such as the
people in linguistics and bioinformatics) would disagree with you.

Charlton


-- 
Charlton Wilbur
cwilbur@chromatico.net


------------------------------

Date: Tue, 4 Nov 2008 09:24:09 -0800 (PST)
From: cartercc <cartercc@gmail.com>
Subject: Re: Perl Presentation
Message-Id: <e6b677d6-eb4d-4a54-8708-3a080455d986@e1g2000pra.googlegroups.com>

On Nov 4, 11:24=A0am, Charlton Wilbur <cwil...@chromatico.net> wrote:

> I expect the numerous academics who actually use Perl (Damian Conway,
> for one) and the people who use Perl to get work done (such as the
> people in linguistics and bioinformatics) would disagree with you.

They undoubtedly would. The ones that focus on research tend to look
down on Perl as a 'practical' language and as such not suited serious
research. It's pretty much expected that code for graduate level
projects will be written in C, and for defense related spending (and
we have a good amount of defense dollars here) Ada.

I remember an algorithms class where I turned in an assignment in
Perl, and was told that I wouldn't get credit for it unless I wrote it
in another language, even though it worked perfectly and the CPU time
was within the range of solutions written in those other languages.

I'm not being ugly or critical or judgmental. I'm just describing my
experience.

CC


------------------------------

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 V11 Issue 1963
***************************************


home help back first fref pref prev next nref lref last post