Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Helping Beginners (continued)

by japhy (Canon)
on Oct 30, 2001 at 07:54 UTC ( [id://122028]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    @data = (
      'buy 1/23/01 100 12.625 50 25.25',
    ...
      'buy 10/23/01 100 12.625 50 25.25',
      'buy 10/25/01 100 12.625 50 25.25',
    );
    
  2. or download this
    sub get_date {
      my $string = shift;
      my $date = (split ' ', $string)[1];  # second field
      return $date;
    
  3. or download this
    for $line (@data) {
      push @dates, get_date($line);
    }
    
  4. or download this
    for $line (@data) {
      push @dates, [ get_date($line), $line ];
    }
    
  5. or download this
    sub get_date {
      my $string = shift;
    ...
      my ($d, $m, $y) = split '/', $date;
      return sprintf "%02d%02d%02d", $y, $m, $d;
    }
    
  6. or download this
    @dates = sort { $a->[0] <=> $b->[0] } @dates;
    
  7. or download this
    @data = map $_->[1], @dates;
    
  8. or download this
    @data =
      restore(
        sort { $a->[0] <=> $b->[0] }
          extract(@data)
      );
    
  9. or download this
    # extract(@data)
    # becomes
    map [ get_date($_), $_ ], @data
    
  10. or download this
    # restore(...)
    # becomes
    map $_->[1], ...
    
  11. or download this
    @data =
      map $_->[1],
      sort { $a->[0] <=> $b->[0] }
      map [ get_date($_), $_ ],
      @data;
    
  12. or download this
    @data =
      map  { restore($_) }
      sort { ... }
      map  { extract($_) }
      @data;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://122028]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-19 14:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found