[26741] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8826 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 4 21:05:35 2006

Date: Wed, 4 Jan 2006 18:05:07 -0800 (PST)
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, 4 Jan 2006     Volume: 10 Number: 8826

Today's topics:
        Are there alternatives to exec and system <NoSPam@NoSpam.com>
    Re: cut -c18-31,49-51 in perl? (Anno Siegel)
    Re: cut -c18-31,49-51 in perl? <abigail@abigail.nl>
    Re: cut -c18-31,49-51 in perl? <rvtol+news@isolution.nl>
    Re: cut -c18-31,49-51 in perl? <jkcohen@pobox.com>
    Re: cut -c18-31,49-51 in perl? xhoster@gmail.com
        How to create a coderef from an object-method? (Bruno Boettcher)
        IO::HANDLE install error <kigar@gmx.net>
    Re: IO::HANDLE install error <andy@andyh.co.uk>
    Re: output of system() call <abigail@abigail.nl>
    Re: output of system() call <tadmc@augustmail.com>
        SSH Error <kigar@gmx.net>
    Re: SSH Error <penryu@saiyix.ath.cx>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 4 Jan 2006 19:31:37 -0500
From: "Daniel Kaplan" <NoSPam@NoSpam.com>
Subject: Are there alternatives to exec and system
Message-Id: <1136421097.690643@nntp.acecape.com>

I would like one of my Perl scripts to "spawn" another Perl script.

However it seems that with exec()  my calling app stops running and 
everything goes to the script I exec'd.  And that system() freezes my 
calling app and it waits for the new app to complete and return.

Is there a function in Perl that let's me call a new app, and both apps 
(calling and the called) both just run completly independently of each 
other?

I was at best able to find that Win32 Perl had such a beast, but this is for 
my Linux machine.

Thanks ahead,

Daniel 




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

Date: 4 Jan 2006 20:05:43 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: cut -c18-31,49-51 in perl?
Message-Id: <dph9qn$6n8$1@mamenchi.zrz.TU-Berlin.DE>

Dan Jacobson  <jidanni@jidanni.org> wrote in comp.lang.perl.misc:
> $ perldoc -q cut #no help, so asking here.
> How do I emulate UNIX's "cut -c18-31,49-51"?
> Certainly there is no one-liner possible unless I express the ranges
> differently?

Here is a way to do it with unpack().  The relation between the cut
specification and the corresponding template for unpack is made explicit.
The code also demonstrates that "cut" with the original specification
and the same data produces the same output.

In a one-off case one would probably create the template '@17a14 @48a3'
once manually (well, as often as it takes to get it right), and make it
 a one-liner.

    my $template;                  # for unpack
    for ( [ 18, 31], [ 49, 51] ) { # "cut -c" specifications
        my ( $first, $last) = @$_; # "cut" counts from 1
        my $start = $first - 1;
        my $length = $last - $first + 1;
        $template .= ' ' if $template;
        $template .= '@' . $start . 'a' . $length;
    }
    print "template: $template\n";

    my $str;                       # collect DATA to feed into cut command
    while ( <DATA> ) {
        $str .= $_;
        print unpack( $template, $_), "\n";
    }
    print "\n";

    open my $cut, '| cut -c18-31,49-51';
    print $cut $str;


    __DATA__
    0000000000111111111122222222223333333333444444444455555555556666666666
    0123456789012345678901234567890123456789012345678901234567890123456789

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: 04 Jan 2006 21:25:57 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: cut -c18-31,49-51 in perl?
Message-Id: <slrndrofb5.t9n.abigail@alexandra.abigail.nl>

Dan Jacobson (jidanni@jidanni.org) wrote on MMMMDIX September MCMXCIII in
<URL:news:87irszdh3b.fsf@jidanni.org>:
 ..  $ perldoc -q cut #no help, so asking here.
 ..  How do I emulate UNIX's "cut -c18-31,49-51"?
 ..  Certainly there is no one-liner possible unless I express the ranges
 ..  differently?


I'd use 'system' to call 'cut', but that's just me I guess.



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: Thu, 5 Jan 2006 00:01:38 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: cut -c18-31,49-51 in perl?
Message-Id: <dpho2c.ho.1@news.isolution.nl>

Abigail:
> Dan Jacobson:

>> How do I emulate UNIX's "cut -c18-31,49-51"?
> 
> I'd use 'system' to call 'cut', but that's just me I guess.

Yeah, why emulate if you should have the real thing.
;)

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: Wed, 04 Jan 2006 16:13:37 -0800
From: "Jonathan K. Cohen" <jkcohen@pobox.com>
Subject: Re: cut -c18-31,49-51 in perl?
Message-Id: <CvZuf.6856$JT.3052@fed1read06>

Dan Jacobson wrote:
> $ perldoc -q cut #no help, so asking here.
> How do I emulate UNIX's "cut -c18-31,49-51"?
> Certainly there is no one-liner possible unless I express the ranges
> differently?

One-liners are possible. OTOH, you could always use the multi-line
implementations from Tom Christiansen's old PPT project:

http://ppt.perl.org/commands/cut/cut.lafferty
http://ppt.perl.org/commands/cut/cut.hewgill

Jonathan


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

Date: 05 Jan 2006 00:14:19 GMT
From: xhoster@gmail.com
Subject: Re: cut -c18-31,49-51 in perl?
Message-Id: <20060104191419.907$9o@newsreader.com>

Abigail <abigail@abigail.nl> wrote:
> Dan Jacobson (jidanni@jidanni.org) wrote on MMMMDIX September MCMXCIII in
> <URL:news:87irszdh3b.fsf@jidanni.org>:
> ..  $ perldoc -q cut #no help, so asking here.
> ..  How do I emulate UNIX's "cut -c18-31,49-51"?
> ..  Certainly there is no one-liner possible unless I express the ranges
> ..  differently?
>
> I'd use 'system' to call 'cut', but that's just me I guess.

It's not just you.  I would too, in many situations. (Although in practise
I'd be more likely to use a pipe open, rather than system, to do it).

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 04 Jan 2006 20:47:42 GMT
From: bboett@bboett.dyndns.org (Bruno Boettcher)
Subject: How to create a coderef from an object-method?
Message-Id: <43bc346e$0$19914$626a54ce@news.free.fr>


Hello!

i am having trouble writing a script for xchat...

that thing has a method to add new commands or handlers, and that method
uses coderefs....

now i have created an object with several methods, and i have a table
with the commands to add to the client, and now i am trying to find the
syntax to do this....


here you can see the different tries i made so far:

foreach my $cmd (keys(%$commands))
{
  #my $funcref =  \&{$this->{"leve"}->($commands->{$cmd})};
  #my $funcref =  \&Leve::($commands->{$cmd});
  #my $funcref =  eval("\&{".$this->{"leve"}."->".$commands->{$cmd}."}");
  #my $funcref =  eval("\&{Leve::".$commands->{$cmd}."}");
  my $funcref =  eval("sub { ".$this->{"leve"}."->".$commands->{$cmd}."(@_);}");
  Xchat::hook_command("l".$cmd, $funcref);
  Xchat::print("added command handler l".$cmd." calling back on $funcref");
}#foreach my $cmd (keys(%$commands))

the version with the anon sub would be the most interesting, since that
would preserve the OO design, passing the reference of the object along
the call....

but this dooesn't seem to work... the $funcref is empty in this last
case, and none of them work....

problem is that all the cases depicted in the docu are very simple
structures.... nothing composite is ever used as an example... so i am
quite clueless here....

what would be the best way to achieve this?

thanks for any help

-- 
ciao bboett
==============================================================
bboett@adlp.org
http://inforezo.u-strasbg.fr/~bboett


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

Date: Wed, 4 Jan 2006 20:49:27 +0100
From: "Reinhard Glauber" <kigar@gmx.net>
Subject: IO::HANDLE install error
Message-Id: <43bc2721$0$26909$9b4e6d93@newsread4.arcor-online.net>

SSdtIHRyeWluZyB0byBpbnN0YWxsIElPOjpoYW5kbGUgdW5kZXIgQ3lnd2luIG9uIGEgV2luZG93
cyBQbGF0Zm9ybUkndmUgaW5zdGFsbGVkIHNldmVyYWwgb3RoZXIgTW9kdWxlcyB3aXRob3V0IFBy
b2JsZW0sIGJ1dCB0aGlzIG9uZWdpdmVzIG1lIGEgaGVhZGFjaGUgOihBbnkgaWRlYSA/VGhhbmtz
cGVybCAtTUNQQU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3BlcmxfaW5z
dGFsbF0gRXJyb3IgMTMgIC91c3IvYmluL21ha2UgaW5zdGFsbCAgLS0gTk9UIE9L



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

Date: Thu, 05 Jan 2006 00:31:42 +0000
From: Andy Hassall <andy@andyh.co.uk>
Subject: Re: IO::HANDLE install error
Message-Id: <i1qor1h6k1mvm51kllnht75ulf2k1j4m76@4ax.com>

On Wed, 4 Jan 2006 20:49:27 +0100, "Reinhard Glauber" <kigar@gmx.net> wrote:

>I'm trying to install IO::handle under Cygwin on a Windows PlatformI've installed several other Modules without Problem, but this onegives me a headache :(Any idea ?Thanksperl -MCPAN -e shellinstall IO::HandleRunning make test/usr/bin/perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.tt/IO...............okt/io_const.........okt/io_dir...........okt/io_dup...........okt/io_file..........okt/io_linenum.......okt/io_multihomed....okt/io_pipe..........okt/io_poll..........okt/io_sel...........okt/io_sock..........okt/io_taint.........okt/io_tell..........okt/io_udp...........okt/io_unix..........okt/io_utf8..........okt/io_xs............okAll tests successful.Files=17, Tests=172, 28 wallclock secs ( 3.75 cusr +  2.13 csys =  5.87 CPU)  /usr/bin/make test -- OKRunning make installCannot forceunlink /usr/lib/perl5/5.8/cygwin/auto/IO/IO.dll: Permission denied at /usr/lib/perl5/5.8/File/Find.pm line 907make: *** [pure_perl_install] Error 13
/usr/bin/make
>install  -- NOT OK

 You can't use CPAN to install File::Find under Cygwin, because CPAN itself
uses File::Find, and the locking semantics of Windows filesystems means you
can't overwrite an in-use file.

 You have to install it manually - you can use the cpan shell to fetch it with
"get File::Find", then exit that and do the usual "perl Makefile.PL && make &&
make test && make install" to install it.

-- 
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool


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

Date: 04 Jan 2006 21:28:18 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: output of system() call
Message-Id: <slrndroffi.t9n.abigail@alexandra.abigail.nl>

Madhu Ramachandran (madhuram@nortel.com) wrote on MMMMDIX September
MCMXCIII in <URL:news:dpgqj6$1h1$1@zcars129.ca.nortel.com>:
:)  question.
:)  
:)  i am perl newbie. i read that system() call  can be used to invoke other 
:)  program (shell scripts etc). The return code of the program is returned by 
:)  system() call and i have to >> by 8 bits.
:)  
:)  is there any variable which will contain ouput printed by the program in 
:)  system() call?

Well, if there is, it would be documented in the manual page, wouldn't?
Did you check the manual page? Did it say you can you capture the output
of an command?



Abigail
-- 
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
          q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'


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

Date: Wed, 4 Jan 2006 18:09:08 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: output of system() call
Message-Id: <slrndroot4.5da.tadmc@magna.augustmail.com>

Madhu Ramachandran <madhuram@nortel.com> wrote:


> question.


You put that in there to distinguish from the many posts here
that do not ask a question?


> i am perl newbie. 


You really should see the Posting Guidelines you know.


> i read 


Where did you read it?

In the documentation for the software that you are using?


> that system() call  can be used to invoke other 
> program

> is there any variable which will contain ouput printed by the program in 
> system() call?


No, but there is a way to capture the output printed by the program
into a variable using something other than the system() function.


> how can i capture the 'bla' value, using 
> the system() call?


You can't.

You'll have to use something other than the system() function.


> wondering if there is an easier way to get output.


Yes there is, and it is included in the documentation for the
system() function that you already know about.

Why didn't you read the documentation for the function you are using?


By now you have used up all of your coupons...

So long!


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 4 Jan 2006 22:06:09 +0100
From: "Reinhard Glauber" <kigar@gmx.net>
Subject: SSH Error
Message-Id: <43bc38c1$0$7400$9b4e6d93@newsread2.arcor-online.net>

ZG9lcyBhbnlvbmUga25vdyB3aGF0IHBhY2tldCB0eXBlIDIwIG9yIDMgaXMgPw0KdGhhbmtzDQoN
CkZlaGxlciAtIFByb3RvY29sIGVycm9yOiBleHBlY3RlZCBwYWNrZXQgdHlwZSAyMCwgZ290IDMg
YXQgL3Vzci9saWIvcGVybDUvc2l0ZV9wDQplcmwvNS44L05ldC9TU0gvUGVybC9QYWNrZXQucG0g
bGluZSAyMjE=



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

Date: Wed, 04 Jan 2006 21:16:12 GMT
From: Tim Hammerquist <penryu@saiyix.ath.cx>
Subject: Re: SSH Error
Message-Id: <slrndroeos.24og.penryu@haruko.saiyix>

Reinhard Glauber <kigar@gmx.net> wrote:
> does anyone know what packet type 20 or 3 is ?
> thanks
>
> Fehler - Protocol error: expected packet type 20, got 3 at
> /usr/lib/perl5/site_p

Can you post the relevant perl code?

Cheers,
Tim Hammerquist


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

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 V10 Issue 8826
***************************************


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