Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re:How to check last used date.

by davido (Cardinal)
on Mar 12, 2021 at 19:31 UTC ( [id://11129528]=note: print w/replies, xml ) Need Help??


in reply to How to check last used date.

I think you're asking a little bit the wrong question. Why do you need a module that deals specifically with login date? That's specific enough that you won't find what you're looking for. You have two problems and they're not satisfied by a single module:

  • You need to extract data from a log
  • You need to find the max date (possibly per user)
So the module you really need is one that can compare dates and tell you the most recent. This has nothing to do specifically with login. You just need to parse your input data for dates, and then use a module to compare them.

Your data looks like it is in column format. In other words, the login date is in a predictable column: Column 36 (offset +35). And your userid is in a predictable column: Column 1 (offset 0) So use substr or unpack to capture the user and the date. Skip lines that don't match (that have NOT REGISTERED in them). Then use a module such as DateTime to compare the dates, finding the most recent. Let us know what part of that you actually have trouble with so that we can help.


Dave

Replies are listed 'Best First'.
Re^2: How to check last used date.
by choroba (Cardinal) on Mar 12, 2021 at 20:04 UTC
    In fact, in this date format, dates can be compared as plain strings, no date parsing is needed.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re^2: How to check last used date.
by chandantul (Scribe) on Mar 13, 2021 at 05:41 UTC

    Thanks for the suggestions. I have the data structure that needs 2 dimentional Hash of arrays. I will need to find out the Specific ID and their respective Netowrk IDs and which was not used and the used one Network ID to be checked with Last used among the usages. Please check my latest data structure . How i can create a 2 dimentional Hash of arrays and extract the unique data? Can you please consider @array1 as the Key @array 3 is the 2nd and @arra3 is the respective values? Please check ID 500000008

    @array1 @array3 @array2 @arra3 900000001 900000001 Network1 Login 900000002 900000002 Network1 2019-11-07T20:31:10.000Z 900000002 900000002 Network1 2021-02-19T13:47:25.000Z 900000002 900000002 Network1 2021-03-10T13:58:50.000Z 900000003 NOT Registered No Network1 NOT Registered 900000004 900000004 Network1 Login 900000005 900000005 Network1 Login 900000006 900000006 Network1 Login2 900000007 900000007 Network1 2021-03-10T17:11:24.000Z 900000007 900000007 Network1 2021-02-18T08:34:58.000Z 900000007 900000007 Network1 2021-01-25T17:19:44.000Z 500000008 500000008 Network1 2021-03-10T17:11:24.000Z 500000008 500000008 Network2 Not Used 500000008 500000008 Network1 2021-03-11T17:12:42.000Z 500000008 500000008 Network3 Not Used 400000008 400000008 Network1 2021-01-25T17:19:36.000Z

      So now you have three problems that you seem to be asking about:

      • How to sort by date, or find the maximum date.
      • How to extract the user ID and date from tabular data.
      • How to insert data into a datastructure

      Which part of the problem are you able to solve yourself, so that we can help with the parts you can't solve? Show us the minimal amount of code you can write to get started on this. Sample input, sample output, code that compiles, etc.


      Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-03-29 14:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found