[24480] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6662 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 7 21:06:01 2004

Date: Mon, 7 Jun 2004 18:05:08 -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           Mon, 7 Jun 2004     Volume: 10 Number: 6662

Today's topics:
        call win32 API from linux perl script (broutard)
    Re: call win32 API from linux perl script <usenet@morrow.me.uk>
    Re: Cute bit of Perl to Assign $1,$2 to named variables <jboes@qtm.net>
    Re: Do you ever use awk? <rwxr-xr-x@gmx.de>
    Re: Do you ever use awk? <usenet@morrow.me.uk>
    Re: Do you ever use awk? <jeffrey.schwab@comcast.net>
    Re: grab output shell <Joe.Smith@inwap.com>
    Re: Need constant screen with periodic updates (Randal L. Schwartz)
    Re: Need constant screen with periodic updates <nospam@bigpond.com>
    Re: Need constant screen with periodic updates <usenet@morrow.me.uk>
        Need help installing WWW-Search-Ebay-2.193 Module... <grizelda_bone@yahool.com>
    Re: Need help installing WWW-Search-Ebay-2.193 Module.. <usenet@morrow.me.uk>
    Re: Need help installing WWW-Search-Ebay-2.193 Module.. <grizelda_bone@yahool.com>
        Need help running shell commands (jm)
    Re: Need help running shell commands <usenet@morrow.me.uk>
    Re: Need help running shell commands <invalid-email@rochester.rr.com>
    Re: Need help running shell commands <usenet@morrow.me.uk>
    Re: Need help running shell commands <nospam@bigpond.com>
    Re: No-install Perl Interpretor <nospam@bigpond.com>
    Re: No-install Perl Interpretor (Malcolm Dew-Jones)
    Re: perl and assembly <nospam@nspam.net>
    Re: perl and assembly <usenet@morrow.me.uk>
    Re: perl and assembly <Joe.Smith@inwap.com>
    Re: perl and assembly <jurgenex@hotmail.com>
        Print a section of a text file. (Prabh)
    Re: Print a section of a text file. <noreply@gunnar.cc>
    Re: Print a section of a text file. <ittyspam@yahoo.com>
    Re: Print a section of a text file. <usenet@morrow.me.uk>
    Re: syntax  $_[0] <tadmc@augustmail.com>
    Re: syntax  $_[0] <usenet@morrow.me.uk>
    Re: why can't I hang a "shift" on the front of this sta <Joe.Smith@inwap.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 7 Jun 2004 16:02:22 -0700
From: broutaf@yahoo.fr (broutard)
Subject: call win32 API from linux perl script
Message-Id: <78902b37.0406071502.435e9aa7@posting.google.com>

Hi,

I'm must calling an API from a remote win32 server in a perl script.
On a windows server, I use win32::OLE and it's work fine !

But my perl script must run on a linux server and must call this win32 API !
Apparently, it's impossible to install win32::OLE on linux.

So, how can i do ??


Thanks


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

Date: Tue, 8 Jun 2004 00:39:25 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: call win32 API from linux perl script
Message-Id: <ca31rt$gt1$1@wisteria.csv.warwick.ac.uk>


Quoth broutaf@yahoo.fr (broutard):
> 
> I'm must calling an API from a remote win32 server in a perl script.
> On a windows server, I use win32::OLE and it's work fine !
> 
> But my perl script must run on a linux server and must call this win32 API !
> Apparently, it's impossible to install win32::OLE on linux.
> 
> So, how can i do ??

AFAIK COM+ automation (OLE) doesn't allow you to interact with an object
on another machine, so you would have the same problem calling an OLE
function on one windows machine from another. What you need to do is set
up a perl script that is always running on the Win32 machine, waiting
for connections; then, when it receives one, it makes the OLE call and
passes the results back to the other end. 

This sort of setup is called 'RPC' for 'Remote Procedure Call' and there
are modules on CPAN which will handle both ends for you, for a variety
of standard protocols. Try starting with RPC::Simple or XMLRPC::Lite.
If none of these will fit your needs, for whatever reason, you will need
to design your own protocol and implement a server for the Win32 box and
a client for the linux box. Getting this sort of design right is not the
easiest thing in the world, though, so you would be better off using one
of the standard modules if you can.

Ben

-- 
perl -e'print map {/.(.)/s} sort unpack "a2"x26, pack "N"x13,
qw/1632265075 1651865445 1685354798 1696626283 1752131169 1769237618
1801808488 1830841936 1886550130 1914728293 1936225377 1969451372
2047502190/'                                                 # ben@morrow.me.uk


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

Date: Mon, 07 Jun 2004 18:37:31 GMT
From: Jeff Boes <jboes@qtm.net>
Subject: Re: Cute bit of Perl to Assign $1,$2 to named variables
Message-Id: <fea2f1890a2e735cf479b41096467b51@news.teranews.com>

Michele Dondi wrote:
> On 6 Jun 2004 11:08:30 -0700, david@tvis.co.uk (zzapper) wrote:
> 
>>I don't find taking a bit of flak, in any case a few more people know
>>about this particular feature of Perl than did before. Someone with no
>>posting rights emailed me to say  that though he thought himself
>>experienced, he hadn't known about this feature.
> 
>               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> As of my other post, I'd consider *that* the astonishing bit of your
> "discovery"... (no offense intended, sincerely!)
> 
> 
>>Thanx to Gnari for explaining that is was only a special case for $_
> 
> 
> Again, how is it possible that you had overlooked that for so many
> years?!?
> 

Easy. TMTOWTDI, y'know. Someone can be a Perl programmer without knowing 
each of the dozen WTDI. Are they the best possible Perl programmer they 
could be? No, but maybe that's not the only facet of their job. Lots of 
us out here in the Real World learn one, maybe two ways to do something, 
and then the boss hands us a new pile of work that doesn't involve the 
same task, so we never learn ways #3-99.

About half of my work is in Perl, and half in SQL. I'm still learning 
stuff in each arena, 15 years after first encountering SQL, and 8 years 
after my first "Hello, world" in Perl.

I wholeheartedly agree with other posters in this thread: someone goes, 
"Hey, look what I found!", and three people jump down his throat saying, 
"You idjit, that's been there since Larry Wall was in short pants!"

Boy, *there's* a way to stifle enthusiasm. It wouldn't take 17 instances 
of this before I'd stop coming here with my "Hey, look what I found!" 
notes. And then if I ever *do* find something that no one's ever seen, 
how likely would it be that anyone else would ever see it?

Sure, someone's going to post things like:

   $a += 1;   # Wow, I can do this!

but instead of whacking them on top of the head with a rolled up 
newspaper, you could (a) ignore them or (b) point out that all of these 
are possible, too:

   $a *= 3;
   $a .= " cats";
   $a &= 7;

I'd choose (b), because the OP learns something, and I'd get to stroke 
my ego about how much more I know about Perl than the OP.

Damned anti-social grumps.

P.S.: I find it amusing that the OP's signature included:

> 
> vim -c ":%s.^.CyrnfrTfcbafbeROenzSZbbyranne.|:%s/[R-T]/ /Ig|:normal ggVGg?"
> 
> http://www.vim.org/tips/tip.php?tip_id=305  Best of Vim Tips


Sure enough, [s]he's a Vim expert. Now, I don't know enough about Vim to 
  get out of it back to a shell prompt. I hope that if I ever have to 
learn it, I can learn it from the OP. And that if I post something dull 
and old-hat on the equivalent Vim newsgroup, I suspect the OP will have 
the grace to deal with me in a way quite unlike the way this thread 
started out.

-- 
(Posted from an account used as a SPAM dump. If you really want to get
in touch with me, dump the 'jboes' and substitute 'mur'.)
________
Jeffery Boes <>< jboes@qtm.net


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

Date: 7 Jun 2004 21:38:30 GMT
From: Lukas Mai <rwxr-xr-x@gmx.de>
Subject: Re: Do you ever use awk?
Message-Id: <ca2n8m$rha$1@wsc10.lrz-muenchen.de>

ctcgag@hotmail.com schrob:
[...]
> If anything, I now use awk even more, and more proficiently. (Some places
> the Perl docs will compare some feature to awk, things that I never knew
> awk could do in the first place.  But now that I know, I use it.).

> But mostly I still use it for getting a few columns.  I find that with
> Perl I often forget either the 'l' or the 'n' in -lnae, or I forget that
> 'a' splits into @F, not @_ or @a, or forget that the 'e' has to be last
> switch in the switch list.  It is easier to get awk right on the first try,
> for me.

Minor nit: '-e' doesn't have to be the last switch.

perl -e 'your program here' -lna
works just fine.

HTH, Lukas
-- 
#!/bin/bash
echo -e \\37\\136 | cat -v


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

Date: Mon, 7 Jun 2004 21:47:11 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Do you ever use awk?
Message-Id: <ca2nov$a9f$2@wisteria.csv.warwick.ac.uk>


Quoth Lukas Mai <rwxr-xr-x@gmx.de>:
> ctcgag@hotmail.com schrob:
> [...]
> > If anything, I now use awk even more, and more proficiently. (Some places
> > the Perl docs will compare some feature to awk, things that I never knew
> > awk could do in the first place.  But now that I know, I use it.).
> 
> > But mostly I still use it for getting a few columns.  I find that with
> > Perl I often forget either the 'l' or the 'n' in -lnae, or I forget that
> > 'a' splits into @F, not @_ or @a, or forget that the 'e' has to be last
> > switch in the switch list.  It is easier to get awk right on the first try,
> > for me.
> 
> Minor nit: '-e' doesn't have to be the last switch.

It has to be the last in any given group, which is Xho's problem.

perl -lena'program'

doesn't work at all.

Ben

-- 
                Outside of a dog, a book is a man's best friend.
                Inside of a dog, it's too dark to read.
ben@morrow.me.uk                                                  Groucho Marx


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

Date: Mon, 07 Jun 2004 18:52:43 -0400
From: Jeff Schwab <jeffrey.schwab@comcast.net>
Subject: Re: Do you ever use awk?
Message-Id: <TIWdnfuL_L8-bFndRVn-gw@comcast.com>

Michal Jaegermann wrote:
> Jeff Schwab <jeffrey.schwab@comcast.net> wrote:
> 
>>>Do people proficient in Perl have any use for awk/gawk anymore?
>>>Are there things that you still prefer to do using awk/gawk over
>>>perl?
>>
>>I use awk occasionally for pulling particular columns out of a sequence 
>>of records, e.g. awk '{ print $3 }' to get the third entry on each line 
>>of a file.
> 
> 
> For that "complicated" usage you do not need awk at all (or perl for
> that matter)
> 
> while read a b c d ; do echo $c ; done < my_file

The awk approach isn't "complicated," but what you wrote is getting there.

> A "fancier" /bin/sh solution employs a function which does 'echo $3' or
> 'shift $1 ; echo $1' if a column you want has a number higher than 9 and
> you are passing a desired column number as the first argument.

Thanks, but I try to avoid "fancier" solutions. :)


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

Date: Mon, 07 Jun 2004 19:40:54 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: grab output shell
Message-Id: <ax3xc.18155$Sw.2002@attbi_s51>

Andrea Spitaleri wrote:

> how do I grab the output from shell after system?

You can't, without external help, as you have discovered.

For non-interactive programs where you can wait for the
program to finish first, grab the output from qx().

For processing the results as they come in,
   open my $pipe, '-|', 'rasmol';

For interactive programs, let Expect.pm open a pty for you.

> system "rasmol > out ";

If the program sends its usage message to STDERR (which is still
connected to your terminal), then it won't go to the 'out' file.

   system "rasmol >stdout.txt 2>stderr.txt";
   open my $prog_out,'<','stdout.txt' or warn();
   open my $prog_err,'<','stderr.txt' or warn();

Most likely the info you want went to STDERR instead of STDOUT.

   $usage_string = `rasmol 2>&1`;

	-Joe


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

Date: Mon, 07 Jun 2004 23:26:46 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: Kris Dugan <cjdugan@lucent.com>
Subject: Re: Need constant screen with periodic updates
Message-Id: <a5a7ae2bf8d3be49fa2de75606376751@news.teranews.com>

>>>>> "Kris" == Kris Dugan <cjdugan@lucent.com> writes:

Kris> I want to make a tool that will constantly read a structure of
Kris> information and display that information (or "paint it") to the
Kris> screen.  Rather than having the information scroll by, I want
Kris> a way in which the screen would be "repainted".

Sounds like a perfect job for Curses.pm.  Look in to it.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 08 Jun 2004 10:06:17 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Need constant screen with periodic updates
Message-Id: <1202966.G6fEguY5Ge@GMT-hosting-and-pickle-farming>

Kris Dugan wrote:

> I am using a Unix/Solaris 8/9 environment.
> 
> I want to make a tool that will constantly read a structure of
> information and display that information (or "paint it") to the
> screen.  Rather than having the information scroll by, I want
> a way in which the screen would be "repainted".  Sample Screen:

Easiest Perl way:

system('clear'); 
print "new info ..."


gtoomey


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

Date: Tue, 8 Jun 2004 00:51:01 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Need constant screen with periodic updates
Message-Id: <ca32hl$gt1$3@wisteria.csv.warwick.ac.uk>


Quoth Gregory Toomey <nospam@bigpond.com>:
> Kris Dugan wrote:
> 
> > I am using a Unix/Solaris 8/9 environment.
> > 
> > I want to make a tool that will constantly read a structure of
> > information and display that information (or "paint it") to the
> > screen.  Rather than having the information scroll by, I want
> > a way in which the screen would be "repainted".  Sample Screen:
> 
> Easiest Perl way:
> 
> system('clear'); 
> print "new info ..."

Come now, using external programs for something that simple is nearly
always wrong.

use Term::ANSIScreen qw/:screen :cursor/;

locate 1, 1;
cls;
print "...";

For some reason I have found that both cls and clline only work for me
if I locate to the start of the region to be cleared first... I am
presuming this is a bug in eiher Term::ANSIScreen or the linux console
driver :).

Ben

-- 
  The cosmos, at best, is like a rubbish heap scattered at random.
                                                         - Heraclitus
  ben@morrow.me.uk


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

Date: Mon, 07 Jun 2004 19:37:52 GMT
From: The Moor Of Venice <grizelda_bone@yahool.com>
Subject: Need help installing WWW-Search-Ebay-2.193 Module...
Message-Id: <ku3xc.45022$_k3.1122038@bgtnsc05-news.ops.worldnet.att.net>

Hi all.  I am trying to install the WWW-Search-Ebay-2.193 Module that I 
nicked off CPAN.  One of the O'Reilly Books has a script that calls this 
module.  Here's the problem:  I am trying to do it under Windows, from 
the Windows command line. <puts on flame proof suit and dodges rotten 
tomatoes>.

It's not a pre-built module.  ActivePerl's PPM won't let me do it.  Shy 
of dinking together a maching running Linux for the sole purpose of 
learning Perl and JavaScript and Python and all those fun scripting 
languages (which are far easier to program in under Linux than under 
Windoze--I mean easier in terms of not having to jump through a lot of 
hoops to get the scripts and so forth to work properly).

Anyone have any idea how to do this?  Any help you could give me?  The 
old version of the search module actually was a pre-built module and it 
installed just fine under the PPM.  But for some reason, the new one 
isn't.  And it's really giving me agita. I downloaded Cygwin but 
something went wrong, and I don't have the make command to run the 
makefile.   I figured if worse came to really horribly bad I could run 
ActivePerl for Linux under Cygwin and run the script which would call 
the then-successfully-installed module that way.  But that would be a 
very jury-rigged way to do it.

Any ideas?  Help?  I'd appreciate any help anyone could give me.

Thanks.

Dave


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

Date: Mon, 7 Jun 2004 19:49:16 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Need help installing WWW-Search-Ebay-2.193 Module...
Message-Id: <ca2grs$5fo$1@wisteria.csv.warwick.ac.uk>


Quoth The Moor Of Venice <grizelda_bone@yahool.com>:
> Hi all.  I am trying to install the WWW-Search-Ebay-2.193 Module that I 
> nicked off CPAN.  One of the O'Reilly Books has a script that calls this 
> module.  Here's the problem:  I am trying to do it under Windows, from 
> the Windows command line. <puts on flame proof suit and dodges rotten 
> tomatoes>.
> 
> It's not a pre-built module.  ActivePerl's PPM won't let me do it.  Shy 
> of dinking together a maching running Linux for the sole purpose of 
> learning Perl and JavaScript and Python and all those fun scripting 
> languages (which are far easier to program in under Linux than under 
> Windoze--I mean easier in terms of not having to jump through a lot of 
> hoops to get the scripts and so forth to work properly).
> 
> Anyone have any idea how to do this?  Any help you could give me?

If the module is Perl-only (no XS), and it probably is, then download
nmake from
http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe
and put it in your path. Then download the .tar.gz from CPAN, untar it,
change to the source directory and run the usual

perl Makefile.PL
nmake
nmake test
nmake install

Alternatively you could use CPAN.pm, which will automate all this; but
you may need to find and install command-line versions of tar and gzip
first.

If you need to install XS modules for which there is no PPD, then you
will have to abtain somehow a perl and a matching C compiler. This means
either installing VC++ to match ActivePerl, or downloading MinGW or
Borland's free compiler and building your own perl.

> I figured if worse came to really horribly bad I could run 
> ActivePerl for Linux under Cygwin

Ohh no you can't... perl does run under cygwin, but you have to build it
for cygwin (there is a binary in the cygwin distro).

Ben

-- 
Every twenty-four hours about 34k children die from the effects of poverty.
Meanwhile, the latest estimate is that 2800 people died on 9/11, so it's like
that image, that ghastly, grey-billowing, double-barrelled fall, repeated
twelve times every day. Full of children. [Iain Banks]         ben@morrow.me.uk


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

Date: Mon, 07 Jun 2004 19:56:33 GMT
From: The Moor Of Venice <grizelda_bone@yahool.com>
Subject: Re: Need help installing WWW-Search-Ebay-2.193 Module...
Message-Id: <RL3xc.45080$_k3.1123182@bgtnsc05-news.ops.worldnet.att.net>

Ben Morrow wrote:

> Quoth The Moor Of Venice <grizelda_bone@yahool.com>:
> 
>>Hi all.  I am trying to install the WWW-Search-Ebay-2.193 Module that I 
>>nicked off CPAN.  One of the O'Reilly Books has a script that calls this 
>>module.  Here's the problem:  I am trying to do it under Windows, from 
>>the Windows command line. <puts on flame proof suit and dodges rotten 
>>tomatoes>.
>>
>>It's not a pre-built module.  ActivePerl's PPM won't let me do it.  Shy 
>>of dinking together a maching running Linux for the sole purpose of 
>>learning Perl and JavaScript and Python and all those fun scripting 
>>languages (which are far easier to program in under Linux than under 
>>Windoze--I mean easier in terms of not having to jump through a lot of 
>>hoops to get the scripts and so forth to work properly).
>>
>>Anyone have any idea how to do this?  Any help you could give me?
> 
> 
> If the module is Perl-only (no XS), and it probably is, then download
> nmake from
> http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe
> and put it in your path. Then download the .tar.gz from CPAN, untar it,
> change to the source directory and run the usual
> 
> perl Makefile.PL
> nmake
> nmake test
> nmake install
> 
> Alternatively you could use CPAN.pm, which will automate all this; but
> you may need to find and install command-line versions of tar and gzip
> first.
> 
> If you need to install XS modules for which there is no PPD, then you
> will have to abtain somehow a perl and a matching C compiler. This means
> either installing VC++ to match ActivePerl, or downloading MinGW or
> Borland's free compiler and building your own perl.
> 
> 
>>I figured if worse came to really horribly bad I could run 
>>ActivePerl for Linux under Cygwin
> 
> 
> Ohh no you can't... perl does run under cygwin, but you have to build it
> for cygwin (there is a binary in the cygwin distro).
> 
> Ben
> 
You don't understand, man.  To me, the glory days of computers are the 
early 80's.  We did stuff however we could do it.  When I read about a 
fellow who had managed to get something like ten sprites going on a C64 
I almost cried.  When I read about another guy who had a VIC-20 Emulator 
running on a C64 Emulator running on a PC I kept thinking I had to get 
back into programming.  Hence Perl and JavaScript and Python and all. 
Because the essential concepts stay the same.  And the feeling of "OH MY 
GOD, it WORKS, the SONOFABITCHING thing ACTUALLY WORKS..." is a feeling 
I have never matched in my life.  And I get that feeling even from 
little programs.  Thanks for your help, I'm going to try it.

I'll let you know how it turns out.

Thanks again,

Dave


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

Date: 7 Jun 2004 14:40:19 -0700
From: john_20_28_2000@yahoo.com (jm)
Subject: Need help running shell commands
Message-Id: <c67e4bdd.0406071340.4c4c69b4@posting.google.com>

I have my perl file set up as 4711 and am running it as root.

I simply want to change the path via the perl script:

I have tried system('/mypath'); and system "/mypath";



When I set the path in the script, is it only set for the script
itself (just for the script's usage)?  and thus it wouldn't change the
path of the person running the script?  Thank you.


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

Date: Mon, 7 Jun 2004 21:50:48 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Need help running shell commands
Message-Id: <ca2nvn$a9f$3@wisteria.csv.warwick.ac.uk>


Quoth john_20_28_2000@yahoo.com (jm):
> I have my perl file set up as 4711 and am running it as root.

Why? It sounds like you don't know Perl anywhere near well enough yet to
be writing scripts to run setid.

> I simply want to change the path via the perl script:
> 
> I have tried system('/mypath'); and system "/mypath";
> 
> When I set the path in the script, is it only set for the script
> itself (just for the script's usage)?  and thus it wouldn't change the
> path of the person running the script?  Thank you.

Please explain yourself a little better.

Are you attempting to set $PATH in the invoking user's shell? This is a
faq: perldoc -q environment

If you're trying to do something else, then I'm afraid I don't
understand you at all. Try posting a short complete program, and
explaining what it does that you don't want it to do (or what it doesn't
do that you do want).

Ben

-- 
   Razors pain you / Rivers are damp
   Acids stain you / And drugs cause cramp.                    [Dorothy Parker]
Guns aren't lawful / Nooses give
  Gas smells awful / You might as well live.                   ben@morrow.me.uk


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

Date: Mon, 07 Jun 2004 22:19:01 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Need help running shell commands
Message-Id: <40C4E9C1.60108@rochester.rr.com>

jm wrote:

> I have my perl file set up as 4711 and am running it as root.
> 
> I simply want to change the path via the perl script:
> 
> I have tried system('/mypath'); and system "/mypath";
> 
> 
> 
> When I set the path in the script, is it only set for the script
> itself 


Nope.  Not even for the script itself (by using system()).  Only for the 
process kicked off by system() -- which, incidently, won't do much other 
than error out if it is as shown, unless you happen to have an 
executable program or script in your root directory named 'mypath'. 
Maybe you meant system('cd /mypath'); ?

> (just for the script's usage)?  and thus it wouldn't change the
> path of the person running the script?  Thank you.

Even if you changed the directory in the process in

which your Perl interpreter is running your script
(which can be done using a module whose name I can't recall
-- maybe File::chdir ?), you *still* wouldn't change the
directory for the user, script, or whatever that fired
off Perl's process.  Read a Unix primer -- a subprocess
is pretty well insulated from its parent process -- the
subprocess cannot make any change to the parent's
environment.  That's a feature, not a bug.  See:

    perldoc -q 'changed directory'


-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Mon, 7 Jun 2004 22:55:25 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Need help running shell commands
Message-Id: <ca2rot$cs4$1@wisteria.csv.warwick.ac.uk>


Quoth see@sig.invalid:
> 
> Even if you changed the directory in the process in
> which your Perl interpreter is running your script
> (which can be done using a module whose name I can't recall
> -- maybe File::chdir ?)

err, try perldoc -f chdir

Ben

-- 
"The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching."
     -Assyrian stone tablet, c.2800 BC                         ben@morrow.me.uk


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

Date: Tue, 08 Jun 2004 10:10:15 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Need help running shell commands
Message-Id: <2160951.jWO6SopZfD@GMT-hosting-and-pickle-farming>

Ben Morrow wrote:

> 
> Quoth john_20_28_2000@yahoo.com (jm):
>> I have my perl file set up as 4711 and am running it as root.
> 

> Please explain yourself a little better.

I dont have a clue what he wants. 4711 is a brand of aftershave.
http://www.fragrancewholesale.com/471127ozedc1.html

gtoomey


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

Date: Tue, 08 Jun 2004 10:13:36 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: No-install Perl Interpretor
Message-Id: <16983853.INFhhELGh6@GMT-hosting-and-pickle-farming>

Micla wrote:

> 
> Would anybody know a Perl version usable without any prior installation?
> 
> One of the goals foreseen for it would be to have some "personal"
> scripts on a USB memory key, immediately usable on any computer that I
> have the opportunity to go on.
> 
> But there are also other reasons to try to use Perl scripts without
> installing Perl previously.
> 
> Thank's for any help.
> 
> Me.

Install an OS ( eg damnsmalllinux about 50MB) with Perl on your usb key
New motherboards support booting from usb.

gtoomey


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

Date: 7 Jun 2004 17:46:41 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: No-install Perl Interpretor
Message-Id: <40c50c71@news.victoria.tc.ca>

Micla (mick.lan@laposte.net) wrote:

: Would anybody know a Perl version usable without any prior installation?

: One of the goals foreseen for it would be to have some "personal" 
: scripts on a USB memory key, immediately usable on any computer that I 
: have the opportunity to go on.

: But there are also other reasons to try to use Perl scripts without 
: installing Perl previously.

: Thank's for any help.

The keys files required by perl are very few.

On windows, for example, you need perl.exe and perhaps one .DLL file
(perhaps another as well).  If you have those files in your path then you
can write and run perl scripts without any kind of install, and without
taking up much space.  Of course you can't use modules, unless you also
include them somewhere, but so what, perl by itself is still extremely
useful for things like mass batch editing of files and flexible filtering
etc.



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

Date: Mon, 7 Jun 2004 14:22:08 -0400
From: "Bill Cunningham" <nospam@nspam.net>
Subject: Re: perl and assembly
Message-Id: <10c9ch41ggr543f@corp.supernews.com>


>
> Do you have a Perl question, too?

    Too many right now to know where to begin without looking like a fool.
Is there a good tutorial online other than cpan ? Something for beginners
over the level of

print 1+2;





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

Date: Mon, 7 Jun 2004 18:24:45 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: perl and assembly
Message-Id: <ca2btd$2o1$1@wisteria.csv.warwick.ac.uk>


Quoth "Bill Cunningham" <nospam@nspam.net>:
> 
> >
> > Do you have a Perl question, too?
> 
>     Too many right now to know where to begin without looking like a fool.
> Is there a good tutorial online other than cpan ? Something for beginners
> over the level of
> 
> print 1+2;

Try starting with the perl docs: start with perldoc perl, and read
through in order (ish).

If you need more of a tutorial than that, in particular if you're not
familiar with programming in general, try 'Learning Perl' published by
O'Reilly.

Ben

-- 
               We do not stop playing because we grow old; 
                  we grow old because we stop playing.
                            ben@morrow.me.uk


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

Date: Mon, 07 Jun 2004 19:30:14 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: perl and assembly
Message-Id: <an3xc.368$ar.226@attbi_s04>

Bill Cunningham wrote:

>>Do you have a Perl question, too?
>  
>     Too many right now to know where to begin without looking like a fool.
> Is there a good tutorial online other than cpan ?

http://learn.perl.org/
	-Joe


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

Date: Mon, 07 Jun 2004 20:21:27 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: perl and assembly
Message-Id: <b74xc.22467$AU1.9600@nwrddc01.gnilink.net>

Bill Cunningham wrote:
>> Do you have a Perl question, too?
>
>     Too many right now to know where to begin without looking like a
> fool. Is there a good tutorial online other than cpan ? Something for
> beginners over the level of
>
> print 1+2;

Have a look at "perldoc -q book".
This FAQ entry has a nice list of interesting books as well as a link to an
online list with extensive reviews.

jue




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

Date: 7 Jun 2004 16:14:21 -0700
From: Prab_kar@hotmail.com (Prabh)
Subject: Print a section of a text file.
Message-Id: <e7774537.0406071514.41242a53@posting.google.com>

Hello all,
I'm trying to print a section of a text file which has the following
contents.

===========================
 .
 .
 .
Files Section:
{
      File1:
      {
          Description1
          Size1
          Date1
      }

      File2:
      {
          Description2
          Size2
          Date2
      }
}
 .
 .
===========================

In here, I want to print the contents of "File Section".

I tried the following:

#!/usr/local/bin/perl

use strict ;
use warnings;

open(FDL,"file.txt") or die "Can't open file.txt: $!\n" ;
while(<FDL>)
{
        chomp ;
        print "$_\n" if ( /^Files Section/ .. /\}/ ) ;
}
close(FDL) ;

====================================
This only prints the contents till the first occurence of the closing
brace, i.e., till Date1 of the first file1.

How do I tell it to "print till the closing brace of Files Section,
not just the first occurence of }"?

2. Also, whats the closest Perl-equivalent module/package for Java's
Velocity to readin a well-formatted file, because file.txt is always
of a standard format.

Thanks for your time,
Prabh


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

Date: Tue, 08 Jun 2004 01:41:11 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Print a section of a text file.
Message-Id: <2ikcp2Fnta4aU1@uni-berlin.de>

Prabh wrote:
> How do I tell it to "print till the closing brace of Files Section,
> not just the first occurence of }"?

If you can trust the indenting, why not just anchor the pattern in the 
second regex to the beginning of the string?

     /^\}/

Btw,

     chomp;
     print "$_\n"

gives you the same result as just

     print

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Mon, 7 Jun 2004 19:44:00 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Print a section of a text file.
Message-Id: <20040607194210.N8971@dishwasher.cs.rpi.edu>

On Mon, 7 Jun 2004, Prabh wrote:

> Hello all,
> I'm trying to print a section of a text file which has the following
> contents.
>
> ===========================
> .
> .
> .
> Files Section:
> {
>       File1:
>       {
>           Description1
>           Size1
>           Date1
>       }
>
>       File2:
>       {
>           Description2
>           Size2
>           Date2
>       }
> }
> .
> .
> ===========================
>
> In here, I want to print the contents of "File Section".
>
> I tried the following:
>
> #!/usr/local/bin/perl
>
> use strict ;
> use warnings;
>
> open(FDL,"file.txt") or die "Can't open file.txt: $!\n" ;
> while(<FDL>)
> {
>         chomp ;
>         print "$_\n" if ( /^Files Section/ .. /\}/ ) ;
> }
> close(FDL) ;
>
> ====================================
> This only prints the contents till the first occurence of the closing
> brace, i.e., till Date1 of the first file1.
>
> How do I tell it to "print till the closing brace of Files Section,
> not just the first occurence of }"?
>


Is that file exactly as you showed it above, including all whitespace?  If
so, your second pattern match can just look for a right-brace as the first
character on the line:
print "$_\n" if ( /^Files Section/ .. /^}/ );

Paul Lalli


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

Date: Tue, 8 Jun 2004 00:47:34 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Print a section of a text file.
Message-Id: <ca32b5$gt1$2@wisteria.csv.warwick.ac.uk>


Quoth Gunnar Hjalmarsson <noreply@gunnar.cc>:
> Prabh wrote:
> > How do I tell it to "print till the closing brace of Files Section,
> > not just the first occurence of }"?
> 
> If you can trust the indenting, why not just anchor the pattern in the 
> second regex to the beginning of the string?
> 
>      /^\}/

If you can't, but you can assume there is at most one {} on a line, and
that they are all significant (i.e. you won't ever get braces-inside-
quotes or something that don't count towards the nesting) then you can
do

my $braces = 0; # loathe uninit variable warnings

while (<$file>) {
    /\}/ and $braces--;
    print if /Files section/ .. (/\}/ and not $braces);
    /\{/ and $braces++;
}

If you can't even assume that, you'll have to do something more
complicated; possibly slurping the whole file (File::Slurp) and using
Text::Balanced would be easiest.

> Btw,
> 
>      chomp;
>      print "$_\n"
> 
> gives you the same result as just
> 
>      print

Tut tut... only if $/="\n" :)

Ben

-- 
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~                   Jorge Luis Borges, 'The Babylon Lottery'


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

Date: Mon, 7 Jun 2004 16:12:01 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: syntax  $_[0]
Message-Id: <slrncc9mh1.gp9.tadmc@magna.augustmail.com>

Jon Landenburer <jon.m.landenburger@verizon.com> wrote:

>         if ($_[0])


> Its the $_[0] I dont understand.  If this were a subroutine I would
> understand that tto be the first passed parameter.  But this is not a
> subroutine .


Is is accessing the array named underscore ( @_ ).

Since it is not in a subroutine, @_ is not populated automatically,
it must have been populated explicitly somewhere.

Find out where.  :-)


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


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

Date: Mon, 7 Jun 2004 21:46:07 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: syntax  $_[0]
Message-Id: <ca2nmv$a9f$1@wisteria.csv.warwick.ac.uk>


Quoth tadmc@augustmail.com:
> Jon Landenburer <jon.m.landenburger@verizon.com> wrote:
> 
> >         if ($_[0])
> 
> > Its the $_[0] I dont understand.  If this were a subroutine I would
> > understand that tto be the first passed parameter.  But this is not a
> > subroutine .
> 
> Is is accessing the array named underscore ( @_ ).
> 
> Since it is not in a subroutine, @_ is not populated automatically,
> it must have been populated explicitly somewhere.

Or, perhaps, implicitly by split in scalar context.

Ben

-- 
perl -e'print map {/.(.)/s} sort unpack "a2"x26, pack "N"x13,
qw/1632265075 1651865445 1685354798 1696626283 1752131169 1769237618
1801808488 1830841936 1886550130 1914728293 1936225377 1969451372
2047502190/'                                                 # ben@morrow.me.uk


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

Date: Mon, 07 Jun 2004 20:04:13 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: why can't I hang a "shift" on the front of this statement
Message-Id: <1T3xc.1347$0y.1164@attbi_s03>

Sara wrote:

> Perl is unhappy with this line:
>     shift my @id = split /ID\s+([^\n]+)\n/, $$_;
>   Use of implicit split to @_ is deprecated at ./SSMCP10Conditioner.pl
 > And why is it assuming I'm trying to do anything implicitly with @_ ?

You'll get that message when doing {$scalar = split /.../}.

Since shift(@id) returns a scalar value, what you've written is like
   12345 = split /ID\s+([^\n]+)\n/, $$_;
which has to problems: split is being told to operate in scalar context
and you're attempting to modify a readonly value.

Forget about shift; use a dummy variable or undef to ignore the first item.
    my ($first,@id) = split /ID\s+([^\n]+)\n/, $$_;

	-Joe


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

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 6662
***************************************


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