I'm a newbie ...
Within a xsd schema, I'd like to know is it possible to apply a different rule based on the actual name of the xml file I'm validating?
For example, a specific tag (eg. <devUse>) is valid only for xml files that contain "debug" in their actual xml file name. If the xml file...
string = "id <xx> MM blah blah"
'MM' is a optional value in string ...
If 'MM' exist, I want to capture contents seperately both before and after 'MM'. If 'MM' doesn't exist, just capture the entire string.
examples:
If 'MM' exist ...
/(.*)M{2}(.*)/
$1 = 'id <xx> '
$2 = ' blah blah'
This is...
When running the following 2 lookbehind zero-width assertions :
/(?<!\S)dog/ ##Match a non-non-whitespace char
/(?<=\s)dog/ ##Match a whitespace char
... why would I get different results?
That is, the first lookbehind will match if "dog" is at the beginning of the line, the 2nd lookbehind...
Say I'm executing from the cmd line...
myprogram > RDfile
Is there a way to reference the actual redirected file name 'RDfile' in the ksh script?
Built-in shell variables like $* or $@ don't include any of the tokens right of the ">" cmd.
What about referencing the file descriptor ... how...
Using the -w option doesn't necessarily return a whole word.
For example, if I run /usr/xpg4/bin/grep -w "bird" myfile,
"birdie" will not be returned, but any of the following will:
bird#
bird@
bird$
..etc.
This will cure it, at the cost of longer execution time.
grep...
Using something like ...
@matched = grep /ABC/g, <FILE>;
On a single 16,000 line txt file takes only 0.7 seconds.
but, if I add ...
@matched = grep /ABC|XYZ/g, <FILE>;
On a single 16,000 line txt file takes 17.0 seconds.
Why would adding a alternate pattern sequence cause such an increase in...
if ( $name =~ /$sp/i ) ### works as expected
...but I want to instead use:
my $cs="i"
if ( $name =~ /$sp/$cs ) ### can I somehow use a variable for the modifier?
PS - I don't want to convert everything to a specific case -i.e. - \U
I'm using ksh in Solaris ...
Say I have a simple 4 line file:
30 XB A
30 XB B
30 XB C
30 XB A
I want to sort on the 1st column only and not have another
column (i.e. - 3rd column) influence my result:
I run something like...
sort -k0,1 file
...but, my return result is always:
30 XB...
Using Getopt:Long ...
Is there a way to correctly capture all the files return if the cmd line arg contains a wildcard?
e.g., -f *.dbg ?
Since the shell expands the wildcard prior to perl, double-quoting "*.dbg" will resolves this, but sometimes the users don't always use double-quotes.
I...
In ksh,
${var%%pattern}
%% will remove the longest matching pattern from the right.
% will remove the shortest matching pattern from the right.
so if ...
var="abc7xyz"
echo ${var%7*} ## would display "abc"
How would I do something like this in perl?
How do you get the size of an array inside a hash in 1 step?
this works (2 steps):
$cnt=@{$hash{$key}};
print "cnt is: $cnt\n";
But if I want to do it in 1 step (print):
print "cnt is: @{$hash{key}}\n";
this doesn't work - it returns all the array elements ...
If'm testing to see if initially the hash's array value is empty. If it's not, I want to push a string value to the array.
I'm getting an error when I printing out the hash array values:
"can't use string ("2") as an ARRAY ref while "strict refs" in use".
This simple code works if I don't...
24 hours into my 1st Perl coding, and I'm jumping right into data structures. I'm testing conceptual stuff 1st.I have some questions:
1.) is the line "my %byaid" defined correctly?
2.) where I use "undef"'s, is this right?
3.) why am I not getting what I expect in the output?
Please go easy on...
I supply a script with cmd line args ...
e.g. somescript -a *.msg
When I echo the cmd line arguments in the script:
echo "$@" or with echo "$*"
(I want "-a *.msg")
Using a "set -f" within the script has no effect on the cmd line arguments.
However, if I use a "set -f" at the command prompt...
Is there a simpler way/method to get the return value from a unix cmd then to use the following method:
FILE *in;
char cmd[5] = "pwd";
char buf[100];
in = popen(cmd, "r");
fgets(buf,100,in);
/* or use some form of fscanf(in,%s,buf); */
pclose(in);
It seems that "popen" is the only way to get...
I want to test the "time_str" to see if it's has the correct format. The format should be "##,##,##"
int hr, min, sec;
if sscanf( time_str, "%i %*[,] %i %*[,] %i", &hr, &min, &sec) !=3)
If a user enters for "time_str" something like:
02x,05,05 or 02,05x,05
the conversion will fail based on...
Is there a way to tar-up a directory containing sub-directories so that the resulting tar file just contains the file names from the sub-directories and doersn't include the name of the sub-dirs?
e.g.:
> /test/one/file1.txt
> /test/two/file2.txt
and run something like ... tar -cvf final.tar *...
I can ...
> exec dtterm -title "mytitle" -e ls -la
but in doing so the new shell closes when the cmd is completed plus it closes the the calling shell!
If I ...
> eval dtterm -title "mytitle" -e ls -la , at least the calling shell doesn't close.
Is there a way to keep the new shell open...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.