Hello,
Can you explain why in the first 2 commands the awk does not print anything? Is it looking of a specific format ?
Thanks.
$ echo 12a3 | awk '($1>=2) {print $1}' # prints nothing
$ echo 123a | awk '($1>=2) {print $1}' # prints nothing
$ echo a123 | awk '($1>=2) {print $1}'
a123... (1 Reply)
I do not know how to do this unless I use a bunch of if statements. I need a script to replace numbers in each record in a file. I am really getting tangled in this web.
If a fieldA (19 positions) is greater than 14 digits, I have to change the data (resulting fieldA is fixed 19 postions).
If... (5 Replies)
Hi Everyone,
# cat 1
1;2;3;4;5;6
1;2;3;4;5;
# awk -F ";" '$5 == "5"' 1
1;2;3;4;5;6
1;2;3;4;5;
but the output is should be just "1;2;3;4;5;6" means 1st condition: $5 is 5; 2nd condition: $6 is not empty, please advice. Thanks (2 Replies)
Hi there,
I wanna define a variable 'tempbase'. Therefore I read a text file "base.out". "base.out" contains a list with four columns. 'tempbase' is the 4th entry in the line, where the first entry is equal to the predefined variable $orb1 and the second entry is equal to $orb2. I wrote the code... (2 Replies)
Hi there, here is my command
ssh host.local "/path/to/my/perscript/hostconfig.pl -s $HOST -d |awk '{if (\$4 > 120)print \"My error message\";exit}{s=0; for (i=1; i<=NF; i++) s++; if(s == 13) print \$3}'"
The problem is if conditional 1 is met (i.e $4 > 120), i don't see "My error message", the... (5 Replies)
Hi All,
I have a file with below contents.
"en2"/10.185.81.0:cluster_interconnect,"en5"/10.185.81.0:cluster_interconnect,"en6"/169.181.146.0:public
I want to take the interface name from the file and convert it as ipaddress using ifconfig command get the output like below
en6 ->... (2 Replies)
I'm having a problem pulling UID's from data. The data outputs a user's UID in one of three ways:
1. Error User user_name already assigned with <UID>
2. Success <UID> reserved for user_name
3. <a load of crap because there was a db failure yet somehow the UID is still in there>
I typically... (5 Replies)
hello gurus,
I want to use an associative array from a file to populate a field of another file, by matching several columns in order of priority. If the first column matches, then i dont want to match $2. Similarly I only want to match $3 when $1 and $2 are not in associative array.
For the... (6 Replies)
Discussion started by: ritakadm
6 Replies
LEARN ABOUT DEBIAN
www::wikipedia
WWW::Wikipedia(3pm) User Contributed Perl Documentation WWW::Wikipedia(3pm)NAME
WWW::Wikipedia - Automated interface to the Wikipedia
SYNOPSIS
use WWW::Wikipedia;
my $wiki = WWW::Wikipedia->new();
## search for 'perl'
my $result = $wiki->search( 'perl' );
## if the entry has some text print it out
if ( $result->text() ) {
print $result->text();
}
## list any related items we can look up
print join( "
", $result->related() );
DESCRIPTION
WWW::Wikipedia provides an automated interface to the Wikipedia <http://www.wikipedia.org>, which is a free, collaborative, online
encyclopedia. This module allows you to search for a topic and return the resulting entry. It also gives you access to related topics which
are also available via the Wikipedia for that entry.
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
METHODS
new()
The constructor. You can pass it a two letter language code, or nothing to let it default to 'en'.
## Default: English
my $wiki = WWW::Wikipedia->new();
## use the French wiki instead
my $wiki = WWW::Wikipedia->new( language => 'fr' );
WWW::Wikipedia is a subclass of LWP::UserAgent. If you would like to have more control over the user agent (control timeouts, proxies ...)
you have full access.
## set HTTP request timeout
my $wiki = WWW::Wikipedia->new();
$wiki->timeout( 2 );
You can turn off the following of wikipedia redirect directives by passing a false value to "follow_redirects".
language()
This allows you to get and set the language you want to use. Two letter language codes should be used. The default is 'en'.
my $wiki = WWW::Wikipedia->new( language => 'es' );
# Later on...
$wiki->language( 'fr' );
follow_redirects()
By default, wikipeda redirect directives are followed. Set this to false to turn that off.
search()
Which performs the search and returns a WWW::Wikipedia::Entry object which you can query further. See WWW::Wikipedia::Entry docs for more
info.
$entry = $wiki->search( 'Perl' );
print $entry->text();
If there's a problem connecting to Wikipedia, "undef" will be returned and the error message will be stored in "error()".
random()
This method fetches a random wikipedia page.
error()
This is a generic error accessor/mutator. You can retrieve any searching error messages here.
TODO
o Clean up results. Strip HTML.
o Watch the development of Special:Export XML formatting, eg: http://en.wikipedia.org/wiki/Special:Export/perl
SEE ALSO
o LWP::UserAgent
AUTHORS
Ed Summers <ehs@pobox.com>
Brian Cassidy <bricas@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2003-2011 by Ed Summers
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-04-05 WWW::Wikipedia(3pm)