[31347] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2592 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 9 21:09:47 2009

Date: Wed, 9 Sep 2009 18:09:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 9 Sep 2009     Volume: 11 Number: 2592

Today's topics:
        ANN: dh, the daemon helper 2009-09-04 <jak@isp2dial.com>
        FAQ 4.18 Does Perl have a Year 2000 problem? Is Perl Y2 <brian@theperlreview.com>
        How to extract a hash element into an array? <johnson@pharmacy.arizona.edu>
    Re: How to extract a hash element into an array? <uri@StemSystems.com>
    Re: How to extract a hash element into an array? <tadmc@seesig.invalid>
    Re: How to extract a hash element into an array? <tadmc@seesig.invalid>
    Re: How to extract a hash element into an array? <kst-u@mib.org>
    Re: How to extract a hash element into an array? <johnson@pharmacy.arizona.edu>
    Re: How to extract a hash element into an array? <uri@StemSystems.com>
    Re: How to extract a hash element into an array? <uri@StemSystems.com>
        is there a compact way to initialize this array? <DaLoveRhino@hotmail.com>
    Re: is there a compact way to initialize this array? <uri@StemSystems.com>
        keep getting time out on Net::Telnet->cmd in my perl sc <vikrantp@gmail.com>
    Re: keep getting time out on Net::Telnet->cmd in my per <vikrantp@gmail.com>
    Re: perl regex : surround tabbed numeric field by doubl sln@netherlands.com
    Re: perl regex : surround tabbed numeric field by doubl <source@netcom.com>
    Re: replace words <nat.k@gm.ml>
        samba-mounted directory, OS X, bash, 'system' calls <jfcampbell@aol.com>
    Re: samba-mounted directory, OS X, bash, 'system' calls <ben@morrow.me.uk>
    Re: samba-mounted directory, OS X, bash, 'system' calls <jfcampbell@aol.com>
        SIGUSR1 ignored during poll() if sleep() and warn() cal <alexander.farber@gmail.com>
    Re: split a big program into main + (optional) advanced <cartercc@gmail.com>
    Re: split a big program into main + (optional) advanced <jimsgibson@gmail.com>
    Re: Why does "$v = @ARGV[0]" work ? <nat.k@gm.ml>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 09 Sep 2009 23:37:44 +0000
From: John Kelly <jak@isp2dial.com>
Subject: ANN: dh, the daemon helper 2009-09-04
Message-Id: <shega59ngm7n0rad23h76qh0g812vppsq2@4ax.com>


dh, the daemon helper

The daemon helper starts any program or script as a daemon.  It's a
small C program with a simple interface and a liberal license.

ftp://ftp.isp2dial.com/users/jak/src/dh/

Get the files and do:

    make install clean

To build and install dh.  Don't try to run the Sh.install script
directly, it must be invoked using the Makefile.

I use dh for starting scripts which read fifos fed by syslog.  They
block on read until syslog provides data to work on.  They never end,
and need help to start as "daemons."

But that's just one example.  There are many other potential uses for
the daemon helper.

dh is its name; a natural companion to sh.

I use dh on Linux, but was curious about portability.  With some minor
changes, I compiled and installed it on NetBSD 5.0.1 x86.  So now it's
portable.  Wheee!

It's a cool tool, it reports problems encountered when trying to exec
the target daemon program or script.  Debian's start-stop-deamon can't
do that, nor can any other daemon tool I know of.

It's minimal, with only one command line option, -p.  Avoiding unneeded
bells and whistles was my intentional design.

In six months time, I could lose interest in computers, start a new
career, and the work would be lost forever.  Someone who likes C more
than I do should adopt dh and help it grow.

But if you do, don't believe what Stevens wrote about ignoring SIGHUP
before the second fork().  It's not true, so don't write voodoo code to
handle it!  See the thread in c.u.p with the subject "Orphaned process
groups, daemon startup, SIGHUP."

If you can't adopt dh, but have ideas for patches, send them.  But if I
don't respond, well then, you're on your own.

There is no man page for dh, but the README explains how to use it.

If there is enough interest, maybe someday I will give dh an official
version number and use some version control.  But for now, the date of
last modification is all there is.


-- 
Webmail for Dialup Users
http://www.isp2dial.com/freeaccounts.html
 


------------------------------

Date: Wed, 09 Sep 2009 22:00:06 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 4.18 Does Perl have a Year 2000 problem? Is Perl Y2K compliant?
Message-Id: <GzVpm.158226$cf6.40051@newsfe16.iad>

This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

4.18: Does Perl have a Year 2000 problem? Is Perl Y2K compliant?

    Short answer: No, Perl does not have a Year 2000 problem. Yes, Perl is
    Y2K compliant (whatever that means). The programmers you've hired to use
    it, however, probably are not.

    Long answer: The question belies a true understanding of the issue. Perl
    is just as Y2K compliant as your pencil--no more, and no less. Can you
    use your pencil to write a non-Y2K-compliant memo? Of course you can. Is
    that the pencil's fault? Of course it isn't.

    The date and time functions supplied with Perl (gmtime and localtime)
    supply adequate information to determine the year well beyond 2000 (2038
    is when trouble strikes for 32-bit machines). The year returned by these
    functions when used in a list context is the year minus 1900. For years
    between 1910 and 1999 this *happens* to be a 2-digit decimal number. To
    avoid the year 2000 problem simply do not treat the year as a 2-digit
    number. It isn't.

    When gmtime() and localtime() are used in scalar context they return a
    timestamp string that contains a fully-expanded year. For example,
    "$timestamp = gmtime(1005613200)" sets $timestamp to "Tue Nov 13
    01:00:00 2001". There's no year 2000 problem here.

    That doesn't mean that Perl can't be used to create non-Y2K compliant
    programs. It can. But so can your pencil. It's the fault of the user,
    not the language. At the risk of inflaming the NRA: "Perl doesn't break
    Y2K, people do." See http://www.perl.org/about/y2k.html for a longer
    exposition.



--------------------------------------------------------------------

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


------------------------------

Date: Wed, 9 Sep 2009 14:51:01 -0700 (PDT)
From: bleah <johnson@pharmacy.arizona.edu>
Subject: How to extract a hash element into an array?
Message-Id: <c5c09114-0fb9-436a-9549-4fc234001ae1@k13g2000prh.googlegroups.com>

I've got a hash, one element of which is an array (of file extensions,
but the exact data is irrelevant)

This is roughly what I want to do:

The hash is loaded with an array:

@arr = qw(jpg jpeg doc pdf gif boo yah baz);
$myhash{'allowed_types'} = @arr;


This code works, $myhash{'allowed_types'} now cpontains the array, and
if I do:

print $myhash{allowed_types}[3];

I get 'pdf' as expected.

This hash is passed as a cgi parameter to another script.

use CGI qw(:standard);
my (%upload_params) =$_;

This does in fact load the hash correctly

print $upload_params{allowed_types}[3];

Results in 'pdf'.

BUT I need the hash element %upload_params{'allowed_types'} back out
as an array, because I want to do:

$allowed = joint (' ',@allowed_types);
if ($allowed =~ $loaded_extension) {# Ok it's allowed, continue} else
{# not allowed, print error}

How do I get $myhash{'allowed_types'} stuffed back into
@allowed_types.


------------------------------

Date: Wed, 09 Sep 2009 18:19:13 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: How to extract a hash element into an array?
Message-Id: <87r5uf7oda.fsf@quad.sysarch.com>

>>>>> "b" == bleah  <johnson@pharmacy.arizona.edu> writes:

  b> I've got a hash, one element of which is an array (of file extensions,
  b> but the exact data is irrelevant)

  b> This is roughly what I want to do:

  b> The hash is loaded with an array:

  b> @arr = qw(jpg jpeg doc pdf gif boo yah baz);
  b> $myhash{'allowed_types'} = @arr;

that is incorrect. it assigns that array to the whole hash with the
array values alternating between keys and values.

  b> This code works, $myhash{'allowed_types'} now cpontains the array, and
  b> if I do:

  b> print $myhash{allowed_types}[3];

please show a complete example that does this. the output of this code
is an empty line:

perl -le  ' @arr = qw(jpg jpeg doc pdf gif boo yah baz); $myhash{'allowed_types'} = @arr; print $myhash{allowed_types}[3];'


  b> I get 'pdf' as expected.

then you didn't run the above code as you claim. 

  b> This hash is passed as a cgi parameter to another script.

  b> use CGI qw(:standard);
  b> my (%upload_params) =$_;

  b> This does in fact load the hash correctly

  b> print $upload_params{allowed_types}[3];

  b> Results in 'pdf'.

not according to the code you showed.

  b> BUT I need the hash element %upload_params{'allowed_types'} back out
  b> as an array, because I want to do:

  b> $allowed = joint (' ',@allowed_types);

you smoke joints, but it isn't a perl op. this tells me you are not
cutting/pasting real code and you are retyping it. this is why the above
code is wrong and it may work only in your programs but not in this
post. please always PASTE the code in question.

  b> if ($allowed =~ $loaded_extension) {# Ok it's allowed, continue} else
  b> {# not allowed, print error}

  b> How do I get $myhash{'allowed_types'} stuffed back into
  b> @allowed_types.

first off you need to make sure that array is properly assigned into the
hash as an array ref, not a list as your code above does. then you can
access it as you claim for its array members. to get the whole array you
need to dereference it:

	my @allowed_types = @{$myhash{'allowed_types'}} ;

read perldoc perlreftut, perllol and perldsc. then read perlref for the
complete story on references.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Wed, 09 Sep 2009 17:29:31 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: How to extract a hash element into an array?
Message-Id: <slrnhagacg.mfp.tadmc@tadmc30.sbcglobal.net>

Uri Guttman <uri@StemSystems.com> wrote:
>>>>>> "b" == bleah  <johnson@pharmacy.arizona.edu> writes:
>  b> The hash is loaded with an array:
>
>  b> @arr = qw(jpg jpeg doc pdf gif boo yah baz);
>  b> $myhash{'allowed_types'} = @arr;
>
> that is incorrect. it assigns that array to the whole hash with the
> array values alternating between keys and values.


That is incorrect too!

It assigns "8" to the hash element keyed by 'allowed_types'.


>  b> This code works, $myhash{'allowed_types'} now cpontains the array, and
>  b> if I do:
>
>  b> print $myhash{allowed_types}[3];
>
> please show a complete example that does this. the output of this code
> is an empty line:
>
> perl -le  ' @arr = qw(jpg jpeg doc pdf gif boo yah baz); $myhash{'allowed_types'} = @arr; print $myhash{allowed_types}[3];'


Note the output of this code:

    perl -le  ' @arr = qw(jpg jpeg doc pdf gif boo yah baz); $myhash{'allowed_types'} = @arr; print $myhash{allowed_types}'


:-)


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Wed, 09 Sep 2009 17:35:00 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: How to extract a hash element into an array?
Message-Id: <slrnhagamp.mfp.tadmc@tadmc30.sbcglobal.net>

bleah <johnson@pharmacy.arizona.edu> wrote:

> @arr = qw(jpg jpeg doc pdf gif boo yah baz);
> $myhash{'allowed_types'} = @arr;
>
>
> This code works,


Errr, no it doesn't.

Have you seen the Posting Guidelines that are posted here frequently?


> BUT I need the hash element %upload_params{'allowed_types'} back out
> as an array, because I want to do:
>
> $allowed = joint (' ',@allowed_types);


You do not need to stuff it into its own named array, you can
simply apply "Use Rule 1" from

    perldoc perlreftut

which I like to do in 3 steps:


1) pretend it is a plain array:

    $allowed = join ' ', @allowed_types;

2) replace the array *name* with a block:

    $allowed = join ' ', @{                        };

3) put something in the block that returns the right kind of
   a reference (to an array in this case):

    $allowed = join ' ', @{ $myhash{allowed_types} };


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Wed, 09 Sep 2009 15:42:19 -0700
From: Keith Thompson <kst-u@mib.org>
Subject: Re: How to extract a hash element into an array?
Message-Id: <lnfxavviyc.fsf@nuthaus.mib.org>

"Uri Guttman" <uri@StemSystems.com> writes:
>>>>>> "b" == bleah  <johnson@pharmacy.arizona.edu> writes:
>
>   b> I've got a hash, one element of which is an array (of file extensions,
>   b> but the exact data is irrelevant)
>
>   b> This is roughly what I want to do:
>
>   b> The hash is loaded with an array:
>
>   b> @arr = qw(jpg jpeg doc pdf gif boo yah baz);
>   b> $myhash{'allowed_types'} = @arr;
>
> that is incorrect. it assigns that array to the whole hash with the
> array values alternating between keys and values.

Did either of you actually try it?
    %myhash = @arr;
would do as you describe.
    $myhash{'allowed_types'} = @arr;

evalutes @arr in scalar context and assigns the result (8) to
$myhash{'allowed_types'}.

>   b> This code works, $myhash{'allowed_types'} now cpontains the array, and
>   b> if I do:
>
>   b> print $myhash{allowed_types}[3];

I suspect what the original poster actually did was

    $myhash{'allowed_types'} = \@arr;

which assigns a reference to the array (note that a reference is a scalar)
to $myhash{'allowed_types'}.  After that, $myhash{allowed_types}[3]
would indeed yield 'pdf'.  Note that
    $myhash{allowed_types}[3]
is a shorthand for
    $myhash{allowed_types}->[3]

[...]

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"


------------------------------

Date: Wed, 9 Sep 2009 16:34:17 -0700 (PDT)
From: bleah <johnson@pharmacy.arizona.edu>
Subject: Re: How to extract a hash element into an array?
Message-Id: <9c4eeb2d-9565-4d03-b516-96c855fa5656@y10g2000prf.googlegroups.com>

On Sep 9, 3:42=A0pm, Keith Thompson <ks...@mib.org> wrote:


> I suspect what the original poster actually did was
>
> =A0 =A0 $myhash{'allowed_types'} =3D \@arr;
>
> which assigns a reference to the array (note that a reference is a scalar=
)
> to $myhash{'allowed_types'}. =A0After that, $myhash{allowed_types}[3]
> would indeed yield 'pdf'. =A0Note that
> =A0 =A0 $myhash{allowed_types}[3]
> is a shorthand for
> =A0 =A0 $myhash{allowed_types}->[3]
>

You are correct. A typo in my example.



------------------------------

Date: Wed, 09 Sep 2009 19:41:51 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: How to extract a hash element into an array?
Message-Id: <87bplj7kjk.fsf@quad.sysarch.com>

>>>>> "KT" == Keith Thompson <kst-u@mib.org> writes:

  KT> "Uri Guttman" <uri@StemSystems.com> writes:
  >>>>>>> "b" == bleah  <johnson@pharmacy.arizona.edu> writes:
  >> 
  b> I've got a hash, one element of which is an array (of file extensions,
  b> but the exact data is irrelevant)
  >> 
  b> This is roughly what I want to do:
  >> 
  b> The hash is loaded with an array:
  >> 
  b> @arr = qw(jpg jpeg doc pdf gif boo yah baz);
  b> $myhash{'allowed_types'} = @arr;
  >> 
  >> that is incorrect. it assigns that array to the whole hash with the
  >> array values alternating between keys and values.

  KT> Did either of you actually try it?
  KT>     %myhash = @arr;
  KT> would do as you describe.
  KT>     $myhash{'allowed_types'} = @arr;

yeah, my bad. but i saw the OP's mistake. i was posting too quickly and
had assigning arrays on my mind so i didn't see the count in scalar
context.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Wed, 09 Sep 2009 19:42:33 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: How to extract a hash element into an array?
Message-Id: <877hw77kie.fsf@quad.sysarch.com>

>>>>> "b" == bleah  <johnson@pharmacy.arizona.edu> writes:

  b> On Sep 9, 3:42 pm, Keith Thompson <ks...@mib.org> wrote:
  >> I suspect what the original poster actually did was
  >> 
  >>     $myhash{'allowed_types'} = \@arr;
  >> 
  >> which assigns a reference to the array (note that a reference is a scalar)
  >> to $myhash{'allowed_types'}.  After that, $myhash{allowed_types}[3]
  >> would indeed yield 'pdf'.  Note that
  >>     $myhash{allowed_types}[3]
  >> is a shorthand for
  >>     $myhash{allowed_types}->[3]
  >> 

  b> You are correct. A typo in my example.

so i was right about retyping. don't do that! always cut/paste code so
typos aren't part of the equation.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Wed, 9 Sep 2009 11:46:02 -0700 (PDT)
From: DaLoverhino <DaLoveRhino@hotmail.com>
Subject: is there a compact way to initialize this array?
Message-Id: <bb0d781a-20dd-48f4-9691-c772be9b5766@o36g2000vbl.googlegroups.com>

I want to initialize an array with 100 empty strings.

I can use a loop, but is there a more compact way to do so?

thanks.


------------------------------

Date: Wed, 09 Sep 2009 14:53:51 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: is there a compact way to initialize this array?
Message-Id: <87tyzc7xvk.fsf@quad.sysarch.com>

>>>>> "D" == DaLoverhino  <DaLoveRhino@hotmail.com> writes:

  D> I want to initialize an array with 100 empty strings.
  D> I can use a loop, but is there a more compact way to do so?

my @empty = ('') x 100 ;

and you likely don't need to do that if you are appending text as each
entry will autovivify. .= works cleanly and quietly (no warnings) on
undef values.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Wed, 9 Sep 2009 13:18:22 -0700 (PDT)
From: Vic <vikrantp@gmail.com>
Subject: keep getting time out on Net::Telnet->cmd in my perl script
Message-Id: <c7f3d674-8044-4b4e-88ec-2a7cec05e0bd@o9g2000prg.googlegroups.com>

I've a perl script which tries to telnet into a server and then
execute a few command
Here is my code

sub AgaBringDown {
    my ($GVHOME,$Server) = @_;
    my $string;
    my @lines;

    ### Seting  up the GVHOME
    #$ENV{'GVHOME'}  = $GVHOME;
    my $username = 'vpatanka';
    my $passwd = 'gen2boyS2';
    my $t = new Net::Telnet (Timeout => 10, Prompt => '/login: $/i');
    $t->open("$Server");
    $t->waitfor('/login: $/i');
    $t->print($username);
    $t->waitfor('/password: $/i');
    $t->print($passwd);

     $string = "setenv GVHOME $GVHOME";
      my $temp = $t->cmd($string);
}

As I mentioned I keep getting error on the last line
command timed-out at ConfigurationSetup.pl line 270
 at /usr/local/geneva/perl/lib/site_perl/5.8.8/Net/Telnet.pm line 2036
        Net::Telnet::_croak('Net::Telnet=GLOB(0x879538)', 'command
timed-out') called at /usr/local/geneva/perl/lib/site_perl/5.8.8/Net/
Telnet.pm line 539
        Net::Telnet::error('Net::Telnet=GLOB(0x879538)', 'command
timed-out') called at /usr/local/geneva/perl/lib/site_perl/5.8.8/Net/
Telnet.pm line 361
        Net::Telnet::cmd('Net::Telnet=GLOB(0x879538)', 'setenv GVHOME /
home/vpatanka/800currentSAGAV2_P') called at ConfigurationSetup.pl
line 270
        main::AgaBringDown('/home/vpatanka/800currentSAGAV2_P',
'nemo') called at ConfigurationSetup.pl line 190
        main::SetupConfig() called at ConfigurationSetup.pl line 123
        main::SetupData() called at ConfigurationSetup.pl line 29

If I login manually in telnet with the same steps it works fine.
Please help. thanks


------------------------------

Date: Wed, 9 Sep 2009 16:23:34 -0700 (PDT)
From: Vic <vikrantp@gmail.com>
Subject: Re: keep getting time out on Net::Telnet->cmd in my perl script
Message-Id: <811104e5-58c2-45f6-948e-6bf95ac3a837@13g2000prl.googlegroups.com>

On Sep 9, 1:18=A0pm, Vic <vikra...@gmail.com> wrote:
> I've a perl script which tries to telnet into a server and then
> execute a few command
> Here is my code
>
> sub AgaBringDown {
> =A0 =A0 my ($GVHOME,$Server) =3D @_;
> =A0 =A0 my $string;
> =A0 =A0 my @lines;
>
> =A0 =A0 ### Seting =A0up the GVHOME
> =A0 =A0 #$ENV{'GVHOME'} =A0=3D $GVHOME;
> =A0 =A0 my $username =3D 'vpatanka';
> =A0 =A0 my $passwd =3D 'gen2boyS2';
> =A0 =A0 my $t =3D new Net::Telnet (Timeout =3D> 10, Prompt =3D> '/login: =
$/i');
> =A0 =A0 $t->open("$Server");
> =A0 =A0 $t->waitfor('/login: $/i');
> =A0 =A0 $t->print($username);
> =A0 =A0 $t->waitfor('/password: $/i');
> =A0 =A0 $t->print($passwd);
>
> =A0 =A0 =A0$string =3D "setenv GVHOME $GVHOME";
> =A0 =A0 =A0 my $temp =3D $t->cmd($string);
>
> }
>
> As I mentioned I keep getting error on the last line
> command timed-out at ConfigurationSetup.pl line 270
> =A0at /usr/local/geneva/perl/lib/site_perl/5.8.8/Net/Telnet.pm line 2036
> =A0 =A0 =A0 =A0 Net::Telnet::_croak('Net::Telnet=3DGLOB(0x879538)', 'comm=
and
> timed-out') called at /usr/local/geneva/perl/lib/site_perl/5.8.8/Net/
> Telnet.pm line 539
> =A0 =A0 =A0 =A0 Net::Telnet::error('Net::Telnet=3DGLOB(0x879538)', 'comma=
nd
> timed-out') called at /usr/local/geneva/perl/lib/site_perl/5.8.8/Net/
> Telnet.pm line 361
> =A0 =A0 =A0 =A0 Net::Telnet::cmd('Net::Telnet=3DGLOB(0x879538)', 'setenv =
GVHOME /
> home/vpatanka/800currentSAGAV2_P') called at ConfigurationSetup.pl
> line 270
> =A0 =A0 =A0 =A0 main::AgaBringDown('/home/vpatanka/800currentSAGAV2_P',
> 'nemo') called at ConfigurationSetup.pl line 190
> =A0 =A0 =A0 =A0 main::SetupConfig() called at ConfigurationSetup.pl line =
123
> =A0 =A0 =A0 =A0 main::SetupData() called at ConfigurationSetup.pl line 29
>
> If I login manually in telnet with the same steps it works fine.
> Please help. thanks

There was an issue with the prompt at the remote host. I got it fixed.
Thanks


------------------------------

Date: Wed, 09 Sep 2009 12:09:05 -0700
From: sln@netherlands.com
Subject: Re: perl regex : surround tabbed numeric field by double quotes
Message-Id: <nuufa5pdq505rn5f3r8kdq55hpv8stftm8@4ax.com>

On Wed, 9 Sep 2009 14:39:59 +0000 (UTC), toralf <toralf.foerster@gmx.de> wrote:

>I've a file containing tab separated values - most, but not all are
>quoted - and now I'm wondering how to substitute a non-quoted value like
><tab>20090807<tab> by sth. like <tab>"20090807"<tab>

You would have to do some complicated regex (possibly multiple regx's),
but that depends on the data sample in regards to quote's, newlines, or other
shapes it can have.
A simple way is to split on tab, fix up the value, the join it back together.
Its ugly though.

-sln
------------
use strict;
use warnings;

my @ar = (
qq{\n12345145\t\n36367\t"qfqqbv"\n\t"0987"\t"asdf"a"\n },
qq{\t"01234"\taaaa\t494848\t}
); 

for my $str (@ar) {
	my $newstring = join "<tab>", map {/^(\s*|)"*(.*?|)"*(\s*|)$/; $1.'"'.$2.'"'.$3 } split (/\t/,$str);
	print "-> $newstring\n\n";
}
__END__



------------------------------

Date: Wed, 09 Sep 2009 17:19:50 -0700
From: David Harmon <source@netcom.com>
Subject: Re: perl regex : surround tabbed numeric field by double quotes
Message-Id: <U-SdncdXIdDL2zXXnZ2dnUVZ_q2dnZ2d@earthlink.com>

On Wed, 09 Sep 2009 12:09:05 -0700 in comp.lang.perl.misc,
sln@netherlands.com wrote,

>   (\s*|)

Just in case \s* fails to match the empty string, eh?



------------------------------

Date: Wed, 09 Sep 2009 11:48:09 -0700
From: Nathan Keel <nat.k@gm.ml>
Subject: Re: replace words
Message-Id: <KLSpm.42550$Y83.6097@newsfe21.iad>

Uri Guttman wrote:

> but did the OP know? you were pathetically attempting to help him and
> you said nothing useful.

Get a life, weirdo.  Does it make you feel like a big man to try and
harass people on usenet?  Move on and grow up, troll boy.


------------------------------

Date: Wed, 9 Sep 2009 15:38:13 -0700 (PDT)
From: John <jfcampbell@aol.com>
Subject: samba-mounted directory, OS X, bash, 'system' calls
Message-Id: <180e1a2a-4d0f-4dc5-b858-f5878d736273@y21g2000yqn.googlegroups.com>

Have got a Perl script called from within a bash script.
Bash connects to a Samba share:

umount ~/Documents/bin/pdfs
mount -t smbfs //NAME:pass@server/SHARE ~/Documents/bin/pdfs

Then it calls this Perl script:

#!/usr/bin/perl -w
my $sourcedir="~/Documents/bin/pdfs";
print "sourcedir=$sourcedir\n";
system("ls",$sourcedir);

I get:

ls: ~/Documents/bin/pdfs: No such file or directory

However if I copy the path from the error message and paste it onto
the command line behind 'ls' [  ls ~/Documents/bin/pdfs ], then the
shell lists the directory.

In an earlier try, I mounted the Samba volume via the Mac GUI and
pointed the script to something like /Volumes/pdfs. In that case it
found the files I was looking for.

Since I want this to run on a crontab and can't count on the volume
being mounted in the middle of a random night, I wanted to script the
Samba connection. Since I couldn't count on the volume NOT being
mounted either, I begin by unmounting anything that might already be
at that point.


John Campbell








------------------------------

Date: Thu, 10 Sep 2009 00:04:30 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: samba-mounted directory, OS X, bash, 'system' calls
Message-Id: <usoln6-0k02.ln1@osiris.mauzo.dyndns.org>


Quoth John <jfcampbell@aol.com>:
> Have got a Perl script called from within a bash script.
> Bash connects to a Samba share:
> 
> umount ~/Documents/bin/pdfs
> mount -t smbfs //NAME:pass@server/SHARE ~/Documents/bin/pdfs
> 
> Then it calls this Perl script:
> 
> #!/usr/bin/perl -w
> my $sourcedir="~/Documents/bin/pdfs";
> print "sourcedir=$sourcedir\n";
> system("ls",$sourcedir);
> 
> I get:
> 
> ls: ~/Documents/bin/pdfs: No such file or directory
> 
> However if I copy the path from the error message and paste it onto
> the command line behind 'ls' [  ls ~/Documents/bin/pdfs ], then the
> shell lists the directory.

Your shell is expanding ~/Documents/bin/pdfs into something like
/Users/jfcampbell/Documents/bin/pdfs. Passing a list to system bypasses
the shell (normally a good thing) so ls ends up looking for a directory
called '~' under the current working directory.

You need to expand the '~'. The simplest way is probably

    $sourcedir =~ s/^~/$ENV{HOME}/;

though that won't respect the ~user/foo syntax. Another way would be

    $sourcedir = glob $sourcedir;

which will expand ~user but will also expand other wildcards like *. I
don't know of any module that will just expand ~user and leave wildcards
alone, but it would be a pretty simple function to write using getpwnam.

Ben



------------------------------

Date: Wed, 9 Sep 2009 17:48:06 -0700 (PDT)
From: John <jfcampbell@aol.com>
Subject: Re: samba-mounted directory, OS X, bash, 'system' calls
Message-Id: <e5e29034-dec6-49aa-b941-a9f5b1cfa86f@j19g2000vbp.googlegroups.com>

> Your shell is expanding ~/Documents/bin/pdfs into something like
> /Users/jfcampbell/Documents/bin/pdfs.
> You need to expand the '~'. The simplest way is probably
>
>     $sourcedir =~ s/^~/$ENV{HOME}/;

Or, I can spell out /Users/jfcampbell/Documents/bin/pdfs as a
constant.

Though I can't count on the Samba share being mounted all the time, I
can be reasonably sure the user name will be good for the life of the
script.

Thanks.


------------------------------

Date: Wed, 9 Sep 2009 16:07:12 -0700 (PDT)
From: "A. Farber" <alexander.farber@gmail.com>
Subject: SIGUSR1 ignored during poll() if sleep() and warn() called?
Message-Id: <34d50653-f67a-4515-abf9-3d1198ab715f@o9g2000yqj.googlegroups.com>

Hello,

I have a non-blocking server:

$SIG{PIPE} = $SIG{ALRM} = $SIG{HUP} = 'IGNORE';
$SIG{USR1} = $SIG{USR2} = sub { $Dump = 1; };
$SIG{TERM} = $SIG{INT}  = sub { $Quit = 1; };
 .....

sub dump {
        my $pkg = shift;

        print STDERR Dumper(\%Kids);
}

sub loop {
        my $pkg = shift;

        while (not $Quit) {
                if ($Dump) {
                        $Dump = undef;
                        Child->dump();
                        #User->dump();
                }

                if ($Poll->poll(TIMEOUT) < 0) {
                        warn "poll error: $!\n";
                        sleep(TIMEOUT);
                        next;
                }

                $pkg->add($httpSocket) if $Poll->events($httpSocket) &
POLLIN;
                $pkg->add($tcpSocket) if $Poll->events($tcpSocket) &
POLLIN;

                for my $child (values %Kids) {
                        my $fh = $child->{FH};
                        my $mask = $Poll->events($fh);

                        if ($mask & (POLLERR | POLLHUP)) {
                                $child->remove();
                        } elsif ($mask & POLLIN) {
                                $child->remove() unless $child->read
();
                        } elsif ($mask & POLLOUT) {
                                $child->remove() unless $child->write
();
                        }
                }
                # remove not responding users
                User->timeout();
        }
}

When I check for poll() return value as above,
then the Child->dump() isn't called when I send
a USR1 signal to my script. I only see:

   poll error: Interrupted system call

and the script continues. When I remove the "if",
warn() and sleep() and just call in void context

   $Poll->poll(TIMEOUT);

then Child->dump() is called as expected.

Why is it so, why isn't USR1 registered in the 1st case?

Do warn() or sleep() clear %!  and how could I workaround this?

Thank you
Alex

PS: I'm using:

This is perl, v5.10.0 built for i386-openbsd





------------------------------

Date: Wed, 9 Sep 2009 12:46:07 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: split a big program into main + (optional) advanced
Message-Id: <0dce130c-68ce-4bc3-81eb-0719822f67d7@t13g2000yqn.googlegroups.com>

On Sep 9, 11:49=A0am, Freddie <bruz...@gmail.com> wrote:
> I have a hotel managerial software that I wrote in perl-tk that I
> would split into 2

I'm not familiar with perl-tk, and (obviously) haven't seen your
software, so this might not track with what you are doing, but here's
my take on things.

If you're writing a front end to a database to be used as a
distributed application, I'd write it as a web app. Do everything on
the server side, and your clients need have nothing other than a
browser.

When you write a big app, break it into modules. That way, you can
modularize your SQL, your HTML, and so on. Your example shows an OO
style, and I don't do OO Perl, but something similar using a
functional interface would be like this, assuming an HTML.pm, a
BASIC.pm and an ADVANCED.pm:

#this is something that produces index.html, say, main.pl
use strict;
use warnings;
use CGI;
#print the http header
print "Content-type: text/html\n\n";
#create the page top
HTML::html_header();
#make a menu for the basic user
BASIC::make_menu();
#make a menu for the advanced user
ADVANCED::make_menu() if $user_license eq 'ADVANCED';
#create the page bottom
HTML::html_footer();
exit(0);

Since you are calling the fully qualified name including the package,
there isn't any need to use, require, or do anything.

CC




------------------------------

Date: Wed, 09 Sep 2009 17:08:10 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: split a big program into main + (optional) advanced
Message-Id: <090920091708107595%jimsgibson@gmail.com>

In article
<0dce130c-68ce-4bc3-81eb-0719822f67d7@t13g2000yqn.googlegroups.com>,
ccc31807 <cartercc@gmail.com> wrote:

> On Sep 9, 11:49 am, Freddie <bruz...@gmail.com> wrote:
> > I have a hotel managerial software that I wrote in perl-tk that I
> > would split into 2
> 
> I'm not familiar with perl-tk, and (obviously) haven't seen your
> software, so this might not track with what you are doing, but here's
> my take on things.
> 
> If you're writing a front end to a database to be used as a
> distributed application, I'd write it as a web app. Do everything on
> the server side, and your clients need have nothing other than a
> browser.
> 
> When you write a big app, break it into modules. That way, you can
> modularize your SQL, your HTML, and so on. Your example shows an OO
> style, and I don't do OO Perl, but something similar using a
> functional interface would be like this, assuming an HTML.pm, a
> BASIC.pm and an ADVANCED.pm:
> 
> #this is something that produces index.html, say, main.pl
> use strict;
> use warnings;
> use CGI;
> #print the http header
> print "Content-type: text/html\n\n";
> #create the page top
> HTML::html_header();
> #make a menu for the basic user
> BASIC::make_menu();
> #make a menu for the advanced user
> ADVANCED::make_menu() if $user_license eq 'ADVANCED';
> #create the page bottom
> HTML::html_footer();
> exit(0);
> 
> Since you are calling the fully qualified name including the package,
> there isn't any need to use, require, or do anything.

How will the Perl compiler know to include the source files HTML.pm,
etc., if you do not have a use, require, or do statement referring to
those files in your program?


% perl ccc.pl
Content-type: text/html

Undefined subroutine &HTML::html_header called at ccc.pl line 7.

-- 
Jim Gibson


------------------------------

Date: Wed, 09 Sep 2009 11:47:13 -0700
From: Nathan Keel <nat.k@gm.ml>
Subject: Re: Why does "$v = @ARGV[0]" work ?
Message-Id: <SKSpm.42549$Y83.33521@newsfe21.iad>

Uri Guttman wrote:

> your answer was useless.

Ugh, *you* are useless.  Move on and bug someone else.


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 2592
***************************************


home help back first fref pref prev next nref lref last post