[Perl] Accessing array elements within a sed command in Perl script
I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows:
This script doesn't work as is and I think it might be something with the syntax of how to call the element of an array within a embedded sed command. If I put an actual integer as the array index instead of the variable $count, it works fine, but if I try to use $count, it doesn't work at all. I know this might not be the most efficient method, but it is the only way I can think of with my limited knowledge of perl scripting.
Hello,
I have a comma delimited input feed file. The first field has directory location and the second field has file name.
Ex of input feed:
/export/appl/a,abc*.dat
/export/appl/b,xyz*.dat
/export/appl/c,pmn*.dat
Under each directory, there would be many files like...
.
.
.... (4 Replies)
How do I access one of the indices in array tst with the code below?
tst=sprintf("%5.2f",Car / 12)
When I scan thru the array with
for ( i in tst ) { print i,tst }
I get the output of:
vec-7 144
But when I try this in the END
print tst
It looks like it's not set.
What am... (6 Replies)
Hi,
My doubt is how to access array elements..
Situation is as below:
#!/bin/ksh
set -x
typeset -i x=0
typeset -i y=0
typeset -i BID=0
typeset -i count=0
while ] ; do
x=`expr $x + 1`;
hwmgr show scsi > scsi.tmp
while read line; do
set... (1 Reply)
I need to use array elements while pattern matching.
@myarr = (ELEM1, ELEM2, ELEM3);
following is the statement which I am using in my code. Basically I want to replace the ELEM1/2/3 with other thing which is mentioned as REPL here.
if (condition) {
s/(ELEM1|ELEM2|ELEM3): REPL: /;
}
I... (3 Replies)
What is wrong with this line in a perl script?
$amc_data = `sed -n '/\/,/\/p' "$config_file"`
I ran the above from command line and it works fine from unix command prompt.
The code should produce output between the and tags.
The config_file is as follows:
Sun ... (2 Replies)
Hello,
I have the following perl array:
@longname = (Fasthernet0/0 Fasthernet0/1 Serial0/1/0 Serial0/2/1 Tunnel55 Tunnel77)
with the followinh array:
@shortname = (Fa0/0 Fa0/1 Se0/1/0 Se0/2/1 Tu55 Tu77)
in other words, I need to remove the following from each element in the array... (4 Replies)
Hi all,
I can’t resolve an array element access issue on (Linux/pdksh) .. So I’m positing for advice.By the way - a friend demonstrated to me - same script works as expected under Solaris.
I have been working on a documentation project where many *.jpg screen shots are used in the... (4 Replies)
Hi all,
Not sure if this should be in the programming forum, but I believe it will get more response under the Shell Programming and Scripting FORUM.
Am trying to write a customized df script in Perl and need some help with regards to using arrays and file handlers.
At the moment am... (3 Replies)
Experts,
I am looking to compare elements of 2 array using perl. Below is not the actual code but logic wise something like this.
my $version = "MYSQlcl-5.2.4-264.x86_64"; <-- split this word into array as (5 2 4 264) ( which is to extract only the version number from the package name)
my... (1 Reply)
Hi
I am trying to store the output of a command into an array in perl script.
I am able to store but the problem is i am unable to print the array line with one line space. i mean i inserted the \n in loop ...but not getting the result.
I have written like this
#!/usr/bin/perl
@a =... (2 Replies)
Discussion started by: kumar85shiv
2 Replies
LEARN ABOUT OPENSOLARIS
lptest
lptest(1B) SunOS/BSD Compatibility Package Commands lptest(1B)NAME
lptest - generate line printer ripple pattern
SYNOPSIS
/usr/ucb/lptest [length [count]]
DESCRIPTION
The lptest utility writes the traditional ripple test pattern to the standard output. In 96 lines, the ripple test pattern prints all 96
printable ASCII characters in each position. The ripple test pattern was originally created to test printers. It is also useful for test-
ing terminals, driving terminal ports, debugging, and performing tasks that require a quick supply of random data.
This command is obsolete.
OPTIONS
length Specifies the length of the output line in characters. 79 characters is the default.
count Specifies the number of output lines. 200 lines is the default. If count is specified, length must also be specified.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
non-zero An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWscplp |
+-----------------------------+-----------------------------+
SEE ALSO attributes(5)SunOS 5.11 9 Sep 1996 lptest(1B)