Re: Checking if a website is up doesn't work correctly

2018-02-17 Thread Manfred Lotz
On Thu, 15 Feb 2018 05:46:33 -0600 Mike Flannigan wrote: > See if some version of the attached program > gives the results you expect. > > > Mike > > Thanks. The attached program does better as https://notabug.org works. Only http://scripts.sil.org doesn't work. It seems there are special ch

Re: Checking if a website is up doesn't work correctly

2018-02-13 Thread Manfred Lotz
ORIGIN > > > class="no-js" lang="en-US"> > Access denied | www.sil.org used Cloudflare to restrict > access > > > (+ 2770 more bytes not shown) > > so it's up, but "forbidden" probably as the user agent isn't s

Re: Checking if a website is up doesn't work correctly

2018-02-13 Thread Manfred Lotz
But am afraid this is not all of it. If I test http://scripts.sil.org/OFL then I get an error but it is fine in firefox. Very strange. -- Manfred > > On Tue, Feb 13, 2018 at 5:25 AM, Manfred Lotz > wrote: > > > Hi there, > > Somewhere I found an example how to ch

Checking if a website is up doesn't work correctly

2018-02-13 Thread Manfred Lotz
Hi there, Somewhere I found an example how to check if a website is up. Here my sample: #! /usr/bin/perl use strict; use LWP::Simple; my $url="https://notabug.org";; if (! head($url)) { die "$url is DOWN" } Running above code I get https://notabug.org is DOWN at ./check_url.pl l

Re: Bizarre copy of HASH in list assignment...

2015-04-12 Thread Manfred Lotz
... I just worked around by using warn/die again. -- Manfred On Tue, 31 Mar 2015 13:24:31 +0300 Shlomi Fish wrote: > Hi Manfred, > > On Tue, 31 Mar 2015 10:28:13 +0200 > Manfred Lotz wrote: > > > Hi there, > > I have a script where I use croak and somebody else using

Bizarre copy of HASH in list assignment...

2015-03-31 Thread Manfred Lotz
Hi there, I have a script where I use croak and somebody else using that script gets Bizarre copy of HASH in list assignment at /usr/share/perl/5.20/Carp.pm line 228. I get a message like this, instead: Variable b has empty value! at ./x.pl line 23. main::myfunc() called at ./x.pl line 8

Re: catching utf8 errors

2015-03-15 Thread Manfred Lotz
On Sun, 15 Mar 2015 23:26:41 +1300 Kent Fredric wrote: > On 15 March 2015 at 21:41, Manfred Lotz wrote: > > > I agree but I thought that in this case I would need to know the > > potential warning messages the :encoding(UTF-8) could issue in > > order to take action i

Re: catching utf8 errors

2015-03-15 Thread Manfred Lotz
On Sun, 15 Mar 2015 21:11:05 +1300 Kent Fredric wrote: > On 15 March 2015 at 20:07, Manfred Lotz wrote: > > > I prefer the method Charles showed. But nevertheless your method is > > interesting as well. > > > > FWIW, SIG{__WARN__} is much preferred over redirecti

Re: catching utf8 errors

2015-03-15 Thread Manfred Lotz
I prefer the method Charles showed. But nevertheless your method is interesting as well. Thanks for sharing, Manfred On Sat, 14 Mar 2015 14:24:48 -0400 Brandon McCaig wrote: > On Sat, Mar 14, 2015 at 03:20:06AM -0700, Charles DeRykus wrote: > > open my $fh, '<:encoding ) or die ... > > >

Re: catching utf8 errors

2015-03-14 Thread Manfred Lotz
On Sat, 14 Mar 2015 03:20:06 -0700 Charles DeRykus wrote: > On Sat, Mar 14, 2015 at 2:38 AM, Manfred Lotz > wrote: > > Hi all, > > I wanted to test what happens if Perl encounters an error when > > reading a utf8 encoded file. > > > > Here a minimal example:

Re: catching utf8 errors

2015-03-14 Thread Manfred Lotz
On Sat, 14 Mar 2015 23:18:42 +1300 Kent Fredric wrote: > On 14 March 2015 at 22:38, Manfred Lotz wrote: > > > following error message which is fine. > > > Sorry for being pedantic, but I think you'll find that those are what > we call "warnings", not

catching utf8 errors

2015-03-14 Thread Manfred Lotz
Hi all, I wanted to test what happens if Perl encounters an error when reading a utf8 encoded file. Here a minimal example: #! /usr/bin/perl use strict; use warnings; my $fname = $ARGV[0]; open my $fh, '<:encoding(UTF-8)', $fname or die "Couldn't open file: $fname"; my $string = <$fh>; clo

Re: File checks

2014-05-22 Thread Manfred Lotz
On Thu, 22 May 2014 16:51:24 -0500 Andy Bach wrote: ... Very interesting experiments. > $ perl -e '$fname = "st"; print "yes\n" if ( -f $fname and not -l > _ )' > The stat preceding -l _ wasn't an lstat at -e line 1. This tells me that if ( -f $fname and not -l _ )' should perhap

Re: File checks

2014-05-22 Thread Manfred Lotz
On Thu, 22 May 2014 14:37:01 -0700 Charles DeRykus wrote: > On Thu, May 22, 2014 at 1:40 PM, Manfred Lotz > wrote: > > Hi there, > > I want to check if a file is a plain file but not a symlink. > > > > It seems because -f returns true for a symlink that I

File checks

2014-05-22 Thread Manfred Lotz
Hi there, I want to check if a file is a plain file but not a symlink. It seems because -f returns true for a symlink that I have to do this: my $fname = 'somefile'; if ( -f $fname and not -l $fname ) { say "$fname is a plain file"; } Is there a simpler way to do this? -- Manfred

Re: OO perl programming

2014-02-06 Thread Manfred Lotz
On Wed, 5 Feb 2014 19:00:12 -0500 Omega -1911 <1911...@gmail.com> wrote: > I really think the quoting that you own a resource for beginners is > outdated. Why should you have to reveal you own a site that helps > people? I wish all the Perl guru's would put down their differences > and get this li

Re: package block

2014-02-05 Thread Manfred Lotz
Hi Paul, On Wed, 5 Feb 2014 11:37:08 + Paul Johnson wrote: > On Wed, Feb 05, 2014 at 10:51:56AM +0100, Manfred Lotz wrote: > > Hi all, > > Perl 5.14 allows package blocks. > > > > Assume i have a file Hello.pm > > > > package Hello; { > >

Re: package block

2014-02-05 Thread Manfred Lotz
Hi Shlomi, On Wed, 5 Feb 2014 14:20:55 +0200 Shlomi Fish wrote: > Hi Manfred, > > On Wed, 5 Feb 2014 10:51:56 +0100 > Manfred Lotz wrote: > > > Hi all, > > Perl 5.14 allows package blocks. > > > > Assume i have a file Hello.pm > > > > pa

package block

2014-02-05 Thread Manfred Lotz
Hi all, Perl 5.14 allows package blocks. Assume i have a file Hello.pm package Hello; { ... 1; } # or better here # 1; My question is: Would I put 1; inside the { } or should I put it outside the { }. -- Manfred -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional

Re: How to create a socket file?

2014-01-08 Thread Manfred Lotz
On Wed, 8 Jan 2014 14:54:10 +0200 Shlomi Fish wrote: > On Wed, 8 Jan 2014 13:32:49 +0100 > Manfred Lotz wrote: > > > Hi Shlomi, > > > > Thanks a lot. This is exactly what I was after. > > > > Hi Manfred, > > you are welcome. > > One

Re: How to create a socket file?

2014-01-08 Thread Manfred Lotz
Hi Shlomi, Thanks a lot. This is exactly what I was after. -- Manfred On Wed, 8 Jan 2014 13:15:22 +0200 Shlomi Fish wrote: > Hi Manfred, > > Please reply to list if it's a mailing list post - > http://shlom.in/reply . > > On Wed, 8 Jan 2014 11:42:45 +0100 > Manf

How to create a socket file?

2014-01-08 Thread Manfred Lotz
Hi there, For test purposes I want to create a socket file. Something I could list via ls -l. That's all I want to achieve. As I didn't find any utility to create a socket file my hope is that Perl offers something to do this. Any idea? -- Manfred -- To unsubscribe, e-mail: beginners-unsubsc

Re: Testing a standalone script

2013-10-29 Thread Manfred Lotz
On Tue, 29 Oct 2013 12:01:52 -0700 John SJ Anderson wrote: > On Tue, Oct 29, 2013 at 11:02 AM, Manfred Lotz > wrote: > > This is exactly what I don't want to do. IMHO, for testing modules > > or applications this is the way to go. However, for a standalone > > sc

Re: Testing a standalone script

2013-10-29 Thread Manfred Lotz
On Tue, 29 Oct 2013 12:36:58 -0400 Shawn H Corey wrote: > On Tue, 29 Oct 2013 17:10:51 +0100 > Manfred Lotz wrote: > > > Hi there, > > I have some relatively small standalone perl scripts where I would > > like to include tests. > > > > Which is the rec

Testing a standalone script

2013-10-29 Thread Manfred Lotz
Hi there, I have some relatively small standalone perl scripts where I would like to include tests. Which is the recommended way to test standalone scripts? -- Manfred -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://lea

Re: Can't close filehandle

2013-05-01 Thread Manfred Lotz
On Wed, 1 May 2013 14:57:34 -0700 Charles DeRykus wrote: > On Wed, May 1, 2013 at 12:57 PM, Manfred Lotz > wrote: > > > On Wed, 1 May 2013 12:00:18 -0700 > > Charles DeRykus wrote: > > > > > > ... > > > > Thanks for your detailed explan

Re: Can't close filehandle

2013-05-01 Thread Manfred Lotz
On Wed, 1 May 2013 12:00:18 -0700 Charles DeRykus 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 > > the pipe prematurely. > > Actually, everything is ok until the close which checks both

Re: Can't close filehandle

2013-05-01 Thread Manfred Lotz
On Wed, 1 May 2013 11:50:05 -0400 Brandon McCaig wrote: > On Wed, May 01, 2013 at 11:45:00AM -0400, Brandon McCaig wrote: > > One thing that I know bit me with the 'or die' pattern is that > > with a pipe if the child process exits with an non-zero exit > > status then close returns undef, ... >

Re: Can't close filehandle

2013-05-01 Thread Manfred Lotz
On Wed, 1 May 2013 10:04:15 -0500 Andy Bach wrote: > On Wed, May 1, 2013 at 9:22 AM, Manfred Lotz > wrote: > > > have a script where I log stuff to a file and the same time displays > > it to stdout using Log4perl. > > > > If you use the autodie perld

Re: Can't close filehandle

2013-05-01 Thread Manfred Lotz
On Wed, 1 May 2013 07:58:38 -0700 "Ron Bergin" wrote: > Manfred Lotz wrote: > > Hi there, > > I have a script where I log stuff to a file and the same time > > displays it to stdout using Log4perl. > > > > Here is a minima

Can't close filehandle

2013-05-01 Thread Manfred Lotz
Hi there, I have a script where I log stuff to a file and the same time displays it to stdout using Log4perl. Here is a minimal example where I log a command which fails. #! /usr/bin/perl use strict; use warnings; #use autodie; use Log::Log4pe

Re: Unicode question

2012-07-13 Thread Manfred Lotz
On Thu, 12 Jul 2012 15:40:55 -0500 Andy Bach wrote: > On Thu, Jul 12, 2012 at 3:25 PM, Manfred Lotz > wrote: > > This is really nice. I fumbled with unpack before but have to admit > > that I didn't know about 'use bytes' which is the key. > > Couple inte

Re: Unicode question

2012-07-12 Thread Manfred Lotz
On Thu, 12 Jul 2012 21:01:35 +0200 Manfred Lotz wrote: ... > > > > On the one hand I believe there must be a 'better' way. On the other > hand I like the idea (didn't occur to me) to read from the string as > if it were a file. > I found somet

Re: Unicode question

2012-07-12 Thread Manfred Lotz
Hi Shawn, Thanks for your reply. On Thu, 12 Jul 2012 14:50:16 -0400 Shawn H Corey wrote: > On 12-07-12 02:08 PM, Manfred Lotz wrote: > > The following code works fine. However, I like to know how to > > retrieve the UTF-8 hex representation of $uchar which is x'e0a487'.

Unicode question

2012-07-12 Thread Manfred Lotz
Hi all, Perhaps this is a stupid question. Anyway. The following code works fine. However, I like to know how to retrieve the UTF-8 hex representation of $uchar which is x'e0a487'. This is the internal representation in Perl, so it should be possible to print it out. Is there any function or modul

Re: Getopt::Long

2012-05-16 Thread Manfred Lotz
Hi Rajesh, On Wed, 16 May 2012 16:11:13 +0530 Rajesh Saha wrote: > Hi, > > Sorry for one typo. Read "GetOptions" in place of "Getoptions" . > > Regards, > Rajesh > > > Here is how I do it: #! /usr/bin/perl use strict; use warnings; use Getopt::Long; my $dry_run = 0; GetOptions('vers

Re: Perl preprocessor

2012-05-06 Thread Manfred Lotz
On Fri, 4 May 2012 23:01:46 -0700 Jim Gibson wrote: > > On May 4, 2012, at 12:31 PM, Manfred Lotz wrote: > > > > > Thanks to both (Uri) of you for your reply. > > > > I recognize that my example was bad. If I just would like to > > substitute stuff th

Re: Perl preprocessor

2012-05-04 Thread Manfred Lotz
On Fri, 4 May 2012 20:27:36 +0200 Paul Johnson wrote: > On Fri, May 04, 2012 at 08:16:01PM +0200, Manfred Lotz wrote: > > Hi there, > > I'm looking for a Perl preprocessor which should roughly be able to > > work like this: > > > > In a document I have

Perl preprocessor

2012-05-04 Thread Manfred Lotz
code should be lexical in a way that later code could refer to previous code. Primitive example: This is a sample document. ## my $name = 'Manfred Lotz'; ## My name is ## print $name; ## and I'm from Germany. should result in the following document: This is a sample document

Re: Recommended config/ini file module?

2012-05-04 Thread Manfred Lotz
On Tue, 01 May 2012 08:38:01 -0700 Michael Rasmussen wrote: > On 2012-05-01 06:43, Manfred Lotz wrote: > > On Tue, 1 May 2012 05:57:28 -0700 > > Michael Rasmussen wrote: > > > >> On Tue, May 01, 2012 at 11:58:46AM +0200, Manfred Lotz wrote: > >> > Hi

Re: Recommended config/ini file module?

2012-05-01 Thread Manfred Lotz
On Tue, 1 May 2012 15:58:49 +0530 Mohan L wrote: > On Tue, May 1, 2012 at 3:28 PM, Manfred Lotz > wrote: > > > Hi there, > > What is a recommended Module for processing config resp. inifile > > formats? > > > > One important feature I need is to use prev

Re: Recommended config/ini file module?

2012-05-01 Thread Manfred Lotz
On Tue, 1 May 2012 05:57:28 -0700 Michael Rasmussen wrote: > On Tue, May 01, 2012 at 11:58:46AM +0200, Manfred Lotz wrote: > > Hi there, > > What is a recommended Module for processing config resp. inifile > > formats? > > > > One important feature I need is

Recommended config/ini file module?

2012-05-01 Thread Manfred Lotz
Hi there, What is a recommended Module for processing config resp. inifile formats? One important feature I need is to use previously defined entries. Example: [General] base_dir : /somedir [Files] iso_image : ${base_dir}/x.iso lib : a.so lib : b2.so Multiple entries like 'lib' above is nice

Re: File::Find::Object::Rule problem

2012-04-23 Thread Manfred Lotz
On Mon, 23 Apr 2012 06:02:55 + Jack Maney wrote: > Manfred, > > The issue is that you're storing the return value of the start method > into $plf, and if you look at the source code, the start method > returns 1. > > In fact, using Data::Dumper, > > print Dumper($plf) . "\n"; > > returns

Re: File::Find::Object::Rule problem

2012-04-23 Thread Manfred Lotz
On Mon, 23 Apr 2012 11:01:33 +0300 Shlomi Fish wrote: > Hi all, > > On Mon, 23 Apr 2012 10:12:33 +0300 > Shlomi Fish wrote: > > > Hi Jack, > > > > On Mon, 23 Apr 2012 06:02:55 + > > Jack Maney wrote: > > > > > Manfred, > > > > > > The issue is that you're storing the return value of th

File::Find::Object::Rule problem

2012-04-22 Thread Manfred Lotz
Hi, I'm trying out File::Find::Object::Rule and get a problem. Here a minimal example: #! /usr/bin/perl use strict; use warnings; use Data::Dumper; use File::Find::Object::Rule ; my $plf = File::Find::Object::Rule->file->name("*.pl")->start( "./" ); while ( my $perl_file = $plf->match ){

Re: XML::Mini question

2012-04-18 Thread Manfred Lotz
On Wed, 18 Apr 2012 22:23:37 +0200 Manfred Lotz wrote: > On Thu, 19 Apr 2012 06:15:47 +1000 > "Owen" wrote: > > > > > > Hi there, > > > I've got a question about XML::Mini. > > > > > > When parsing an xml document for some reas

Re: XML::Mini question

2012-04-18 Thread Manfred Lotz
On Thu, 19 Apr 2012 06:15:47 +1000 "Owen" wrote: > > > Hi there, > > I've got a question about XML::Mini. > > > > When parsing an xml document for some reasons I want to preserve > > white space. However, it doesn't work really. > > > > Minimal example: > > > > ! /usr/bin/perl > > > > > > use st

XML::Mini question

2012-04-18 Thread Manfred Lotz
Hi there, I've got a question about XML::Mini. When parsing an xml document for some reasons I want to preserve white space. However, it doesn't work really. Minimal example: ! /usr/bin/perl use strict; use warnings; use Data::Dumper; use XML::Mini::Document; my $XMLString = " Learning Perl

Re: & and subroutine

2012-04-17 Thread Manfred Lotz
On Tue, 17 Apr 2012 14:43:01 +0100 Gary Stainburn wrote: > On Tuesday 17 April 2012 13:30:59 Manfred Lotz wrote: > > > > One example is this: > > > > #! /usr/bin/perl > > > > use strict; > > use warnings; > > > > mysub; > > > >

Re: & and subroutine

2012-04-17 Thread Manfred Lotz
On Tue, 17 Apr 2012 12:27:32 +0100 Gary Stainburn wrote: > On Monday 16 April 2012 15:20:35 Paul Johnson wrote: > > On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote: > > > Hi All > > > > > > Have a question, is it good coding practice to use a & when > > > calling a subroutine, or it is not

Re: Template::Toolkit question

2012-04-09 Thread Manfred Lotz
On Tue, 10 Apr 2012 01:07:32 +0200 "Jenda Krynicky" wrote: > > Hi all, > > Let's say I use Template:Toolkit like this: > > > > <-snip---> > > #! /usr/bin/perl > > > > use strict; > > use warnings; > > > > use Template; > > > > my $variables = { nrme => "Manfred

Re: Template::Toolkit question

2012-04-09 Thread Manfred Lotz
On Mon, 09 Apr 2012 17:03:13 -0400 Uri Guttman wrote: > On 04/09/2012 02:28 PM, Manfred Lotz wrote: > > Hi all, > > Let's say I use Template:Toolkit like this: > > > > <-snip---> > > #! /usr/bin/perl > > >

Re: Template::Toolkit question

2012-04-09 Thread Manfred Lotz
On Mon, 9 Apr 2012 20:28:14 +0200 Manfred Lotz wrote: > Hi all, > Let's say I use Template:Toolkit like this: > > <-snip---> > #! /usr/bin/perl > > use strict; > use warnings; > > use Template; > > my $variabl

Template::Toolkit question

2012-04-09 Thread Manfred Lotz
Hi all, Let's say I use Template:Toolkit like this: <-snip---> #! /usr/bin/perl use strict; use warnings; use Template; my $variables = { nrme => "Manfred", }; my $cmd = 'Hi [% name %], how are you.'; my $template = Template->new(); $template->process(\$cmd, $

Re: Why do I get a warning?

2012-03-26 Thread Manfred Lotz
On Mon, 26 Mar 2012 20:58:43 +0200 Paul Johnson wrote: > On Mon, Mar 26, 2012 at 06:10:08PM +0200, Manfred Lotz wrote: > > On 25 Mar 2012 13:11:16 - > > Peter Scott wrote: > > > > > On Thu, 22 Mar 2012 20:06:35 -0400, Uri Guttman wrote: > > > > no

Re: Why do I get a warning?

2012-03-26 Thread Manfred Lotz
On 25 Mar 2012 13:11:16 - Peter Scott wrote: > On Thu, 22 Mar 2012 20:06:35 -0400, Uri Guttman wrote: > > no one uses braces for single scalar handles in general. > > I do. Ever since Damian recommended it (Perl Best Practices, page > 217). One of those numerous times I didn't agree with h

Re: Why do I get a warning?

2012-03-23 Thread Manfred Lotz
On Fri, 23 Mar 2012 02:35:28 -0400 Uri Guttman wrote: > On 03/23/2012 12:21 AM, Manfred Lotz wrote: > > On Thu, 22 Mar 2012 20:06:35 -0400 > > Uri Guttman wrote: > > > > My idea behind using always braces was that then I'm always sure > > Perl does the ri

Re: Why do I get a warning?

2012-03-22 Thread Manfred Lotz
On Thu, 22 Mar 2012 20:06:35 -0400 Uri Guttman wrote: > On 03/22/2012 05:49 PM, Manfred Lotz wrote: > > > > > In documentation about 'open' I found: > > > > Note that if you're storing FILEHANDLEs in an array, or if > > you&#x

Re: Why do I get a warning?

2012-03-22 Thread Manfred Lotz
On Thu, 22 Mar 2012 14:09:32 -0700 Leo Susanto wrote: > On Thu, Mar 22, 2012 at 1:54 PM, Manfred Lotz > wrote: > > On Thu, 22 Mar 2012 13:08:53 -0700 > > Leo Susanto wrote: > > > >> you should do > >> > >> print {$hdl} "a line

Re: Why do I get a warning?

2012-03-22 Thread Manfred Lotz
On Thu, 22 Mar 2012 13:08:53 -0700 Leo Susanto wrote: > you should do > > print {$hdl} "a line\n"; > > instead of > > print $hdl "a line\n"; > Thanks for this. Didn't know that. Why is this required? It works also without {}. -- Manfred -- To unsubscribe, e-mail: beginners-unsubscr...@pe

Re: Why do I get a warning?

2012-03-22 Thread Manfred Lotz
On Thu, 22 Mar 2012 16:11:37 -0400 Michael Putch wrote: > On 3/22/2012 3:47 PM, Manfred Lotz wrote: > > Hi all, > > If I run the following small test snippet > > > > <--snip> > > #! /usr/bin/perl > >

Re: Why do I get a warning?

2012-03-22 Thread Manfred Lotz
On Thu, 22 Mar 2012 15:06:35 -0500 Chris Stinemetz wrote: > On Thu, Mar 22, 2012 at 2:47 PM, Manfred Lotz > wrote: > > Hi all, > > If I run the following small test snippet > > > > <--snip> > > #! /usr/bin

Why do I get a warning?

2012-03-22 Thread Manfred Lotz
Hi all, If I run the following small test snippet <--snip> #! /usr/bin/perl use strict; use warnings; use autodie; open my $hdl, ">", "fileio1.txt"; print $hdl "a line\n"; close $hdl; open HDL, ">", "fileio2.txt"; print HDL "a line\n"; close H

Re: Problem with $_

2012-03-04 Thread Manfred Lotz
On Sun, 04 Mar 2012 11:15:34 + Rob Dixon wrote: ... > > $_ is a package variable. You can fully-qualify it here and access it > as $main::_. > > Perl itself takes care of using $_ in foreach loops by localizing it > within every such loop. The problem is usually when it is implicitly > use

Re: Problem with $_

2012-03-04 Thread Manfred Lotz
Hi Timothy, Thanks for your reply. On Sun, 4 Mar 2012 10:52:04 +0100 timothy adigun <2teezp...@gmail.com> wrote: > Hi Manfred, > > On Sun, Mar 4, 2012 at 8:56 AM, Manfred Lotz > wrote: > > > Hi there, > > I've got a strange problem with $_. It seems I

Re: Problem with $_

2012-03-04 Thread Manfred Lotz
Hi Rob, Thanks for your reply. On Sun, 04 Mar 2012 09:50:07 + Rob Dixon wrote: > On 04/03/2012 07:56, Manfred Lotz wrote: ... > > > > Running this gives: > > > > Sub3: Issuing [uname -a] > > Linux hogwart 3.0.0-14-generic-pae #23~lucid1-Ubuntu SMP Thu Dec

Problem with $_

2012-03-04 Thread Manfred Lotz
Hi there, I've got a strange problem with $_. It seems I do not understand something which might be basic. Anyway, here is a minimal example. #! /usr/bin/perl use strict; use warnings; use 5.010; sub sub1 { my $cmd = shift; print "Sub3: Issuing [$cmd]\n"; open my $fh, '-|', "$cmd 2>&1" or

Re: run command from perl

2012-03-03 Thread Manfred Lotz
On 4 Mar 2012 05:03:55 - Peter Scott wrote: > On Fri, 02 Mar 2012 21:31:50 +0100, Manfred Lotz wrote: > > Another question I have: Where do I find what '-|' means? I mean the > > minus before the pipe char. > > perldoc -f open > > Thanks, fo

Re: run command from perl

2012-03-02 Thread Manfred Lotz
Hi Peter, Thanks for your reply. On 2 Mar 2012 02:48:28 - Peter Scott wrote: > > It doesn't have flaws. You could do it without the module with a > piped open: > > sub run_cmd > { > my $cmd = shift; > > open my $fh, '-|', "$cmd 2>&1" or die "open: $!"; > print while <$fh>; > clos

run command from perl

2012-02-26 Thread Manfred Lotz
Hi, I want to run a shell command with the following constraints: a. I like to get the return code of the command b. Furthermore I want to combine stdout and stderr so that the output comes in a natural sequence like in the shell. c. I don't want to capture the output in a variable (because the ou

Re: remove_tree question

2012-02-26 Thread Manfred Lotz
Hi Rob, On Sat, 25 Feb 2012 20:43:15 + Rob Dixon wrote: > On 25/02/2012 19:24, Manfred Lotz wrote: > > Hi all, > > I had a look at remove_tree from File::Path. > > > > Let us say I have a directory: ./a/b/c/d > > > > When I do > > > > re

remove_tree question

2012-02-25 Thread Manfred Lotz
Hi all, I had a look at remove_tree from File::Path. Let us say I have a directory: ./a/b/c/d When I do remove_tree('./a', { verbose => 1 }); I get the following messages: rmdir d rmdir c rmdir b rmdir ./a Is there a way to get nice messages like this: rmdir ./a/

Re: map usage

2012-02-20 Thread Manfred Lotz
On Mon, 20 Feb 2012 20:14:13 +0100 "Christian Walde" wrote: > On Mon, 20 Feb 2012 20:08:31 +0100, Manfred Lotz > wrote: > > > Hi there, > > > > I have a hash table where I want to do some action for each value in > > the hash table. > > >

Re: map usage

2012-02-20 Thread Manfred Lotz
On Mon, 20 Feb 2012 20:08:31 +0100 Manfred Lotz wrote: > Hi there, > > I have a hash table where I want to do some action for each value in > the hash table. > > > > Among other possibilities I could do like this: >map { some_action($_) } values %ht; >

map usage

2012-02-20 Thread Manfred Lotz
Hi there, I have a hash table where I want to do some action for each value in the hash table. Among other possibilities I could do like this: map { some_action($_) } values %ht; where let us say: sub some_action { ... return; } I like it because it is really short. Questions:

Re: How to evaluate a raw string?

2008-10-05 Thread Manfred Lotz
John W. Krahn wrote: Manfred Lotz wrote: Mr. Shawn H. Corey wrote: On Sun, 2008-10-05 at 16:54 +0200, Manfred Lotz wrote: my $DRYRUN="--dry-run"; my $cmd = q(rsync $DRYRUN -avh \ -exclude bla1 \ -exclude bla2 \ src tgtdir }; s

Re: How to evaluate a raw string?

2008-10-05 Thread Manfred Lotz
Mr. Shawn H. Corey wrote: On Sun, 2008-10-05 at 16:54 +0200, Manfred Lotz wrote: my $DRYRUN="--dry-run"; my $cmd = q(rsync $DRYRUN -avh \ -exclude bla1 \ -exclude bla2 \ src tgtdir }; system($cmd); my $Dry_Run = '

Re: How to evaluate a raw string?

2008-10-05 Thread Manfred Lotz
Dr.Ruud wrote: Manfred Lotz schreef: I like to specify a raw string, like for example $w: my $who = "my friend"; my $w = q(This is \n $who.); Now I want to evaluate that raw string so that the result is a string: This is my friend. eval doesn't seem to help. Actually I

How to evaluate a raw string?

2008-10-04 Thread Manfred Lotz
Hi all, I like to specify a raw string, like for example $w: my $who = "my friend"; my $w = q(This is \n $who.); Now I want to evaluate that raw string so that the result is a string: This is my friend. eval doesn't seem to help. Actually I want to be able to specify a raw string where at