Re: array population from system app call

2004-05-25 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
> 
> yes it does thanks!  Will you be so kind and answer my other question too?
> 
> maybe I am not understanding when a multidimensional array would be
> useful?  when are these references useful?
> is there a perldoc I can read as well?

perldoc perldata
perldoc perllol
perldoc perldsc


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: array population from system app call

2004-05-25 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
> 
> All,

Hello,

> was hoping anyone could provide some syntax help.
> 
> I want to populate an array from a system app call like so and then
> print out each element.
> 
> my @ftapes = system ("evmvol -w label_state=3|grep barcode");
> print $ftapes[0]
> 
> or
> 
> print $ftapes[0,1]
> 
> The problem is it prints out all the lines for print $ftapes[0] and does
> not print for print $ftapes[0,1]
> 
> OR
> should I just run the system call,  put it to a file
> then open the file,  read line by line
> chomp
> foreach $_
> print $_
> close file

Either:

my @ftapes = grep /barcode/, `evmvol -w label_state=3`;


Or:

open PIPE, 'evmvol -w label_state=3 |' or die "Cannot open pipe from evmvol: $!";
my @ftapes = grep /barcode/, ;
close OUTPUT or warn $! ? "Cannot close pipe from evmvol: $!"
: "Exit status $? from evmvol";

print $ftapes[ 0 ];

or

print @ftapes[ 0, 1 ];



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: array population from system app call

2004-05-25 Thread James Edward Gray II
On May 25, 2004, at 2:45 PM, [EMAIL PROTECTED] wrote:
James,
yes it does thanks!  Will you be so kind and answer my other question 
too?
Good news.  Yes, I will...
maybe I am not understanding when a multidimensional array would be
useful?  when are these references useful?
is there a perldoc I can read as well?
The docs are:
perlreftut
and
perlref
References are great for building complex data structures, ask you 
guessed.  However they add a degree complexity, so make sure you need 
them before you inflict that upon yourself.

James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: array population from system app call

2004-05-25 Thread DBSMITH
James, 

yes it does thanks!  Will you be so kind and answer my other question too?

maybe I am not understanding when a multidimensional array would be 
useful?  when are these references useful?
is there a perldoc I can read as well?

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams






James Edward Gray II <[EMAIL PROTECTED]>
05/25/2004 03:37 PM

 
To: [EMAIL PROTECTED]
cc: Perl Beginners <[EMAIL PROTECTED]>
Subject:    Re: array population from system app call


On May 25, 2004, at 2:24 PM, [EMAIL PROTECTED] wrote:

> here is the sample output.
>
>
> barcode=E01124
> barcode=E01178
> barcode=E01195
> barcode=E01225
> barcode=E01232
>
> maybe I am not understanding when a multidimensional array would be
> useful?  when are these references useful?

I really doubt you need a multidimensional array here.  The first half 
of all those lines is the same and since you filtered the output to get 
just that, I assume we can throw it away.  You just want the codes 
after the = sign, right?  Let's ask for that:

my @codes = grep s/^barcode=//, `evmvol -w label_state`;

Does that get what you're after?

James





Re: array population from system app call

2004-05-25 Thread James Edward Gray II
On May 25, 2004, at 2:24 PM, [EMAIL PROTECTED] wrote:
here is the sample output.
barcode=E01124
barcode=E01178
barcode=E01195
barcode=E01225
barcode=E01232
maybe I am not understanding when a multidimensional array would be
useful?  when are these references useful?
I really doubt you need a multidimensional array here.  The first half 
of all those lines is the same and since you filtered the output to get 
just that, I assume we can throw it away.  You just want the codes 
after the = sign, right?  Let's ask for that:

my @codes = grep s/^barcode=//, `evmvol -w label_state`;
Does that get what you're after?
James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: array population from system app call

2004-05-25 Thread DBSMITH
here is the full output.


volid=
name=
luname=st_9840_acs_0
slot_index=1
barcode=E01124
mtype=35
atype=0
sequence=0
mside=0
state=0
open_count=0
v_flags=0
comment=
flags_value: 0x108
flags: RVM_IS_FOREIGN RVM_IS_IN_REAL_LU 

volid=
name=
luname=st_9840_acs_0
slot_index=4
barcode=E01178
mtype=35
atype=0
sequence=0
mside=0
state=0
open_count=0
v_flags=0
comment=
flags_value: 0x108
flags: RVM_IS_FOREIGN RVM_IS_IN_REAL_LU 

volid=
name=
luname=st_9840_acs_0
slot_index=0
barcode=E01195
mtype=35
atype=0
sequence=0
mside=0
state=0
open_count=0
v_flags=0
comment=
flags_value: 0x108
flags: RVM_IS_FOREIGN RVM_IS_IN_REAL_LU 

volid=
name=
luname=st_9840_acs_0
slot_index=17
barcode=E01225
mtype=35
atype=0
sequence=0
mside=0
state=0
open_count=0
v_flags=0
comment=
flags_value: 0x108
flags: RVM_IS_FOREIGN RVM_IS_IN_REAL_LU 

volid=
name=
luname=st_9840_acs_0
slot_index=24
barcode=E01232
mtype=35
atype=0
sequence=0
mside=0
state=0
open_count=0
v_flags=0
comment=
flags_value: 0x108


Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
614-566-4145





James Edward Gray II <[EMAIL PROTECTED]>
05/25/2004 02:59 PM

 
To: [EMAIL PROTECTED]
cc: Perl Beginners <[EMAIL PROTECTED]>
Subject:    Re: array population from system app call


On May 25, 2004, at 1:34 PM, [EMAIL PROTECTED] wrote:

> ok so now I can get all elements printed using
>
> my @ftapes = ( );
> my @ftapes = `evmvol -w label_state=3|grep barcode`;
>
> foreach $_  (@ftapes) {
> print $_ , "\n";
> }
>
> so now I want to use multidimensional arrays using print $ftapes[0,1]
> does print $ftapes [0,1] mean print element 0 and element 1 or address 
> 0,1
> am I confusing a normal array with a MDarray?

Perl arrays are not multidimensional.  Using references though, we can 
get there.

Backticks return LINES, not fields.  If we want to break them down, 
we'll need to do that.

Can you show a sample output of `evmvol -w label_state`?

James





Re: array population from system app call

2004-05-25 Thread DBSMITH
here is the sample output.


barcode=E01124
barcode=E01178
barcode=E01195
barcode=E01225
barcode=E01232

maybe I am not understanding when a multidimensional array would be 
useful?  when are these references useful?


Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams






James Edward Gray II <[EMAIL PROTECTED]>
05/25/2004 02:59 PM

 
To: [EMAIL PROTECTED]
cc: Perl Beginners <[EMAIL PROTECTED]>
Subject:    Re: array population from system app call


On May 25, 2004, at 1:34 PM, [EMAIL PROTECTED] wrote:

> ok so now I can get all elements printed using
>
> my @ftapes = ( );
> my @ftapes = `evmvol -w label_state=3|grep barcode`;
>
> foreach $_  (@ftapes) {
> print $_ , "\n";
> }
>
> so now I want to use multidimensional arrays using print $ftapes[0,1]
> does print $ftapes [0,1] mean print element 0 and element 1 or address 
> 0,1
> am I confusing a normal array with a MDarray?

Perl arrays are not multidimensional.  Using references though, we can 
get there.

Backticks return LINES, not fields.  If we want to break them down, 
we'll need to do that.

Can you show a sample output of `evmvol -w label_state`?

James





Re: array population from system app call

2004-05-25 Thread James Edward Gray II
On May 25, 2004, at 1:34 PM, [EMAIL PROTECTED] wrote:
ok so now I can get all elements printed using
my @ftapes = ( );
my @ftapes = `evmvol -w label_state=3|grep barcode`;
foreach $_  (@ftapes) {
print $_ , "\n";
}
so now I want to use multidimensional arrays using print $ftapes[0,1]
does print $ftapes [0,1] mean print element 0 and element 1 or address 
0,1
am I confusing a normal array with a MDarray?
Perl arrays are not multidimensional.  Using references though, we can 
get there.

Backticks return LINES, not fields.  If we want to break them down, 
we'll need to do that.

Can you show a sample output of `evmvol -w label_state`?
James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: array population from system app call

2004-05-25 Thread DBSMITH
ok so now I can get all elements printed using

my @ftapes = ( );
my @ftapes = `evmvol -w label_state=3|grep barcode`;
 
foreach $_  (@ftapes) {
print $_ , "\n";
}

so now I want to use multidimensional arrays using print $ftapes[0,1]
does print $ftapes [0,1] mean print element 0 and element 1 or address 0,1
am I confusing a normal array with a MDarray?

where 

[0] is a subscript address so to get the first element I would say print 
$ftapes [0]

thanks

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams



Re: array population from system app call

2004-05-25 Thread DBSMITH
excellent I did not know that about system!

thanks again!

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams






James Edward Gray II <[EMAIL PROTECTED]>
05/25/2004 02:08 PM

 
To: [EMAIL PROTECTED]
cc: Perl Beginners <[EMAIL PROTECTED]>
Subject:    Re: array population from system app call


On May 25, 2004, at 1:03 PM, [EMAIL PROTECTED] wrote:

> cool, but why doesn't
> my @ftapes = system ("evmvol -w label_state=3|grep barcode");
> print $ftapes[0]
>
> OR
> print $ftapes[0,1]
>
> work?

Because system() does not return the program's output, it returns exit 
status.

> I see that it does not support multidimensional arrays, so how do I
> implement this using system?

Multi-dimensional arrays are possible in Perl, with references.  If you 
want to talk about that, please send a new message asking your 
questions about that topic.

You don't do what you show with system() because that's not what it's 
for.  Backticks fill that role.

James





Re: array population from system app call

2004-05-25 Thread James Edward Gray II
On May 25, 2004, at 1:03 PM, [EMAIL PROTECTED] wrote:
cool, but why doesn't
my @ftapes = system ("evmvol -w label_state=3|grep barcode");
print $ftapes[0]
OR
print $ftapes[0,1]
work?
Because system() does not return the program's output, it returns exit 
status.

I see that it does not support multidimensional arrays, so how do I
implement this using system?
Multi-dimensional arrays are possible in Perl, with references.  If you 
want to talk about that, please send a new message asking your 
questions about that topic.

You don't do what you show with system() because that's not what it's 
for.  Backticks fill that role.

James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: array population from system app call

2004-05-25 Thread DBSMITH
cool, but why doesn't 
my @ftapes = system ("evmvol -w label_state=3|grep barcode");
print $ftapes[0]

OR
print $ftapes[0,1] 

work? 

I see that it does not support multidimensional arrays, so how do I 
implement this using system?

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
614-566-4145





"Halkyard, Jim" <[EMAIL PROTECTED]>
05/25/2004 01:58 PM

 
To: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
    cc: 
    Subject:    RE: array population from system app call




To capture output you need the backticks 

my @output = `put your command here`;

The return value of a system call is the return value of the program you 
call.

See perldoc perlfaq8 for more info

Jim

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 25 May 2004 18:45
To: [EMAIL PROTECTED]
Subject: array population from system app call


All, 

was hoping anyone could provide some syntax help.

I want to populate an array from a system app call like so and then 
print out each element.


my @ftapes = system ("evmvol -w label_state=3|grep barcode");
print $ftapes[0]


or 

print $ftapes[0,1]

The problem is it prints out all the lines for print $ftapes[0] and does 
not print for print $ftapes[0,1]


OR 
should I just run the system call,  put it to a file
then open the file,  read line by line 
chomp
foreach $_
print $_
close file

thanks
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>






Re: array population from system app call

2004-05-25 Thread James Edward Gray II
On May 25, 2004, at 12:45 PM, [EMAIL PROTECTED] wrote:
All,
was hoping anyone could provide some syntax help.
I want to populate an array from a system app call like so and then
print out each element.
my @ftapes = system ("evmvol -w label_state=3|grep barcode");
print $ftapes[0];
You're looking for backticks:
my @ftapes = `evmvol -w label_state=3|grep barcode`;
# etc...
Hope that helps.
James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: array population from system app call

2004-05-25 Thread Halkyard, Jim


To capture output you need the backticks 

my @output = `put your command here`;

The return value of a system call is the return value of the program you call.

See perldoc perlfaq8 for more info

Jim

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 25 May 2004 18:45
To: [EMAIL PROTECTED]
Subject: array population from system app call


All, 

was hoping anyone could provide some syntax help.

I want to populate an array from a system app call like so and then 
print out each element.


my @ftapes = system ("evmvol -w label_state=3|grep barcode");
print $ftapes[0]


or 

print $ftapes[0,1]

The problem is it prints out all the lines for print $ftapes[0] and does 
not print for print $ftapes[0,1]


OR 
should I just run the system call,  put it to a file
then open the file,  read line by line 
chomp
foreach $_
print $_
close file

thanks
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




array population from system app call

2004-05-25 Thread DBSMITH
All, 

was hoping anyone could provide some syntax help.

I want to populate an array from a system app call like so and then 
print out each element.


my @ftapes = system ("evmvol -w label_state=3|grep barcode");
print $ftapes[0]


or 

print $ftapes[0,1]

The problem is it prints out all the lines for print $ftapes[0] and does 
not print for print $ftapes[0,1]


OR 
should I just run the system call,  put it to a file
then open the file,  read line by line 
chomp
foreach $_
print $_
close file

thanks
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams