Hi,
I have to search for a string in a variable.
Say the variable is var1='ERROR: Make java] as enabled'
here i want to match which are in red color. other like abc etc could change.
Can you tell me the exact command something like the below in perl
if ($var1=~ m/ERROR: Make... (3 Replies)
Let's say I'm trying to match potentially multiple sets of parentheses. Is there a way in a regular expression to force a match of closing parentheses specifically in the number of the opening parentheses?
For example, if the string is "((foo bar))", I want to be able to say "match any number of... (7 Replies)
I have a few .tex files generated with html2latex. They have some extra \\ that generate error with pdflatex, so I would like to get rid of them.
This
perl -p -i -e s/\\\\//g myfile.tex
with or without simple or double quote remove all of the backslashes, also the single ones needed by tex.
How... (2 Replies)
I'm working on a basic log parser in perl. Input file looks like:
len: 120713
foo
bar
file size of: testdir1/testdir1/testdir1/testdir1/testfile0 is 120713Of course there are tens of thousands of lines... I'm trying to compare the len and filesize values.
#!/usr/bin/perl
use strict;
use... (2 Replies)
Hi Guys,
In the following line:
cn=portal.090710.191533.428571000,cn=groups,dc=mp,dc=rj,dc=gov,dc=br
I need to extract this string: portal.090710.191533.428571000
As you can see this string always will be bettween "cn=" and "," strings.
Someone know one regular expression to... (4 Replies)
I need a way to extract data from
X 4T Solution 21 OCT 2011 37 .00
to account 12345678 User1 user2
X 4T Solution Solution Unlimited 11 Sep 2009 248 .00
to account 87654321 user3 user4
I need it to extract 'X' '37.00' and account number 12345678.
I have extracted above stuff... (3 Replies)
I have two variables,
my $filename = "abc_yyyy_mm_dd.txt";
my $filename1 = " abc_2011_11_07.txt";
I need to perform some operations after checking if $filename has $filename1 in it
i have used the below code,
if($filename =~ /^$filename1/)
{
----
--
} (2 Replies)
i have a script in which i need to skip comments, and i am able to achieve it partially...
IN text file:
{****************************
{test : test...test }
Script:
while (<$fh>)
{
push ( @data, $_);
}
if ( $data =~ m/(^{\*+$)/ ){
}
With the above match i am... (5 Replies)
The sample file:
dept1: user1,user2,user3
dept2: user4,user5,user6
dept3: user7,user8,user9
I want to match by '/^dept2.*/' but don't want to have substring 'dept2:' in output. How to compose such regex? (8 Replies)
Hi,
I need some guidance with understanding this Perl script below. I am not the author of the script and the author has not leave any documentation. I supposed it is meant to be 'easy' if you're a Perl or regex guru. I am having problem understanding what regex to use :confused: The script does... (3 Replies)
Discussion started by: newbie_01
3 Replies
LEARN ABOUT DEBIAN
dpkg::log
DPKG::Log(3pm) User Contributed Perl Documentation DPKG::Log(3pm)NAME
DPKG::Log - Parse the dpkg log
VERSION
version 1.20
SYNOPSIS
use DPKG::Log;
my $dpkg_log = DPKG::Log->new('filename' => 'dpkg.log', 'parse' => 1);
DESCRIPTION
This module is used to parse a logfile and store each line as a DPKG::Log::Entry object.
METHODS
$dpkg_log = DPKG::Log->new()
$dpkg_log = DPKG::Log->new('filename' => 'dpkg.log')
$dpkg_log = DPKG::Log->new('filename' => 'dpkg.log', 'parse' => 1 )
Returns a new DPKG::Log object. If parse is set to a true value the logfile specified by filename is parsed at the end of the object
initialisation. Otherwise the parse routine has to be called. Filename parameter can be omitted, it defaults to /var/log/dpkg.log.
Optionally its possible to specify from or to arguments as timestamps in the standard dpkg.log format or as DateTime objects. This
will limit the entries which will be stored in the object to entries in the given timerange. Note that, if this is not what you want,
you may ommit these attributes and can use filter_by_time() instead.
By default the module will assume that those timestamps are in the local timezone as determined by DateTime::TimeZone. This can be
overridden by giving the argument time_zone which takes a timezone string (e.g. 'Europe/Berlin') or a DateTime::TimeZone object.
Additionally its possible to override the timestamp_pattern by specifying timestamp_format. This has to be a valid pattern for
DateTime::Format::Strptime.
$dpkg_log->filename
$dpkg_log->filename('newfilename.log')
Get or set the filename of the dpkg logfile.
$dpkg_log->parse
$dpkg_log->parse('time_zone' => 'Europe/Berlin')
$dpkg_log->parse('time_zone' => $dt_tz )
Call the parser.
The time_zone parameter is optional and specifies in which time zone the dpkg log timestamps are. If its omitted it will use the
default local time zone. Its possible to specify either a DateTime::TimeZone object or a string.
@entries = $dpkg_log->entries;
@entries = $dpkg_log->entries('from' => '2010-01-01.10:00:00', to => '2010-01-02 24:00:00')
Return all entries or all entries in a given timerange.
from and to are optional arguments, specifying a date before (from) and after (to) which entries aren't returned. If only to is
specified all entries from the beginning of the log are read. If only from is specified all entries till the end of the log are read.
$entry = $dpkg_log->next_entry;
Return the next entry.
@entries = $dpkg_log->filter_by_time(from => ts, to => ts)
@entries = $dpkg_log->filter_by_time(from => ts)
@entries = $dpkg_log->filter_by_time(to => ts)
@entries = $dpkg_log->filter_by_time(from => ts, to => ts, entry_ref => $entry_ref)
Filter entries by given from - to range. See the explanations for the new sub for the arguments.
If entry_ref is given and an array reference its used instead of $self->{entries} as input source for the entries which are to be
filtered.
($from, $to) = $dpkg_log->get_datetime_info()
Returns the from and to timestamps of the logfile or (if from/to values are set) the values set during object initialisation.
SEE ALSO
DPKG::Log::Entry, DateTime, DateTime::TimeZone
AUTHOR
Patrick Schoenfeld <schoenfeld@debian.org>.
COPYRIGHT AND LICENSE
Copyright (C) 2011 Patrick Schoenfeld <schoenfeld@debian.org>
This library is free software. You can redistribute it and/or modify it under the same terms as perl itself.
perl v5.10.1 2011-02-26 DPKG::Log(3pm)