Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2009
    Location
    Scotland
    Posts
    44
    Thanks
    2
    Thanked 1 Time in 1 Post

    Extracting info from files

    I have a log file viewer which has lines displaying UTC time as:
    time[000000000.000]

    I want to to pull this in from the file, using a search mechanism, and store the numerical value from the line. This will then allow me to use the variable holding the time to allow the user to convert the time format displayed when the click on the Convert Time button. What would be the quickest/easiest way to do this?

    Cheers
    Chris

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,953
    Thanks
    2
    Thanked 172 Times in 167 Posts
    Code:
    $_ = 'time[000000000.000]';
    
    my ($timestamp) = $_ =~ /time\[([\d.]+)\]/;
    print $timestamp;

  • #3
    New Coder
    Join Date
    Jul 2009
    Location
    Scotland
    Posts
    44
    Thanks
    2
    Thanked 1 Time in 1 Post
    thanks, seems to work ok

    Chris


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •