One easier approach:
use Tie::File;
tie( my @array, 'Tie::File', "/path/to/file" )
or die $!;
my $n = 0;
while ( $n <= $#array ) {
if ( $array[$n] =~ /.*[Oo]rder deny,allow(.*)/ and
$n < $#array and $array[$n+1] =~ /[\Dd]eny from all(.*)/ )
{
$n
On Fri, Jan 29, 2016 at 12:39 AM, Jorge Almeida wrote:
> Can someone help me to understand this?
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> my $s='\\n';
> print $s;
>
>
> Output:
> \n
>
> Expected output:
> \\n
>
>
> Jorge Almeida
>
From: perldoc perlop
q/STRING/
ure 'say';
tie( my %pagetypes, 'Tie::IxHash') or die $!;
%pagetypes=( 'Delivery Note' => ..., Foo=>, Bar=>);
foreach my $pagetype (keys %pagetypes) { ... }
say $pagetypes{'Delivery Note'}{weight};
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
possibility:
...
for foreach my $entry ( @{$ordered{$ip}} ) {
while ( my($date, $data) = each %{$entry} ) {
say join( ,$date:, $data-{ip}, $data-{action} );
}
}
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional
\%ordered;
Leaving exact details of printing as an exercise for reader...
--
Charles DeRykus
On Fri, Jul 17, 2015 at 6:11 AM, Vincent Lequertier s...@riseup.net wrote:
Hi,
I have the following structure :
$hash{$date} = {
'ip' = $ip,
'action
my $DEBUG;
($DEBUG = shift) //= 0; # no debug if no arg missing
...
if ($DEBUG) { ... }
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
=~ /does not map to Unicode/) {
# take action.
}
}
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
++]; ... };
foreach $task (@tasks) {
if (...)
$report_statics-();
else
$report_dynamic-();
...
}
But with everything in lexical scope, you could just pass any needed
arg's directly and
eliminate the closure altogether.
--
Charles DeRykus
--
To unsubscribe, e
-[$iter++];
...
#MAIN_CODE START
foreach $task (@tasks) {
if ( )
$report_static-(\@tasks);
...
else
$report_dynamic-(\@tasks);
...
}
}
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners
) {
^
12: To save a full .LOG file rerun with -g
---
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
gallery :)
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On Tue, Jan 20, 2015 at 9:12 PM, Uri Guttman u...@stemsystems.com wrote:
On 01/20/2015 11:28 PM, Charles DeRykus wrote:
...
or something odd
my $contents = do { local $/; map { chomp } HANDLE };
I'm afraid this, while appealing, in my testing generates an
incorrect result, ie, 1
in the returned value.
Remember, map has tossed all but the final value at this point so it
just returns 1.
Clear as mud?
/SPECULATION
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h
]'
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
context .
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
...
I think the normal and original behavior is no reference. I think
they added the reference in 5.14 too. Perhaps the documentation
just fails to mention that support for arrays was added in 5.14
along with references? Hopefully I got that right this time. :)
Ah, RTFM would've helped ...
On Fri, Jan 9, 2015 at 10:31 AM, Brandon McCaig bamcc...@gmail.com wrote:
Charles:
On Fri, Jan 9, 2015 at 12:46 PM, Charles DeRykus dery...@gmail.com wrote:
On Fri, Jan 9, 2015 at 3:39 AM, Dermot paik...@gmail.com wrote:
I think John has answered your immediate question.
...
for (0
On Fri, Jan 9, 2015 at 3:39 AM, Dermot paik...@gmail.com wrote:
I think John has answered your immediate question.
...
for (0..$#files) {
print $_) $files[$_]\n;
}
Alternatively (at least since 5.14) :
say $k) $v while ($k,$v) = each @files;
--
Charles DeRykus
--
To unsubscribe, e
/;
my @cmd =(rsnapshot);
run( \@cmd, \undef, \$out, \$err) or die run: $!;
say out:$out \nerr:$err'
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
).*? /div
}six;
{ local($/);
my $content = DATA; # substitute your lexical filehandle
while ( $content =~ /$regex/g) {
print table=$1;
}
}
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e
in a conditional all in a one-liner?
Do you know for instance that my @foo = $some_scalar is the equivalent
of just saying: my @foo = ($some_scalar).
So, just a few thoughts... some more explanation of what that code is
intended to do would help.
--
Charles DeRykus
--
To unsubscribe, e-mail
in error IIRC. What happens is perl's internal array
structure for @x is marked inaccessible when the sub exits.This enables
the struct to be more quickly resurrected on subsequent calls. Scope is
preserved without doing extra work on re-entry.
Note the IIRC. Corrections welcome.
--
Charles
to export the plugin API into the Perl world to make it possible to
write plugins in Perl.
You might want to try the XS specific newsgroup:
lists.perl.org/list/perl-xs.html
Or, if that group hat den Loeffel abgegeben,
perlmonks.org
HTH,
Charles DeRykus
--
To unsubscribe, e
of context,
eg, perldoc perldata.
You could alter context, ie, change if to while, to get the correct count:
$c++ while $line =~ /\s\w+\s/g;
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http
On Mon, Jun 30, 2014 at 1:41 PM, Charles DeRykus dery...@gmail.com wrote:
On Mon, Jun 30, 2014 at 11:57 AM, Sunita Pradhan
sunita.pradhan.2...@hotmail.com wrote:
Hi
I want to count number of occurrences of one word in a line within one
single line of perl script .
My code :
$c
On Mon, Jun 30, 2014 at 1:53 PM, Charles DeRykus dery...@gmail.com wrote:
On Mon, Jun 30, 2014 at 1:41 PM, Charles DeRykus dery...@gmail.com wrote:
On Mon, Jun 30, 2014 at 11:57 AM, Sunita Pradhan
sunita.pradhan.2...@hotmail.com wrote:
You could alter context, ie, change if to while
Vernekar vernekaru...@gmail.com
wrote:
Thanks everybody will work out the Feasible option from all
these..Thanks a lot
On Mon, Jun 23, 2014 at 10:12 PM, Charles DeRykus dery...@gmail.com
wrote:
On Mon, Jun 23, 2014 at 2:42 AM, Uday Vernekar vernekaru...@gmail.com
wrote:
Hi All,
I
Another way:
while ( DATA) {
...
my $fail_count - ( split( /\|/, $_ ) )[-2];
...
}
See: perldoc -f split
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
) {
say $fname is a plain file;
}
Is there a simpler way to do this?
Potentially shorter and arguably simpler if you use the special
underscore argument to access file info for previous test, eg,
if ( -f $fname and not -l _ ) {
say...
}
--
Charles DeRykus
--
To unsubscribe, e-mail
= qr/(|').*?\g{1}/;
my @array;
while (my $line = $file){
while($line =~ /$pattern/pg) {
push (@array, ${^MATCH});
}
}
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
(Perl reg exp tutorial)
perlre (Perl regular expressions, the rest of the story)
.--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
-computational-x86_64/boost141-regex-1.4.0-2.el5.x86_64.rpm.html
HTH,
Charles DeRykus
On Mon, Feb 17, 2014 at 4:25 PM, Phil Smith philbo...@gmail.com wrote:
On Mon, Feb 17, 2014 at 6:16 PM, Charles DeRykus dery...@gmail.comwrote:
On Mon, Feb 17, 2014 at 12:41 PM, Phil Smith philbo...@gmail.com wrote:
I'm currently loading some new servers with CentOS6 on which perl5.10
And, then go on to other suggested sources... or not :)
TIMTOWDI
--
Charles DeRykus
, easier and more
transparent than deciphering shell error returns, and enables you
to avoid the nasty quoting issues of a 'system' call:
use File::Copy;
move( $file1, $file2) or die move: $!;
See: perldoc File::Copy
--
Charles DeRykus
expressions are used in matchings of
m//,
operations, plus various examples of the same, see discussions of
m//,
s///, qr// and ?? in Regexp Quote-Like Operators in
perlop.ls of
Modifiers quoted constructs in perlop
--
Charles DeRykus
--
Charles DeRykus
On 11/30/2013 5:16 AM, Lars Noodén wrote:
On 11/30/2013 02:55 PM, Charles DeRykus wrote:
[ ..
Thanks. I see those in perlop and perlfunc. In perlfunc, it is grouped
as Regular expressions and pattern matching though that man page just
points to perlop.
A really clear description in perlre
On Wed, Oct 2, 2013 at 5:10 PM, Peter Holsberg
pjh42atpobox@gmail.comwrote:
Charles DeRykus has written on 10/2/2013 5:49 PM:
Wouldn't a manual edit be easier... or is this a recurrent problem?
If recurrent, a messy solution may be possible but fragile unless
the html formatting
On Wed, Oct 2, 2013 at 1:58 AM, James Griffin j...@kontrol.kode5.net wrote:
* Shawn H Corey shawnhco...@gmail.com [2013-10-01 17:34:06 -0400]:
On Tue, 1 Oct 2013 14:14:16 -0700
Charles DeRykus dery...@gmail.com wrote:
I'm not bucking for net nanny but, while full solutions
).
--
Charles DeRykus
On Sun, Sep 15, 2013 at 6:59 PM, Charles DeRykus dery...@gmail.com
wrote: left: , $start+$sleep -time() };
...
Actually, this is wrong because if sleep(3) is interrupted by any signal
it
will return, so something like this should work, eg
my $secs_to_sleep = 60;
my $start = time();
my $end
would be grinding
out more code.
--
Charles DeRykus
On Fri, Jul 26, 2013 at 4:45 AM, Perl Beginners beginners@perl.org wrote:
On 07/25/2013 04:40 PM, Charles DeRykus wrote:
On Wed, Jul 24, 2013 at 10:56 PM, Michael Brader
mbra...@internode.com.au
mailto:mbra...@internode.com.**aumbra...@internode.com.au
wrote:
On 07/25/2013 10:14
this is with HTTP::Request::Common which
will handle escaping the form parameters for you, eg,
use HTTP::Request::Common;
use LWP::UserAgent;
$ua-request( POST 'http://rt.cpan.org/Public/Dist/Display.html'
[ Status = ..., Name=... ] );
--
Charles DeRykus
, fmt2=... } );
--
Charles DeRykus
useful for quickly generating
reports: [...snip]
...
Hm, this wasn't an argument for exclusive either/or usage at all. Rather
I was making a case that do in limited cases could be a shorter and/or
slightly clearer idiom.
--
Charles DeRykus
On Fri, Jun 28, 2013 at 1:21 AM, Dr.Ruud rvtol+use...@isolution.nl wrote:
On 28/06/2013 09:08, Charles DeRykus wrote:
[...] I was making a case that do in limited cases could be a
shorter and/or slightly clearer idiom.
I think the context was if you would ever go as far as using double
-e 'do {$in =; ... } until $in =~ /q/'
vs.
perl -e 'while ( $in = ; ... ) { ... last if $in =~ /q/}'
--
Charles DeRykus
$decoder-name;#--- utf8
--
Charles DeRykus
are fairly intuitive but you can add:
use diagnostics qw/-verbose/;
for added explanations.
--
Charles DeRykus
: '' at...
--
Charles DeRykus
On Wed, May 1, 2013 at 12:57 PM, Manfred Lotz manfred.l...@arcor.de wrote:
On Wed, 1 May 2013 12:00:18 -0700
Charles DeRykus dery...@gmail.com wrote:
...
Thanks for your detailed explanations. I think that close should
work as I cannot see any reason why a failure of a command closes
On Tue, Apr 30, 2013 at 10:07 AM, Piyush Verma 114piy...@gmail.com
wrote:
Hi,I want to use string as a variable name, please explain if there is
any way
in perl.
...
This is a FAQ. See:
http://perldoc.perl.org/perlfaq7.html#How-can-I-use-a-variable-as-a-variable-name
?
--
Charles
::NYTProf, I need to check if my SA if he will allow me to
install
You can usually just install the module under your own directory...
See: perldoc -q How do I keep my own module/library directory?
--
Charles DeRykus
:
...
use warnings;
my @a;
{
no warnings;
my $b = @a[0];
}
my $c = @a[0];
The code in the enclosing block has warnings enabled, but the inner
block has them disabled.
...
--
Charles DeRykus
On Thu, Mar 21, 2013 at 6:41 PM, Charles DeRykus dery...@gmail.com wrote:
On Thu, Mar 21, 2013 at 3:12 PM, Dominik Danter domi...@foop.at wrote:
Hi I just don't understand the perlfaq example. All I want is to capture
output
of an external command's stdout and stderr. Here is what I've tried
$agent-success; ;
print content: $a-content;
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
errors so if
it couldn't fetch content, your program dies before mech ran
occurs. Only if you said $agent-new(autocheck=0), would you
see it.
You can see the differing output in these:
$agent-new(autocheck=0); # toggle 0/1
$agent-get(http://nowhere.com/nono;);
print mech ran;
--
Charles DeRykus
but the pipe
close needs to be checked first and then
subsequently the child return as another poster
demonstrated:
close $trexe or warn $! ? Error closing $tr pipe: $!
: Exit status $? from $tr;
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr
)machine
so yes I'm root I want to do this on a system wide basis.
I haven't used it but App::cpanminus may be a
help:
http://search.cpan.org/~miyagawa/App-cpanminus-1.6002/lib/App/cpanminus.pm
--
Charles DeRykus
to do
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional
, no matter if it appears in a
link or not, probably the easiest way would be to use regular expressions.
Or search on CPAN if there is a module that does that easier.
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h
*possibly* fail. ;)
A module is a good idea since URI will parse a valid
mailto and ignore leading whitespace. Note however
there may be multiple comma separated emails.
See: perldoc URI.
my $uri = URI-new($link);
if ( $uri-scheme eq 'mailto') {
my $email = $uri-path;
...
}
--
Charles
On Sat, Jan 12, 2013 at 12:56 PM, Charles DeRykus dery...@gmail.com wrote:
On Fri, Jan 11, 2013 at 2:01 PM, Christer Palm b...@bredband.net wrote:
Hi!
I have a perl script that parses RSS streams from different news sources and
experience problems with national characters in a regexp
programming
but you may want to invest in learning POE:
https://poe.perl.org
It's already refined many of the wheels you'll need and appears well
documented.
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
)
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
;
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
to the unwanted \
would be $user =~ tr/\\//d;
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On Thu, Dec 13, 2012 at 8:09 AM, Alvin Ramos w...@theflux.net wrote:
Any one have any suggestions of a module/function/method to write a perl
script to try pinging a server then after the 3rd time to send an email?
Thanks in advance...
perldoc Net::Ping
--
Charles DeRykus
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On Sat, Dec 1, 2012 at 9:58 PM, Charles DeRykus dery...@gmail.com wrote:
...
On the command line, I believe you just redirecto to nul:
chch 2nul
^^^
chcp
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
On Sat, Dec 1, 2012 at 10:06 PM, boB Stepp robertvst...@gmail.com wrote:
On Sat, Dec 1, 2012 at 11:58 PM, Charles DeRykus dery...@gmail.com wrote:
On Sat, Dec 1, 2012 at 8:50 PM, boB Stepp robertvst...@gmail.com wrote:
What I would like to do is make chcp 65001 the default behavior
On Thu, Nov 29, 2012 at 5:00 AM, timothy adigun 2teezp...@gmail.com wrote:
Hi,
Please check my comments below:
On Thu, Nov 29, 2012 at 8:55 AM, Charles DeRykus dery...@gmail.com wrote:
On Wed, Nov 28, 2012 at 8:10 PM, boB Stepp robertvst...@gmail.com wrote:
As I have mentioned
on?
(I understand that the first line is a consequence of my system
command to turn on UTF-8.)
binmode STDOUT, :utf8;
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
sides keys and values.
One possible way:
DB_File has a BTREE file type (with the R_DUP setting and
the 'seq' API method) that enables storing/retrieving dup's.
There's a full example in the docs.
See: perldoc DB_File.
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr
Assuming no anomalies/surprises in file.txt:
use File::Slurp;
use strict;
use warnings;
my @lines = read_file( 'file.txt', chomp=1 );
my %hash = map { split( /\s*=\s*/,$_ ) } @lines;
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail
line endings.
See: perldoc perlio
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
looks correct.
I have modified the Mechanize.pm @ line no. 2042 to open( my $fh,
':utf8', $filename ). But I am not getting the desired output.
Please help in getting the $mech-content in utf-8 format.
Try $mech-decoded_content instead of $mech-content.
HTH,
Charles DeRykus
--
To unsubscribe
Hello,
I subscribed to perl.beginners via Google groups but none of my posts
get through
Can you help or suggest what might be amiss?
--
Charles DeRykus
78 matches
Mail list logo