I'm working on a basic log parser in perl. Input file looks like:
Of course there are tens of thousands of lines... I'm trying to compare the len and filesize values.
$size =~ s/\d+$// does exactly the opposite of what I want. I tried using !~ but that didn't return anything.
Tips?
Many thanks.
---------- Post updated at 05:23 PM ---------- Previous update was at 04:51 PM ----------
Found a working solution. It seems strange to have to use the if statements given that I know that the result is there.
Is there a way to simply directly assign it without the If statement?
Hi,
Can anyone help me to find regular expression for the following in Perl?
"The string can only contain lower case letters (a-z) and no more than one of any letter."
For example: "table" is accepted, whether "dude" is not.
I have coded like this:
$str = "table";
if ($str =~ m/\b()\b/) {... (4 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)
My input contains a single word lines.
From each line
data.txt
prjtestBlaBlatestBlaBla
prjthisBlaBlathisBlaBla
prjthatBlaBladpthatBlaBla
prjgoodBlaBladpgoodBlaBla
prjgood1BlaBla123dpgood1BlaBla123
Desired output -->
data_out.txt
prjtestBlaBla
prjthisBlaBla... (8 Replies)
I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly:
if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Hi,
I've a logfile which i need to parse and get the logs depending upon the user input. here, i'm providing an option to enter the string which can be matched with the log entries.
e.g. one of the logfile entry reads like this -
$str = " mpgw(BLUESOAPFramework):... (6 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)
HI,
I'm new to perl and need simple regex for reading a file using my perl script.
The text file reads as -
filename=/pot/uio/current/myremificates.txt
certificates=/pot/uio/current/userdir/conf/user/gamma/settings/security/... (3 Replies)
Hello folks,
Looking for a quick help on regex in my perl script.
here's the string i want to parse and get the 2nd field out of it.
$str = " 2013-08-07 12:29 Beta ACTIVE";
I want to extract 'Beta' out of this string. This string will keep on changing... (2 Replies)
I am not a big expert in regex and have just little understanding of that language.
Could you help me to understand the regular Perl expression:
^(?!if\b|else\b|while\b|)(?:+?\s+){1,6}(+\s*)\(*\) *?(?:^*;?+){0,10}\{
------
This is regex to select functions from a C/C++ source and defined in... (2 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 MOJAVE
text::glob
Text::Glob(3) User Contributed Perl Documentation Text::Glob(3)NAME
Text::Glob - match globbing patterns against text
SYNOPSIS
use Text::Glob qw( match_glob glob_to_regex );
print "matched
" if match_glob( "foo.*", "foo.bar" );
# prints foo.bar and foo.baz
my $regex = glob_to_regex( "foo.*" );
for ( qw( foo.bar foo.baz foo bar ) ) {
print "matched: $_
" if /$regex/;
}
DESCRIPTION
Text::Glob implements glob(3) style matching that can be used to match against text, rather than fetching names from a filesystem. If you
want to do full file globbing use the File::Glob module instead.
Routines
match_glob( $glob, @things_to_test )
Returns the list of things which match the glob from the source list.
glob_to_regex( $glob )
Returns a compiled regex which is the equivalent of the globbing pattern.
glob_to_regex_string( $glob )
Returns a regex string which is the equivalent of the globbing pattern.
SYNTAX
The following metacharacters and rules are respected.
"*" - match zero or more characters
"a*" matches "a", "aa", "aaaa" and many many more.
"?" - match exactly one character
"a?" matches "aa", but not "a", or "aaa"
Character sets/ranges
"example.[ch]" matches "example.c" and "example.h"
"demo.[a-c]" matches "demo.a", "demo.b", and "demo.c"
alternation
"example.{foo,bar,baz}" matches "example.foo", "example.bar", and "example.baz"
leading . must be explictly matched
"*.foo" does not match ".bar.foo". For this you must either specify the leading . in the glob pattern (".*.foo"), or set
$Text::Glob::strict_leading_dot to a false value while compiling the regex.
"*" and "?" do not match /
"*.foo" does not match "bar/baz.foo". For this you must either explicitly match the / in the glob ("*/*.foo"), or set
$Text::Glob::strict_wildcard_slash to a false value with compiling the regex.
BUGS
The code uses qr// to produce compiled regexes, therefore this module requires perl version 5.005_03 or newer.
AUTHOR
Richard Clamp <richardc@unixbeard.net>
COPYRIGHT
Copyright (C) 2002, 2003, 2006, 2007 Richard Clamp. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
File::Glob, glob(3)perl v5.18.2 2017-10-06 Text::Glob(3)