Sponsored Content
Full Discussion: Perl: varible-sized arrays?
Top Forums Shell Programming and Scripting Perl: varible-sized arrays? Post 302338018 by KevinADC on Monday 27th of July 2009 01:14:49 AM
Old 07-27-2009
Your question is a bit vague, but to add new data to the end of an array you can the push() function:

@array = ('foo');
push @array,'bar';

now the array has ('foo', 'bar')

You can just keep adding to an array like this until you have used all the available memory, although in practice you don't want to do that. Its just that perl puts no limitations on the size of an array.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using varible/varible substitution in Perl/sed Search & Replace

Hi, I have a program that searches for a particular string patten. I am however having difficulty passing the varible $i (in a loop) as the string pattern to replace. Using either perl or sed search and replace statements, I get the same kinda result. For example, using the perl: for i in... (3 Replies)
Discussion started by: Breen
3 Replies

2. Programming

perl arrays

hello ppl, i'm coding a perl script and i have the following situation: @array1 = ("test1", "test2", "test3"); @array2 = ("something1", "something2", "something1"); $var1 = "with_one_of_the_array1_values"; $var2 = "with_one_of_the_array2_values"; what i want to do is to compare $var1... (2 Replies)
Discussion started by: crashnburn
2 Replies

3. Shell Programming and Scripting

Perl Arrays and Substituion

@xray =~ s/^ *//g; @xray =~ s/ *$//g; @xray =~ s/\s+/ /g; Guess I have a two part question ... First Is there a way to make substitutions, remove leading spaces, trailing spaces, and crunch multiple spaces into a single space, to the entire array, or must the substitutions be done on on... (1 Reply)
Discussion started by: popeye
1 Replies

4. Shell Programming and Scripting

Perl array of arrays

Hi, I am trying to assign an array as a value to one of the array element, I mean I have an array @KS and array @kr. I want array @KS to hold @kr as an element. So I am doin this $KS=@kr; But the value stored is number of elements in the @kr array. Can... (2 Replies)
Discussion started by: eamani_sun
2 Replies

5. Shell Programming and Scripting

perl arrays

Hi I need some help using arrays in perl. I have an array say var and a variable var1. I want to check if the var1 is present in the array. How do I check that ? my @var = 1...10; my $var1 =5; if ( $var1 in @var ) { ....... } else { ....... } Something like above. Can some... (2 Replies)
Discussion started by: ammu
2 Replies

6. Shell Programming and Scripting

Comparing arrays in perl

Hi all, I am trying to compare two arrays in perl using the following code. foreach $item (@arrayA){ push(@arrayC, $item) unless grep(/$item/, @arrayB); ... (1 Reply)
Discussion started by: chriss_58
1 Replies

7. Shell Programming and Scripting

Perl hash containing arrays

Hi, I am not that good at Perl. But here's what I wanna do. I want to create a hash where the keys would point to different arrays. This is what I have tried to do but in vain :( @arr=(1,2,3); @arr1=(3,2,1); %hashOfLists=(); $hashOfLists{Key1}=@arr."\n"; $hashOfLists{Key2}=@arr1."\n";... (3 Replies)
Discussion started by: King Nothing
3 Replies

8. Shell Programming and Scripting

Difference between 2 arrays in perl

Hi, I have 2 arrays: @a=qw(19190289 18381856 12780546 10626296 9337410 8850557 7740161 8101063); @b=qw(18309897 17612870 10626296 16871843 7740161 19947571 18062861); $len=@a; print "<br> length of array1: $len<br>"; $len1=@b; print "<br> length of array2: $len1<br>"; The output... (3 Replies)
Discussion started by: vanitham
3 Replies

9. Shell Programming and Scripting

Arrays in perl

Hi all, I have a log file which has logs. I am reading logs line by line into perl arrays. I want to print all the arrays elements starting from 8(word) to end of the line. print array......array to a new file. and I have to do it in perl as res of the program in perl. Please help me on... (9 Replies)
Discussion started by: firestar
9 Replies

10. Shell Programming and Scripting

perl: compare two arrays

Hi friends, I want to compare two arrays and find matched one using perl? Also, I want to delete unmatched one. Plz suggest me solution (1 Reply)
Discussion started by: Renesh
1 Replies
nice(1) 						      General Commands Manual							   nice(1)

NAME
nice - run a command at nondefault priority SYNOPSIS
command [command_args] command [command_args] DESCRIPTION
The command executes command at a nondefault CPU scheduling priority. (The name is derived from being "nice" to other system users by run- ning large programs at lower priority.) Arguments The command-line arguments are as follows: priority_change The difference between the system nice value (relative priority) of the current (or parent) process and the actual system nice value at which command is to run. An unsigned value increases the system nice value for command, causing it to run at lower priority. A negative value requires superuser privileges, and assigns a lower system nice value (higher priority) to command. If the current process is not privileged, the value is silently treated as if it were 0. If the value of priority_change would result in a system nice value outside the range 0 through 39, the correspond- ing limit value of 0 or 39 is used instead. Note that a positive priority_change (lower priority) has a single option character before the numeric value; a neg- ative (higher priority) priority_change has two: the option character followed by the minus sign If is not speci- fied, it defaults to command A program, HP-UX command, user shell script, etc. to be executed at the nondefault priority. command can be run as a foreground or background process. If command is run as a background process, any nice priority_change made by the shell executes all background pro- cesses via is in addition to that specified in the command line. command_args Any arguments recognized by command. Process Priorities All processes have an associated system nice value which is used to compute the instantaneous-priority of the process when it is scheduled to run. Normally, all processes inherit the system nice value of their parent process when they are spawned. The shell etc.) can create a child process with a different priority from the current shell process by spawning the child process via the command. If the prior- ity_change value is unsigned (positive), the child process is nicer (lower in priority) relative to the parent. If the priority_change value is negative, the child process runs at a higher priority with a greater share of available system resources. To spawn a higher pri- ority child process, the parent process must be owned by a user who has the appropriate privileges. At boot-up, the system starts the process at a system nice value of 20 (system default). On most systems, all processes (down to the login shells) inherit this priority. Starting from their individual login shell processes, users can alter the system nice value of descendent processes to as much as 39, or, with appropriate privileges, as little as 0. A system nice value of 0 establishes an extremely high prior- ity, whereas a value of 39 indicates a very low priority. Ordinary users can only increase the system nice value of any child process relative to the current process; i.e., priority_change must be a positive (unsigned) value, resulting in a lower priority. To start a child process at a lower system nice value (higher priority) than the current process, the user must have the appropriate privileges, regardless of the relative nice-priority value desired. For example, using the command from a login shell whose current nice value is 20 spawns a subshell with a system nice value of 30. Attempting to use from the new shell to spawn another subshell whose system nice value would be 28, is rejected (unless the user has appropriate privileges), even though the resulting system nice value would be less than the priority of the original login shell process. The system nice value for current processes is listed under the column produced by the command (see ps(1)). Background Processes Foreground processes are run at same system nice value as the parent shell. Background processes spawned by run at the equivalent of a by default. If a background process is started via from any priority_change specified in the command is added to default Thus the command runs at a system nice value of 36 if executed from EXTERNAL INFLUENCES
Environment Variables determines the language in which messages are displayed. If is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty vari- able. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See environ(5). International Code Set Support Single- and multi-byte character code sets are supported. RETURN VALUE
returns the value returned by command. EXAMPLES
The following examples assume the current process is running with a system nice value of 20 and is executed from the Korn shell (see ksh(1)). Run a program named in the current directory at the default priority_change of 10 (system nice value of 30): Run the same program in the background using a system nice value of 36 (priority_change=12 plus 4 for the Korn shell): As a user with appropriate privileges, run as a foreground process with a system nice value of 6: WARNINGS
The C shell, has a built-in command with different syntax. See csh(1) for details. SEE ALSO
csh(1), ksh(1), nohup(1), sh-posix(1), sh(1), renice(1M), nice(2). STANDARDS CONFORMANCE
nice(1)
All times are GMT -4. The time now is 02:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy