\s+
(.*)
)?
$/smx;
Good luck!
--
Igor Sutton
[EMAIL PROTECTED]
PGP.sig
Description: This is a digitally signed message part
me '*' to remove the current directory.
File::Find::Rule->directory()->maxdepth(1)->name('*')->exec
( \&move_file )
->in($basedir);
Sorry for the erroneous code before.
--
Igor Sutton
[EMAIL PROTECTED]
PGP.sig
Description: This is a digitally signed message part
story', $_ ) )
or warn $!;
}
my $rule = File::Find::Rule->new;
$rule->directory()->name('trunk')->exec( \&move_file )->in($basedir);
--
Igor Sutton
[EMAIL PROTECTED]
PGP.sig
Description: This is a digitally signed message part
On 2007/04/04, at 18:12, Randal L. Schwartz wrote:
"Igor" == Igor Sutton Lopes <[EMAIL PROTECTED]> writes:
Igor> my $str = join( " ", map { s/\B(\w+)/\L\1/; $_ } split( /
\s+/, $_ ) );
It's bad style to modify $_ in a map, because that also m
THREE
A-HYPENED NAME
This was discussed sometime ago on Lisbon.pm :-)
while () {
my $str = join( " ", map { s/\B(\w+)/\L\1/; $_ } split( /\s+/,
$_ ) );
print "str = $str\n";
}
__DATA__
SOME NAME
SOMEONE WITH FOUR NAMES
ONE WITH THREE
A-HYPENED NAME
--
Ig
;
exit;
}
}
sub stop {
...
}
my %functions = (
start => \&start,
stop => \&stop,
...
);
$functions{$ARGV[0]}->();
This approach is called 'dispatch table' and is very common on Perl
code.
Good luck!
--
Igor Sutton
[EMAIL PROTECTED]
PGP.sig
Description: This is a digitally signed message part
ll that on usual Perl include path when done.
--
Igor Sutton
[EMAIL PROTECTED]
PGP.sig
Description: This is a digitally signed message part
low should do what you want.
$xml = new XML::Simple( KeyAttr => [], ForceArray => [qw/RECORD/] );
--
Igor Sutton
[EMAIL PROTECTED]
PGP.sig
Description: This is a digitally signed message part
File::Spec. It has functions to deal with
those problems.
--
Igor Sutton
[EMAIL PROTECTED]
PGP.sig
Description: This is a digitally signed message part
all a couple of prerequisites modules and spend your time doing
something
fun :-)
--
Igor Sutton
[EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
r 1, so please check out. For more
information about the above code:
$ perldoc strict
$ perldoc warnings
$ perldoc perlsyn
$ perldoc perlfunc
--
Igor Sutton
[EMAIL PROTECTED]
ink it's finally the best option.
Why don't you want to use the Archive::Ar module? There's some
problems with module's installation or something like that?
Just curious about :-)
--
Igor Sutton
[EMAIL PROTECTED]
On 2007/03/15, at 18:29, Jenda Krynicky wrote:
From: Igor Sutton Lopes <[EMAIL PROTECTED]>
my @possible_values = qw{
http://www.google.com
https://my.domain.
http://some.other.domain.net
};
my @urls = qw{
http://www.google.com/?some_bizarre_args
https://my.domain.com
s documentation.
--
Igor Sutton
[EMAIL PROTECTED]
http://some.other.domain.net
};
my $regex = '(' . join( "|", @possible_values ) . ')';
foreach my $url (@urls) {
if ( $url =~ /$regex/ ) {
print "$url matches!\n";
}
}
--
Igor Sutton
[EMAIL PROTECTED]
can try the Slash[1], which is the same that Slashdot runs,
if you like it. There's another I can't remember the name right now,
but it would not be difficult to find on a Google search.
[1] http://www.slashcode.com/
--
Igor Sutton
[EMAIL PROTECTED]
//www.twiki.org/
[2] http://www.bricolage.cc/
--
Igor Sutton
[EMAIL PROTECTED]
wnload them all?
Assuming such a script does not exist, can someone recommend a good
set of
packages and functions I would use to reinvent wget?
You can use WWW::Mechanize for browsing the pages and discover the
ISO's url and then LWP for grab them.
--
Igor Sutton
[EMAIL PROTECTED]
On 2007/03/14, at 15:55, Jeff Pang wrote:
Hello,
I just think regex is the best way since you choose to use Perl
doing this work.
Regexp::Common::URI may be what you're looking for.
--
Igor Sutton
[EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional com
sage, and the
concerning lines of your script?
--
Igor Sutton
[EMAIL PROTECTED]
PGP.sig
Description: This is a digitally signed message part
ay and
slice val-
ues interpolated into a double-quoted string (or
similar inter-
preted string). Default is a space. (Mnemonic:
obvious, I
think.)
HTH!
--
Igor Sutton
[EMAIL PROTECTED]
PGP.sig
Description: This is a digitally signed message part
Hi,
On 2007/02/26, at 10:12, John W. Krahn wrote:
print map "$_\n", @test;
print "$_\n" for @test;
Another solution is setting the $" variable:
my @array = qw(1 2 3 4 5);
{
local $" = "\n";
print "@array";
}
HTH!
--
Igor Sutto
directory. such
as: C:\Documents and Settings\yantao
USERPROFILE is the environment variable.
You can also use the File::HomeDir module, that implements the
abstraction for those operational systems.
HTH!
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
P
kA);
sub do_specific_thing {
my ($self) = @_;
my $data = $self->{B}->do_other_thing($self); # see, $self is
PackAA instead.
...
}
HTH!
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
uot; . join( ",", map { "?" } @list ) . ")";
print $query, "\n";
Then you can do this:
$sth->prepare($query);
$sth->execute (@list);
HTH!
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
Ana,
2007/2/13, Ana Saiz GarcĂa <[EMAIL PROTECTED]>:
Thank you all for your answers, they have been very helpful :o)
It would be nice if you post the solution you picked. It is useful for
another user like you to search in archives :-)
--
Igor Sutton Lopes <[EMAIL PROTECTED
ckage Application;
use Module::Pluggable require => 1;
package main;
foreach my $plugin ( Application->plugins() ) {
if ( my $code = $plugin->can("my_routine") ) {
$code->();
}
}
HTH!
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail:
gin::A;
sub my_routine {
print __PACKAGE__, "::my_routine()\n";
}
^D
$ cat > Application/Plugin/B.pm
package Application::Plugin::B;
sub my_routine {
print __PACKAGE__, "::my_routine()\n";
}
^D
$ perl module-pluggable-sample.pm
Application::Plugin::A::my_routine()
Application::
ackage main;
my $function_name = "some_function";
if (my $coderef = M->can($function_name)) {
$coderef->();
}
Good luck!
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
PGP.sig
Description: This is a digitally signed message part
Hi fellows,
Dave, you wanted to use
while (1) {
...
the code to be repeated
..
}
The above code could be written like this:
{
...
# the code to be repeated
...
redo;
}
Do you think this is better or worse than the other idiom? I like the last more.
--
Igor Sutton
);
my $filepath = "/tmp/something.txt";
my ($name, $path, $suffix) = fileparse($filepath, @suffix);
HTH!
--
Igor Sutton
[EMAIL PROTECTED]
PGP.sig
Description: This is a digitally signed message part
s.pm)));
Keep up the good work :)
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
sider the network traffic going from your computer
to destination. Probably the time you're seen is due to connection
delay. I told you the last message that one of the causes would be DNS
query, and told you how to cache it, but it is not the only bottleneck
you may get.
HTH!
--
Igor Sutton L
t.uspto.gov/netacgi/nph-Parser?";;
my $uri = URI->new($url);
print $uri->host, "\n";
HTH!
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
m_hostname("www.google.com");
$t->stop('get_ip_from_hostname without memoize');
}
print $t->report();
$t->reset();
memoize('get_ip_from_hostname');
for ( 1 .. 1000 ) {
$t->start('get_ip_from_hostname memoize');
my $ip = get_ip_from_ho
out
of 70.000 files have been downloaded)
You can use the awesome XML::RSS module to create RSS. Now, for
database insert you have the excellent DBI module.
I bet Java is your problem there (no, I'm not initiating a language war here).
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
--
mpose the filename
# from url.
}
open my $input, "<", $filename or die $!;
while (my $url = <$input>) {
chomp($url);
my $content = get($url);
if ($content) {
open my $output, ">", filename_from_url($url) or die $!;
print {$output} $content;
# skip comments
my ($capture) = /^(\w+)\s+/; # grab first 'word'
...
}
I also like to point that you still can match $some_var like this:
my ($capture) = $some_var =~ m/^(\w+)\s+/;
Example:
while (my $some_var = ) {
next if $some_var =~ /^#/;
my ($capture) = $some_var
et::SSH::Perl[2] to invoke procmail on remote host. I
think it is the best start, then you could improve it.
[1] http://search.cpan.org/~dbrobins/Net-SFTP-0.10/lib/Net/SFTP.pm
[2] http://search.cpan.org/~dbrobins/Net-SSH-Perl-1.30/lib/Net/SSH/Perl.pm
HTH!
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
I have an update:
my @data = $string =~ m/0x(\d{2})/g;
my @data = $string =~ m/0x(\S{2}),?/g;
Now I think it is right :)
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
iable. I need to pull out only the
numbers and store them in a array. Like:
@array = (53, 65, 63, 75, 72, 69, 74, 79, 43, 6F, 64, 65, 00);
I've achieved this results with the following code:
my @data = $string =~ m/0x(\d{2})/g;
I don't know if it is the most efficient way to do that.
%hash ) {
if ( $hash{$_} eq 'house' ) {
return 1;
}
}
}
my $results = timethese(
100,
{
reverse_hash => \&reverse_hash,
foreach_hash => \&foreach_hash,
}
);
cmpthese($results)
Maybe I'm doing the Ben
ash => \&foreach_hash,
}
);
cmpthese($results)
Maybe I'm doing the Benchmark in a wrong way, or is really more
expensive reversing a hash than iterating its keys using foreach?
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
'some cmd and args', 'optarg', ...);
HTH!
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
s right, because URI gives you the host part of uri.
What is the problem you are trying to solve?
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
s for any pointers,
Mike
Why don't you use the URI module for that?
use strict;
use warnings;
use URI;
while () {
my $uri = URI->new($_);
print $uri->host, "\n";
}
HTH.
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
2007/1/3, Octavian Rasnita <[EMAIL PROTECTED]>:
Hi,
I want to check if a certain string is UTF-8 or not.
Maybe you want Encode::Guess[1].
[1] http://search.cpan.org/~dankogai/Encode-2.18/lib/Encode/Guess.pm
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
uot;
$VAR1 = [
'',
'one',
'two',
'three',
'four'
];
[EMAIL PROTECTED] ~]$ perl -MData::Dumper -le "@foo = split ' ', qq( one two
three\t\n four ); print Dumper [EMAIL PROTECTED];&quo
behav-
ior, whereas "split(/ /)" will give you as many null initial
fields as there are leading spaces. A "split" on "/\s+/" is
like a "split(' ')" except that any leading whitespace
produces
a null first field. A "split" with no arguments really does
a
"split(' ', $_)" internally.
HTH
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
d or Getopt::Long modules, instead of writing your own
argument parser.
For resolving your file search problem, I suggest the File::Find or
File::Find::Rule modules instead. glob can give you headaches, and it
doesn't support regexes, just shell like substitution.
HTH
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
d, and then
Net::SSH::Perl[1] comes to rescue you.
[1] http://search.cpan.org/~dbrobins/Net-SSH-Perl-1.30/lib/Net/SSH/Perl.pm
Hope this helps!
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
es is mentioned in sudoers file.
--
Igor Sutton
[EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
your CPAN shell, then execute the command look "look Image::Imlib2".
Then 'perl Makefile.PL; make; make test; make install'.
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
uot;0". And it prints output
correctly, but not assigning it to my string.
By the way, if you want to know how to get the output of some external
command, you can check the qx// operator, that works the same as backticks.
$string = `date`;
Remember this approach is not portable.
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
ll be tight with ( $projection =~ ... ) because it has higher
precedence than 'or'. The way you wrote it will assign "(missing)" to
$ptype, then $ptype's value to $ptype again. It works but not the way you
think.
Maybe someone could correct me :-) ?
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
exical scope of for.
Maybe someone could explain this better?
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
while ($string != m/[a-zA-Z]{1,5}/ )
{ print("that is wrongtry again: ");
chomp ($string = ); }
Maybe:
while ($string !~ m/.../) {
...
}
When you're matching against regular expressions, you need to use =~ or !~.
Hope this helps.
--
Igor Sutton Lopes
t: +55
while(<@line>){
print if $_ =~ /The/ .. /east/ ;
I suggest this:
print join " ", (grep { /The/ .. /east/ } <@line>);
--
Igor Sutton Lopes
t: +55 51 9627.0779
e: [EMAIL PROTECTED]
There's some reason to not use Proc::ProcessTable? It is really easy to use,
and doesnt' relies on environment variables to be used.
--
Igor Sutton Lopes
t: +55 51 9627.0779
e: [EMAIL PROTECTED]
my %hash = map { $_, 1 } @array;
What is the usage of 1 in this code?
When you have any kind of doubt about a Perl structure, you can use
Data::Dumper:
use Data::Dumper;
my %hash = map { $_, 1 } @array;
print Dumper \%hash;
Try it!
--
Igor Sutton Lopes
t: +55 51 9627.0779
e: [EMAIL
/^((?:\d+\.){3})(\d+)$/
$2 will match the last entry of $1, unles s you use (?:). Now, $1 should be
the first three octets, and $2 should be the last octet.
--
Igor Sutton Lopes
t: +55 51 9627.0779
e: [EMAIL PROTECTED]
You can do something like this:
%url_options_hash = ("times_visited"=>0);
%url_hash = ("this_url"=>\%url_options_hash);
%usr_hash = ("igor"=>\%url_hash);
print $usr_hash{"igor"}->{"this_url"}->{"times_visited"}, "\n";
$usr_hash{"igor"}->{"this_url"}->{"times_visited"} = 1;
print $
62 matches
Mail list logo