So, I was bored on the train today, and was thinking of ways to loop through elements of an array. I came up with the following simple script, but it doesn't work as brace expansion doesn't seem to work with variables. Is there something I'm missing, or does the shell just not work like this?
So, clearly it is recognizing the variable, but it's not expanding the 1..26. Any thoughts?
Also, I'm aware that this will leave me with the issue that I'm expanding 1-26 when what I really want is 0-25...but I'll burn that bridge later.
We have a script that runs in ksh on HP-UX 11.11. It takes three arguments. The last argument can be a filename or wildcard character. For example:
script -s hello -t goodbye '*.d*'
In a case such as this, I would wrap single quotes around the final argument because I dont want the shell to... (4 Replies)
#!/usr/bin/bash
if
then
echo "Not valid arguments entered. Just username should be entered."
else
USER_NAME=$1
FILE_NAME=$USER_NAME.info
UNN=STUDIN\\\\$1
echo $UNN
last STUDIN\\\\$1
last UNN
If I type `last STUDIN\\eip060` it works but if I try to expand it with variable it is... (5 Replies)
I have a script that takes an option for server pools to run the script against. The option is given as a comma separated list (ie, -p 201,204,301).
I'm using eval and brace expansion to get those pool numbers into an array. It works fine unless only 1 pool number is given. Here's the code:
... (5 Replies)
I'm in the habit of using the following type of loop structure:
for num in `seq $1 $2`
do
command
doneWhile `seq $1 $2` is not exactly a huge resource hog, I would like to learn a better way. It seems that brace expansion is a good way to go:
for num in {3..10}The problem, though, is... (2 Replies)
There is a file as:
....... some text
timing () {
capacitance : 9.0;
incap : 0.8;
cell_fall () {
values ("8.9","7.8");
}
}
........ some more text
#######
Is there a way to directly find closing brace "{" of timing () block "{" ? (2 Replies)
i write a batch file , here is the content.
dirname='date +%Y-%m-%d'
mkdir dirname
but it doen's work, it just create a folder named date and +%Y-%m-%d.
i have tried run the command seperately in the bash prompt. after the first
sentence executed , i use $dirname to watch the value of... (4 Replies)
The objective of the code below is to create sed script to be later executed. However, it bonks because $ARCHIVENAME expands to a directory specification so the forward slashes cause problems. I can think of a few solutions that would involve redesigning the process, but I'm hoping there might be... (4 Replies)
Hi forum,
in my bash script I've many lines executing commands with redirection to log files.
...
xyz_cmd 2>&1 > $BASENAME.$LINENO
The trailing part of these lines doesn't look nice and I like to put it into a variable.
The (not working) idea is something like that
... (3 Replies)
Hello,
I use a lot this command to edit a bunch of files at once
find . -name filename" | xargs -ifoo sh -c 'echo foo ; sed "s/pattern1/pattern2/" foo > ./tmp ; mv -f ./tmp foo'
I'm trying to put a function on my .bashrc file.
function loopSed()
{
local filename=$1
local... (2 Replies)
Hello.
The file /etc/fstab contains
UUID=957c3295-9944-1593-82e2-2b90dede4312 / ext4 noatime,discard,acl,user_xattr 1 1
I fill a variable
SOME_LINE=$( cat /etc/fstab | grep \/\..*ext4 | grep noatime,discard )echo $SOME_LINE... (3 Replies)
Discussion started by: jcdole
3 Replies
LEARN ABOUT OSX
ppi::structure
PPI::Structure(3) User Contributed Perl Documentation PPI::Structure(3)NAME
PPI::Structure - The base class for Perl braced structures
INHERITANCE
PPI::Structure
isa PPI::Node
isa PPI::Element
DESCRIPTION
PPI::Structure is the root class for all Perl bracing structures. This covers all forms of " [ ... ] ", " { ... } ", and " ( ... ) " brace
types, and includes cases where only one half of the pair exist.
The class PPI::Structure itself is full abstract and no objects of that type should actually exist in the tree.
Elements vs Children
A PPI::Structure has an unusual existance. Unlike a PPI::Document or PPI::Statement, which both simply contain other elements, a structure
both contains and consists of content.
That is, the brace tokens are not considered to be "children" of the structure, but are part of it.
In practice, this will mean that while the ->elements and ->tokens methods (and related) will return a list with the brace tokens at either
end, the ->children method explicitly will not return the brace.
STRUCTURE CLASSES
Excluding the transient PPI::Structure::Unknown that exists briefly inside the parser, there are eight types of structure.
PPI::Structure::List
This covers all round braces used for function arguments, in "foreach" loops, literal lists, and braces used for precedence-ordering
purposes.
PPI::Structure::For
Although not used for the "foreach" loop list, this is used for the special case of the round-brace three-part semicolon-seperated "for"
loop expression (the traditional C style for loop).
PPI::Structure::Given
This is for the expression being matched in switch statements.
PPI::Structure::When
This is for the matching expression in "when" statements.
PPI::Structure::Condition
This round-brace structure covers boolean conditional braces, such as for "if" and "while" blocks.
PPI::Structure::Block
This curly-brace and common structure is used for all form of code blocks. This includes those for "if", "do" and similar, as well as
"grep", "map", "sort", "sub" and (labelled or anonymous) scoping blocks.
PPI::Structure::Constructor
This class covers brace structures used for the construction of anonymous "ARRAY" and "HASH" references.
PPI::Structure::Subscript
This class covers square-braces and curly-braces used after a -> pointer to access the subscript of an "ARRAY" or "HASH".
METHODS
"PPI::Structure" itself has very few methods. Most of the time, you will be working with the more generic PPI::Element or PPI::Node
methods, or one of the methods that are subclass-specific.
start
For lack of better terminology (like "open" and "close") that has not already in use for some other more important purpose, the two
individual braces for the structure are known within PPI as the "start" and "finish" braces (at least for method purposes).
The "start" method returns the start brace for the structure (i.e. the opening brace).
Returns the brace as a PPI::Token::Structure or "undef" if the structure does not have a starting brace.
Under normal parsing circumstances this should never occur, but may happen due to manipulation of the PDOM tree.
finish
The "finish" method returns the finish brace for the structure (i.e. the closing brace).
Returns the brace as a PPI::Token::Structure or "undef" if the structure does not have a finishing brace. This can be quite common if the
document is not complete (for example, from an editor where the user may be halfway through typeing a subroutine).
braces
The "braces" method is a utility method which returns the brace type, regardless of whether has both braces defined, or just the starting
brace, or just the ending brace.
Returns on of the three strings '[]', '{}', or '()', or "undef" on error (primarily not having a start brace, as mentioned above).
complete
The "complete" method is a convenience method that returns true if the both braces are defined for the structure, or false if only one
brace is defined.
Unlike the top level "complete" method which checks for completeness in depth, the structure complete method ONLY confirms completeness for
the braces, and does not recurse downwards.
SUPPORT
See the support section in the main module.
AUTHOR
Adam Kennedy <adamk@cpan.org>
COPYRIGHT
Copyright 2001 - 2011 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
perl v5.16.2 2011-02-25 PPI::Structure(3)