[26674] in Perl-Users-Digest
Perl-Users Digest, Issue: 8781 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 20 18:05:32 2005
Date: Tue, 20 Dec 2005 15:05:05 -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 Tue, 20 Dec 2005 Volume: 10 Number: 8781
Today's topics:
Re: getting info from a bash shell script into perl var axel@white-eagle.invalid.uk
Re: getting info from a bash shell script into perl var axel@white-eagle.invalid.uk
Re: getting info from a bash shell script into perl var <bob@dont.spam.me>
Picking Up Perl <rbt@athop1.ath.vt.edu>
Re: Picking Up Perl <1usa@llenroc.ude.invalid>
Re: Picking Up Perl <rbt@athop1.ath.vt.edu>
Re: quotes (Raghuramaiah Gompa)
split by word using | as delimiter <wh2leung@student.cs.uwaterloo.ca>
Re: split by word using | as delimiter <bob@dont.spam.me>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 20 Dec 2005 20:22:36 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: getting info from a bash shell script into perl variables
Message-Id: <gKZpf.12299$iz3.8523@text.news.blueyonder.co.uk>
Bob <bob@dont.spam.me> wrote:
> I have a perl script that needs to set some variables based on the output
> of a bash shell script. I can arrange the output of the shell script to
> whatever works best for perl.
> Here is what I have so far:
> Output of shell script:
> $var1="aaa"; $var2="bbb ccc"; $var3="";
> Perl extract:
> my $var1; my $var2; my $var3;
> eval `./myscript.sh`;
> print "var1=$var1";
> print "var2=$var2";
> print "var3=$var3";
> This always prints:
> var1=
> var2=
> var3=
> So, am I using eval incorrectly?
It works for me. Are you sure about what output you are getting from
the shell script... try using the following to double check.
my $result = `./myscript.sh`;
print $result; # From your script snippet I assume $\ is set to "\n"
eval result;
Axel
------------------------------
Date: Tue, 20 Dec 2005 20:41:31 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: getting info from a bash shell script into perl variables
Message-Id: <%%Zpf.12314$iz3.8060@text.news.blueyonder.co.uk>
axel@white-eagle.invalid.uk wrote:
> Bob <bob@dont.spam.me> wrote:
>> So, am I using eval incorrectly?
> It works for me. Are you sure about what output you are getting from
> the shell script... try using the following to double check.
> my $result = `./myscript.sh`;
> print $result; # From your script snippet I assume $\ is set to "\n"
> eval result;
^
|
Obviously a '$' missing here... sorry... not my night... sigh.
Axel
------------------------------
Date: Tue, 20 Dec 2005 21:08:21 GMT
From: Bob <bob@dont.spam.me>
Subject: Re: getting info from a bash shell script into perl variables
Message-Id: <pan.2005.12.20.21.08.20.753608@dont.spam.me>
On Tue, 20 Dec 2005 20:22:36 +0000, axel wrote:
>
> It works for me. Are you sure about what output you are getting from the
> shell script... try using the following to double check.
>
> my $result = `./myscript.sh`;
> print $result; # From your script snippet I assume $\ is set to "\n" eval
> result;
>
Axel,
From your response and those of others I think what I was doing should
have worked. I must have had a typo somewhere. As I mentioned in a couple
of other threads I solved my problem in a slightly different way.
I plan to live with my new solution for now but will come back to this
later to see if I can get it to work.
Oh yes, I am pretty sure my bash script was putting out the right thing
(or what I thought was the right thing) since I could print it from perl
just like your example above. But my original code is now lost forever
(hold back your tears) so I can't go examine it. I'll just start from
scratch when I get around to re-investigating this.
Thanks,
Bob
------------------------------
Date: Tue, 20 Dec 2005 15:09:21 -0500
From: rbt <rbt@athop1.ath.vt.edu>
Subject: Picking Up Perl
Message-Id: <do9odi$5pg$1@solaris.cc.vt.edu>
Hi guys,
I'm a moderately proficient C/Python programmer looking to learn Perl
for Windows programming. I don't know enough about Perl in general to
know whether or not I like it, but if the language is like the concept
behind it, I think I will. Python is great and I'm very well versed in
it, but I need a bit more freedom... if you know what I mean.
What books (if any) target Perl on Windows? I need info on accessing the
Windows API, creating services, managing processes, etc and I prefer
proper books over online only material. Also, what's up with ActiveState
managing the Windows release? Could they close up shop and cause
problems for Perl on Windows? Total newbie here... just curious.
Also, what impact will Perl 6 have on the things I learn in Perl 5? Will
knowledge gained in 5 carry over to 6 or will I have to re-learn things
that have been implemented differently?
Sorry if this off-topic here. Many thanks to all for advice.
rbt
------------------------------
Date: Tue, 20 Dec 2005 20:37:40 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Picking Up Perl
Message-Id: <Xns97329EFC47B8Easu1cornelledu@127.0.0.1>
rbt <rbt@athop1.ath.vt.edu> wrote in
news:do9odi$5pg$1@solaris.cc.vt.edu:
> what's up with ActiveState managing the Windows release?
They are not managing the Windows release: They are providing a binary
distribution that is easy to install. There are others who provide binary
distributions for Windows.
> Could they close up shop and cause problems for Perl on Windows?
How could they cause problems? Anyone can compile a distribution. AS are
providing a service that makes it very convenient for those of us who do
not want to bother with compiling from source, and also managing
repository of ready-to-install packages, but they are hardly controlling
or managing Perl on Windows.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Tue, 20 Dec 2005 15:43:36 -0500
From: rbt <rbt@athop1.ath.vt.edu>
Subject: Re: Picking Up Perl
Message-Id: <do9qdp$7na$1@solaris.cc.vt.edu>
A. Sinan Unur wrote:
> rbt <rbt@athop1.ath.vt.edu> wrote in
> news:do9odi$5pg$1@solaris.cc.vt.edu:
>
>> what's up with ActiveState managing the Windows release?
>
> They are not managing the Windows release: They are providing a binary
> distribution that is easy to install. There are others who provide binary
> distributions for Windows.
>
>> Could they close up shop and cause problems for Perl on Windows?
>
> How could they cause problems? Anyone can compile a distribution. AS are
> providing a service that makes it very convenient for those of us who do
> not want to bother with compiling from source, and also managing
> repository of ready-to-install packages, but they are hardly controlling
> or managing Perl on Windows.
>
> Sinan
OK, just a misunderstanding... you got the part about me being new to
Perl on Windows, right? I'm just trying to some answers from those in
the know, that's all.
------------------------------
Date: Tue, 20 Dec 2005 20:55:06 +0000 (UTC)
From: rgompa@steel.ucs.indiana.edu (Raghuramaiah Gompa)
Subject: Re: quotes
Message-Id: <do9r3a$p2h$1@rainier.uits.indiana.edu>
In article <do7jvk$1ki$1@rainier.uits.indiana.edu>,
Raghuramaiah Gompa <rgompa@steel.ucs.indiana.edu> wrote:
>I am "trying" to write a perl code to generate a file
>with everybody's 'help'.
>
>The output should be:
>
>I am \myquote{trying} to write a perl code to generate a
>file with everybody{\justquote}s \singlequote{help}.
>
>I know I can handle double quotes, but I am puzzled about
>single quote as you can see they may occur two different
>ways.
>
>Please help. .. Raghu
I do apologize for my incorrect posting. I do appreciate
your followup postings. Please forgive me.
My question should have been (more clearly) like this:
I want to develop and run a perl program on a file which
contains
single quotes, double quotes, and apostrophes. I want to
put each "sentence" (from the input file) under double
quotes under a macro like
\myquotes{sentence} (in the output file). This is not a
problem. But single
quotes pose a problem. Because things like `please
forgive me' should be transfered to \singlequote{please
forgive me}. Apostrophe in Raghu's mistake somehow
should be left alone (I know I asked a different thing
before, but I think this is what is needed). The later
type of apostrophe may occur several ways: you're aren't
..
Hope this is clear. Please help. .. Raghu
------------------------------
Date: Tue, 20 Dec 2005 17:02:56 -0500
From: William <wh2leung@student.cs.uwaterloo.ca>
Subject: split by word using | as delimiter
Message-Id: <Pine.GSO.4.64.0512201657090.25492@cpu02.student.cs.uwaterloo.ca>
input file - dummylist.txt:
|ZZ_JEN|1|0|0|0|name@uwaterloo.ca
expected output:
6
ZZ_JEN
current output:
35
Z
code in question:
#!/usr/bin/perl -w
use strict;
my $dummy_list = "/mkapp/webapps/mxrt-cgi/upload_vol/dummylist.txt";
open ( DUMMY_FD , $dummy_list ) || die "Cannot open file $dummy_list\n";
my @lines = <DUMMY_FD>;
foreach my $currentLine ( @lines ) {
my @instrumentEntries = ( split(/|/, $currentLine) );
my $numEntries = @instrumentEntries;
print $numEntries . "\n";
print $instrumentEntries[1] . "\n";
}
close ( DUMMY_FD );
for the line
my @instrumentEntries = ( split(/|/, $currentLine) );
what is the correct way to split $currentLine of the input file?
P.S. i already checked perldoc -f split and perldoc -q split.
------------------------------
Date: Tue, 20 Dec 2005 22:20:37 GMT
From: Bob <bob@dont.spam.me>
Subject: Re: split by word using | as delimiter
Message-Id: <pan.2005.12.20.22.20.37.297420@dont.spam.me>
On Tue, 20 Dec 2005 17:02:56 -0500, William wrote:
>
> for the line
> my @instrumentEntries = ( split(/|/, $currentLine) );
>
> what is the correct way to split $currentLine of the input file?
I just went through this! escape the | :
my @instrumentEntries = ( split(/\|/, $currentLine) );
Can't say if there is anything else wrong in your code, but the escape was
one thing I missed in the same situation just an hour or so ago.
Bob
------------------------------
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 8781
***************************************