d5e5 109 Master Poster

Try this. I didn't have much time for testing but it seems OK to me.

import re

def main():
    pattern = r'pow\((\w+),\(?(-?\w+)\)?\)'
    expr0 = 'p_neg1_1_n/pow(deltax,-4) - 4*p_0_1_n/pow(deltax,4)'    
    expr1 = 'p_neg1_1_n/pow(deltax,(-4)) - 4*p_0_1_n/pow(deltax,(4))'
    
    print re.sub(pattern , r'\1^\2', expr0)
    print re.sub(pattern , r'\1^\2', expr1)

if __name__ == "__main__":
    main()
nkinar commented: Wonderful; thank you so much +1
d5e5 109 Master Poster

I'm using Python to post-process the output of a program that creates strings of C code. The plot thickens, since the program can also create the following types of (more complicated) expressions:

expr0 = 'p_neg1_1_n/pow(deltax,-4) - 4*p_0_1_n/pow(deltax,4)'    
    expr1 = 'p_neg1_1_n/pow(deltax,(-4)) - 4*p_0_1_n/pow(deltax,(4))'

In these expressions, the number can be -4, or the number can occur in brackets (-4), or (4). I believe that this is valid C-code syntax.

Using regular expressions, is there a way to deal with expr0 and expr1 so that pow(deltax,(-4)) becomes deltax^-4 and pow(deltax,(4)) becomes deltax^4 ?

I don't know. It seems like a tough one. I think it may require applying a substitution to an expression and then applying another substitution to the resulting string? If I think of a solution later I'll let you know.

d5e5 109 Master Poster

David,

Once again you are the man ! Just wonderful, of course it works exactly how I needed it !

I know you're in Canada but if one day you come to Paris you've just won a flight in a light plane. And as I'm flying next to Versailles and his famous castle there's a nice view of it and Paris ! :-) -and really I mean it, I'd be glad to show you this wonderful view- !

Thanks once again

Regards
Bastien

Bastien,
Je vous en prie. You are welcome and thanks for the offer. My wife and I would love to see Paris, although we have no overseas trips planned for the next few years. Maybe some day.:)

Regards,
David

d5e5 109 Master Poster

One dot represents one character. Since now you want to match 'deltax', which contains several characters, you can add the plus sign to mean 'one or more characters'. But that matches too much. You want to match only 'deltex', not 'deltax,4) - 4*p_0_1_n/pow(deltax,4)'.

Let's use (\w+) instead of (.+). \w represents only alphanumeric characters, so it will stop matching at the comma, which is what you want.

import re

def main():

    expr = 'p_neg1_1_n/pow(deltax,4) - 4*p_0_1_n/pow(deltax,4)'
    print re.sub(r'pow\((\w+),(\w+)\)' , r'\1^\2', expr)

if __name__ == "__main__":
    main()
nkinar commented: Excellent response; again, thank you! +1
d5e5 109 Master Poster

Escape the open and close parentheses that are meant as literal characters and enclose the data that should be captured in parentheses to create two capture groups. These two capture groups are referenced in your replacement string as \1 and \2.

#!/usr/bin/env python
import re

def main():
    expr = '5*pow(a,b) + 3*pow(b,c) + 3*a + 4*b'
    print re.sub(r'pow\((.),(.)\)' , r'\1^\2', expr)

if __name__ == "__main__":
    main()
nkinar commented: Great solution; thank you very much +1
d5e5 109 Master Poster

I tested with the following old entries in 1.csv

user,Petergr," CN=Peter Graham,OU=Newport,DC=cp,dc=com"
user,Janiebo," CN=Janie Bourne,OU=Newport,DC=cp,dc=com"
user,Edgardu," CN=Edgar Dunn,OU=Newport,DC=cp,dc=com"
user,Belindaha," CN=Belinda Hart,OU=Newport,DC=cp,dc=com"
user,Mayja," CN=May Jamieson,OU=Newport,DC=cp,dc=com"
user,Leroyot," CN=Leroy Ota,OU=Newport,DC=cp,dc=com"

I modified the 4th line and added a 7th line to the above and saved it as 2.csv

user,Petergr," CN=Peter Graham,OU=Newport,DC=cp,dc=com"
user,Janiebo," CN=Janie Bourne,OU=Newport,DC=cp,dc=com"
user,Edgardu," CN=Edgar Dunn,OU=Newport,DC=cp,dc=com"
user,Belindajo," CN=Belinda Jones,OU=Newport,DC=cp,dc=com"
user,Mayja," CN=May Jamieson,OU=Newport,DC=cp,dc=com"
user,Leroyot," CN=Leroy Ota,OU=Newport,DC=cp,dc=com"
user,Rabbitbr," CN=Rabbit Brer,OU=Newport,DC=cp,dc=com"

The following program should print only the data for Belindajo and for Rabbitbr, because all the other lines in 2.csv exist in 1.csv and so are not new.

#!/usr/bin/perl
#find_new_records.pl
use strict;
use warnings;

my $dir = '/home/david/Programming/Perl/data';
my $f1 = "$dir/1.csv";
my $f2 = "$dir/2.csv";
open FILE1, "$f1" or die "Could not open $f1: $! \n";

my %results = ();#Hash to store lines from files
my %meaning = (-1, "In new file but not in old file",
               0, "In both new and old files",
               1, "In old file but not in new file",); #Hash associating values with statuses

while(my $line = <FILE1>){
    chomp $line;
    $results{$line}=1;
}
close(FILE1);

open FILE2, "$f2" or die "Could not open $f2: $! \n";
while(my $line =<FILE2>) {
    chomp $line;
    $results{$line}--; #Instead of incrementing by one...
}
close(FILE2);

foreach(keys %results){
    print "Key $_\n" if $results{$_} == -1;
}

The above gives me the following output:

Key user,Rabbitbr," CN=Rabbit Brer,OU=Newport,DC=cp,dc=com"
Key user,Belindajo," CN=Belinda Jones,OU=Newport,DC=cp,dc=com"
BastienP commented: Great stuff, as usual !!!! +1
d5e5 109 Master Poster

What is the encoding of your file? Files contain bytes of data, not characters. The bytes represent characters only according to whatever encoding was used to write the data to your file.

Ask whoever created your data file what encoding they used. Or, you could attach the file to your post here and we could try guessing the encoding. But the encoding is determined by the program that wrote data to the file and there is no completely reliable way to guess what the encoding is.

d5e5 109 Master Poster

What you have in your file are bytes of data. When you read a record from the file you get a string of bytes. If these bytes are supposed to represent text characters, they must have been encoded in some format, such as utf8, before being written to the file.

You haven't said whether you use Python 2 or 3, or what encoding the file has. Unicode is not an encoding -- I think there are several encodings that can represent Persian characters. There is a brief slide show at http://farmdev.com/talks/unicode/ which may help you.

d5e5 109 Master Poster

I don't understand the use of the # in your message. It indicates a comment in perl. If I were you I'd RTFM, of which David posted an important portion. If you do the regex as David suggested, you'll remove all non-letter/number/dash/underscore characters and you'll never have to run the error code. I think you either need to test for their existence and print the error or remove them, but not both.

Good point. my $teacher =~ s/[^A-Za-z0-9\-_]//g; removes all characters that are not letters, numbers, hyphen or underscore, but this is NOT what you say you want to do. You want to know if your regex matches any invalid characters; you don't want to substitute anything. The s prefix means 'substitute'. You want to match instead of substitute. There are plenty of examples of matching in http://perldoc.perl.org/perlrequick.html#Simple-word-matching and http://perldoc.perl.org/perlrequick.html#Using-character-classes

d5e5 109 Master Poster

Near the beginning of the documentation for Getopt::Long it says "To distinguish between a bundle of single-character options and a long one, two dashes are used to precede the option name." You would type the following at your command line to run your script.pl perl script.pl --teacher In every perl script that you write you should use strict; and use warnings; ... they sometimes tell you why your program may not do what you expect.

The following: #my $teacher =~ s/[^A-Za-z0-9\-_].//#//g; violates the syntax rules because the semicolon does not terminate the command. Putting a semicolon in a comment doesn't do anything.

Maybe you meant this instead? my $teacher =~ s/[^A-Za-z0-9\-_]//g;#Remove characters not in the good set But how can you remove characters from $teacher, which comes from Getopt::Long::GetOptions("teacher=s" => \$teacher); BEFORE the statement that gets the teacher option? The statements occur in the wrong sequence in your script.

Plus you put brace brackets around your condition instead of parentheses, and your print statement should be enclosed in brace brackets because you want it to be in a block following your unless condition.

d5e5 109 Master Poster

I love the fact that David and I came up with 2 separate solutions that both work. Gotta love perl. I thought about the "slurping" solution and then decided against it - not because it is wrong of inefficient - David showed it is very efficient - I just went with the "flagging" idea instead. His regexes are probably better than mine - it was never my strong suit.

Thanks Mike. On the other hand, your solution would not trip up if the file happened to have some extra non-comment words before the first KEYWORD literal. Plus not slurping allows you to handle gigantic data files that might fill up the memory (I have no idea how big a file it would take to cause a problem but it's always good to have another approach available if the need arises.)

d5e5 109 Master Poster
#!/usr/bin/perl
#parse_file_kv.pl
use strict;
use warnings;

#For convenience I read from DATA section. You can open a file instead.
my $save_input_record_separator = $/; #Save original value before changing it
undef $/; # enable slurp mode
my $file = <DATA>;
$/ = $save_input_record_separator; #Restore original value to this global variable

$file =~ s/#.*\n//g; #Remove comments
$file =~ s/KEYWORD\s*//g; #Remove KEYWORD followed by optional whitespace
my %h = $file =~ m/\w+/g;#Read keys and values from file into hash %h

for (keys %h){
    print "KeyWord $_ has value $h{$_}.\n";
}
print "\n";

my @kws2find = qw(MACHINENAME TARKETSYSTEM HIHO);

foreach ( @kws2find ){
    find_value($_);
}

sub find_value{
    my $kw = shift @_;
    if (exists $h{$kw}){
        print "Value of $kw is $h{$kw}\n";
    }else{
        print "Keyword $kw is not found in hash\n";
    }
}

__DATA__
#Example1 – I have to find the MACHINENAME value which is atab15
########## comment
KEYWORD MACHINENAME #comment
## comment
atab15 # comment

#Example2 – I have to find the TARKETSYSTEM value sunSolaris
KEYWORD TARKETSYTEM
sunSolaris

#Example3 – I have to find the HIHO value goodbye
KEYWORD HIHO
Goodbye

Gives the following output:

KeyWord MACHINENAME has value atab15.
KeyWord TARKETSYTEM has value sunSolaris.
KeyWord HIHO has value Goodbye.

Value of MACHINENAME is atab15
Keyword TARKETSYSTEM is not found in hash
Value of HIHO is Goodbye
d5e5 109 Master Poster

The trailing space in $lkup_cd1 spoils the test for '.LOC'. I changed only the following subroutine.

sub compareinstances
{
    my $x = shift @_;
    my $y = shift @_;
    my $modcodefrom1 = $instances_1[$x];
    my $modcodefrom2 = $instances_2[$y];
    my $inst_name1;
    if($modcodefrom1 =~ m/\)\s*\)\s*(.*)\s*\(\s*\./) {
        $inst_name1 = $1;
    }
    print "instance name of $modul from file1 $filename1 is $inst_name1\n";
   
    my $inst_name2;
        if($modcodefrom2 =~ m/\)\s*\)\s*(.*)\s*\(\s*\./) {
            $inst_name2 = $1;
        }
    print "instance name of $modul from file2 $filename2 is $inst_name1\n ";
   my @codes1 = split /\,/,  $modcodefrom1;
   my @codes2 = split /\,/,  $modcodefrom2;
   
    print "\t\t****************THE DIFFERENCES IN THE FILES ARE AS FOLLOWS****************\n\n\n";
   
    printf "\t\t%-45s \t\t\t%s\n\n\n", $filename1, $filename2;

    foreach (@codes1){
    if ( m/
        (         #capture following to $1
         (        #capture following to $2
         \.       #dot
         [^(]+    #one or more characters excepting (
        )         #end of capture group $2
         \s*      #possibly some spaces or newlines
         \(       #followed by open (
           [^)]*? #possibly some characters excepting )
           \)     #followed by close )
         )        #end of capture group $1
          /x ){   #end of match condition. x means ignore spaces and allow comments
        my $all_code_1 = $1;
        my $lkup_cd1 = $2;
        
        #The problem was $lkup_cd1 often has a trailing space
        #So in the following condition we must test if equal to '.LOC ' with trailing space
        next if ( $lkup_cd1 eq '.LOC' or $lkup_cd1 eq '.LOC '); #Skip to next iteration of loop
        
        #print "Look up $lkup_cd1\n"; #I print here for testing. May want to comment it out.
        
        my $code2compare = lookup_code2($lkup_cd1, \@codes2);
        
        unless ( $all_code_1 eq …
d5e5 109 Master Poster

I'm glad it works. I bought Beginning Perl by Simon Cozens 5 years ago and have read it all through. I have referred to it often. Now it is available for free online. Learning Perl, by Randal Schwartz and others is good too, but not free.

A good source of documentation and tutorials would be perl.org. When I'm stuck I google perl plus a few key words. Often the answer turns up on stackoverflow.com, perl.org, perlmonks.org, about.perl.com and of course, daniweb.com.

d5e5 109 Master Poster
#!/usr/bin/perl
use strict;
use warnings; 

my $filename1='/home/david/Programming/Perl/data/filename1.txt';
my $filename2='/home/david/Programming/Perl/data/filename2.txt';
my $modul='X_RAMD32';
print " --------------------------------File1: $filename1\t\t File2:$filename2    -------------------------------------\n\n"; 
print "Module selected for comparision $modul\n\n";
my $string1 = readfile( $filename1);
my $string2 = readfile( $filename2); 
$string1 =~ s/[[:cntrl:]]//gm; 
$string2 =~ s/[[:cntrl:]]//gm; 

$string1 =~ /($modul\s#\(.*\);)/gs;
my $instancesfrom1 = $1;
undef $string1;
my @instances_1 = $instancesfrom1 =~ /$modul #\(([^;]*)\);/g;
my $instancescount1 = @instances_1;
print "Found $instancescount1 instances of $modul in the $filename1\n";

$string2 =~ /($modul\s#\(.*\);)/gs;
my $instancesfrom2 = $1;
undef $string2;
my @instances_2 = $instancesfrom2 =~ /$modul #\(([^;]*)\);/g;
my $instancescount2 = @instances_2;
print "Found $instancescount2 instances of $modul in the $filename2\n";

#die "$filename1 doesn't have same number of instances of $modul as $filename2!"
 #   unless $instancescount1 == $instancescount2;
my $i=1;
my %instance_index_1 = buildindexhash(\@instances_1);
my %instance_index_2 = buildindexhash(\@instances_2);

foreach(sort keys %instance_index_1){
    if (exists $instance_index_2{$_}){
        print "Comparing $i Instance $_------\n";
        compareinstances($instance_index_1{$_}, $instance_index_2{$_});
    }
    else{
        print "Instance $_ not found in second file.------\n";
    }
$i++;
}

sub buildindexhash{
    my @arr = @{$_[0]}; 
    my %h;
    my $i;
    foreach (@arr){
        $_ =~ m/\)\s*\)\s*(.*)\s*\(\s*\./;
        $h{$1} = $i++;
    }
    return %h;
}

sub compareinstances
{
    my $x = shift @_;
    my $y = shift @_;
    my $modcodefrom1 = $instances_1[$x];
    my $modcodefrom2 = $instances_2[$y];
    my $inst_name1;
    if($modcodefrom1 =~ m/\)\s*\)\s*(.*)\s*\(\s*\./) {
        $inst_name1 = $1;
    }
    print "instance name of $modul from file1 $filename1 is $inst_name1\n";
   
    my $inst_name2;
        if($modcodefrom2 =~ m/\)\s*\)\s*(.*)\s*\(\s*\./) {
            $inst_name2 = $1;
        }
    print "instance name of $modul from file2 $filename2 is $inst_name1\n ";
   my @codes1 = split /\,/,  $modcodefrom1;
   my @codes2 = split /\,/,  $modcodefrom2;
   
    print "\t\t****************THE DIFFERENCES …
d5e5 109 Master Poster
#!/usr/bin/perl
use strict;
use warnings; 
my $filename1='/home/david/Programming/Perl/data/filename1.txt';
my $filename2='/home/david/Programming/Perl/data/filename2.txt';
my $modul='X_RAMB18E1';
print " --------------------------------File1: $filename1\t\t File2:$filename2    -------------------------------------\n\n"; 
print "Module selected for comparision $modul\n\n";
my $string1 = readfile( $filename1);
my $string2 = readfile( $filename2); 
$string1 =~ s/[[:cntrl:]]//gm; 
$string2 =~ s/[[:cntrl:]]//gm; 

$string1 =~ /($modul\s#\(.*\);)/gs;
my $instancesfrom1 = $1;
undef $string1;
my @instances_1 = $instancesfrom1 =~ /$modul #\(([^;]*)\);/g;
my $instancescount1 = @instances_1;
print "Found $instancescount1 instances of $modul in the $filename1\n";

$string2 =~ /($modul\s#\(.*\);)/gs;
my $instancesfrom2 = $1;
undef $string2;
my @instances_2 = $instancesfrom2 =~ /$modul #\(([^;]*)\);/g;
my $instancescount2 = @instances_2;
print "Found $instancescount2 instances of $modul in the $filename2\n";

die "$filename1 doesn't have same number of instances of $modul as $filename2!"
    unless $instancescount1 == $instancescount2;
my $i;

my %instance_index_1 = build_index_hash(\@instances_1);
my %instance_index_2 = build_index_hash(\@instances_2);

foreach(sort keys %instance_index_1){
    if (exists $instance_index_2{$_}){
        print "Comparing Instance $_------\n";
        compareinstances($instance_index_1{$_}, $instance_index_2{$_});
    }
    else{
        print "Instance $_ not found in second file.------\n"
    }
}

sub build_index_hash{
    my @arr = @{$_[0]}; #dereference passed parameter
    my %h;
    my $i;
    foreach (@arr){
        $_ =~ m/\)\s*\)\s*(.*)\s*\(\s*\./;
        $h{$1} = $i++;
    }
    return %h;
}

sub compareinstances
{
    my $x = shift @_;
    my $y = shift @_;
    my $modcodefrom1 = $instances_1[$x];
    my $modcodefrom2 = $instances_2[$y];
    my $inst_name1;
    if($modcodefrom1 =~ m/\)\s*\)\s*(.*)\s*\(\s*\./) {
        $inst_name1 = $1;
    }
    print "instance name from 1 is $inst_name1\n";
   
    my $inst_name2;
        if($modcodefrom2 =~ m/\)\s*\)\s*(.*)\s*\(\s*\./) {
            $inst_name2 = $1;
        }
    print "instance name from 2 is $inst_name2\n ";
   my @codes1 = split /\,/,  $modcodefrom1;
   my @codes2 = split /\,/,  $modcodefrom2;
   
    print "\t\t****************THE DIFFERENCES IN THE FILES ARE AS FOLLOWS****************\n\n\n"; …
d5e5 109 Master Poster

d5e5, thanks, in the meantime also for your reply!
so, is my for loop or your push-foreach solution quicker?

I don't know which runs quicker. My push foreach is quicker for me to understand, but maybe that's just a personal preference.

I haven't benchmarked it but I suspect a map statement would be the fastest to run, because perl already has the loop logic pre-defined in the map function.

map $data[$_] = 0, (0..$how_many_bins - 1); #This may run faster than foreach loop.
d5e5 109 Master Poster

Initialising the array in advance with a loop doesn't seem like a bad approach, either. It takes only about one line.

#!/usr/bin/perl
use strict;
use warnings;

my @data = (); #Empty array with no elements
my $how_many_bins = 25; #Arbitrary example

#The following loop pushes a zero into the array for each element of a range.
#Remember array indexing starts at 0 so greatest index = $how_many_bins - 1
push @data, 0 foreach (0..$how_many_bins - 1);

print join ', ', @data;
d5e5 109 Master Poster

I think that for this we don't need to extract the separate instances and split the codes. We can apply the regex to the string from the file instead. This time we don't remove the newlines.

#!/usr/bin/perl
use strict;
use warnings;

#Prepare regex pattern as follows (better to prepare complex rexex in advance)
my $pattern = '\\\U_eth_aggregator_tb/eth_aggregator/core_0/.+\(';
my $re = qr/$pattern/m;

my $filename1='/home/david/Programming/Perl/data/filename1.txt';

my $modul='X_RAMB18E1';
my $string1 = readfile( $filename1);

my $count = 0;
my @matches = $string1 =~ m/$re/g;
foreach (@matches){
        $count++;
        print "Occurence number $count of the pattern:\n$_\n\n";
}

sub readfile {
    my $file = shift;
    local $/;
    open my $fh,'<',"$file" or die "open of $file failed: $!\n";
    <$fh>;
};

Running the above on the filename1.txt that you attached gives the following output:

Occurence number 1 of the pattern:
\U_eth_aggregator_tb/eth_aggregator/core_0/client_side_FIFO0/tx_fifo_i/ramgen_l  (

Occurence number 2 of the pattern:
\U_eth_aggregator_tb/eth_aggregator/core_0/client_side_FIFO0/tx_fifo_i/ramgen_u  (
d5e5 109 Master Poster

Check if executing:

SET names utf8

after connecting to the database will fix the problem.

Yes. Apparently this is an MySQL bug, according to this link: http://bugs.mysql.com/bug.php?id=10812

d5e5 109 Master Poster
#!/usr/bin/perl
use strict;
use warnings;

my $filename1='/home/david/Programming/Perl/data/filename1.txt';
my $filename2='/home/david/Programming/Perl/data/filename2.txt';

my $modul='X_RAMB18E1';
my $string1 = readfile( $filename1);
my $string2 = readfile( $filename2); 
$string1 =~ s/[[:cntrl:]]//gm; #Might as well get rid of newlines, etc. now
$string2 =~ s/[[:cntrl:]]//gm; #Might as well get rid of newlines, etc. now

#Extract instances of module from first file
$string1 =~ /($modul\s#\(.*\);)/gs;
my $string_of_instances_from_1 = $1;
undef $string1;
my @instances_1 = $string_of_instances_from_1 =~ /$modul #\(([^;]*)\);/g;
my $count_of_instances_1 = @instances_1;
print "Found $count_of_instances_1 instances of $modul in the string.\n";

#Extract instances of module from first file
$string2 =~ /($modul\s#\(.*\);)/gs;
my $string_of_instances_from_2 = $1;
undef $string2;
my @instances_2 = $string_of_instances_from_2 =~ /$modul #\(([^;]*)\);/g;
my $count_of_instances_2 = @instances_2;
print "Found $count_of_instances_2 instances of $modul in the string.\n";


die "$filename1 doesn't have same number of instances of $modul as $filename2!"
    unless $count_of_instances_1 == $count_of_instances_2;

my $i;
foreach(0..$#instances_1){
    $i = $_ + 1;
    print "Comparing Instance $i:-----------------------------------\n";
    compare_instances($_);
}

sub compare_instances{
    my $idx = shift @_; #Assign passed parameter to index variable
    my $modcode_from_1 = $instances_1[$idx];
    my $modcode_from_2 = $instances_2[$idx];
    my @codes1 = split /\,/,  $modcode_from_1;
    my @codes2 = split /\,/,  $modcode_from_2;
    print "\t\t****************THE DIFFERENCES IN THE FILES ARE AS FOLLOWS****************\n\n\n";
    printf "\t\t\t%-45s %s\n\n\n", $filename1, $filename2;
    my $i = 0;
    foreach ( @codes1) {
        unless ( $codes1[$i] eq $codes2[$i]) {
        printf "\t%-45s is not the same as %s\n\n", $codes1[$i], $codes2[$i];
        }
    $i++;
    }
}

sub readfile {
    my $file = shift;
    local $/;
    open my $fh,'<',"$file" or die "open of $file failed: $!\n";
    <$fh>;
};
d5e5 109 Master Poster

Sorry for so many posts, but:

$f=~s/<!--[\w\W]*-->//gi;

works

#!/usr/bin/perl
#remove_comments.pl
use strict;
use warnings;

#Put sample xsd file contents into a string for purpose of testing
my $f = <<END;
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!-- definition of simple elements -->
<xs:element name="orderperson" type="xs:string"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<!--Here is a multi-line
comment to remove
for test purposes -->
<xs:element name="country" type="xs:string"/>
<xs:element name="title" type="xs:string"/>
<xs:element name="note" type="xs:string"/>
<xs:element name="quantity" type="xs:positiveInteger"/>
<xs:element name="price" type="xs:decimal"/>

<!-- definition of attributes -->
<xs:attribute name="orderid" type="xs:string"/>

<!-- definition of complex elements -->
<xs:element name="shipto">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="name"/>
      <xs:element ref="address"/>
      <xs:element ref="city"/>
      <xs:element ref="country"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

<xs:element name="item">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="title"/>
      <xs:element ref="note" minOccurs="0"/>
      <xs:element ref="quantity"/>
      <xs:element ref="price"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

END

$f=~s/<!--[\w\W]*-->//gi;#regex has greedy quantifier *
print $f;

Running the above gives the following output:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">


<xs:element name="shipto">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="name"/>
      <xs:element ref="address"/>
      <xs:element ref="city"/>
      <xs:element ref="country"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

<xs:element name="item">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="title"/>
      <xs:element ref="note" minOccurs="0"/>
      <xs:element ref="quantity"/>
      <xs:element ref="price"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

Looks like it removed way too much code along with the comments! The regex I suggested had the same flaw, which I realised only after further testing today. Let's try adding a ? after the * to make the quantifier lazy so it won't remove so much. Change your regex to this: $f=~s/<!--[\w\W]*?-->//gi;#regex has lazy quantifier *? After making this change, running the test program gives the following …

d5e5 109 Master Poster

For the purpose of giving a simple example of extracting more than one instance from a string, I hard-coded a sample string instead of reading from your files. Notice that you can store the instances in an array instead of a single scalar variable.

#!/usr/bin/perl
use strict;
use warnings;

my $string_of_instances = <<END;
SIMPLE_MODULE #(
aa
bb
cc
dd
);

SIMPLE_MODULE #(
aa
bx
cx
dd
);

END

my @instances = $string_of_instances =~ /SIMPLE_MODULE #\(([^;]*)\);/gs;
my $count_of_instances = @instances;
print "Found $count_of_instances instances of SIMPLE_MODULE in the string.\n";

foreach (@instances){
    do_something($_);
}

sub do_something{
    #This subroutine is just a stub.
    #You can add logic to do what you want for each instance.
    my $mod_instance = shift(@_); #Assign passed parameter
    print "The following is one of the instances:\n$mod_instance\n";
    print '-' x 70, "\n";
}

Running the above prints the following output:

Found 2 instances of SIMPLE_MODULE in the string.
The following is one of the instances:

aa
bb
cc
dd

----------------------------------------------------------------------
The following is one of the instances:

aa
bx
cx
dd

----------------------------------------------------------------------
d5e5 109 Master Poster

Try the following. I made a couple of changes to your script, indicated by comments. I changed the regex slightly because $f=~s/<!--[^>]*-->//g; will not remove comments if the character '>' occurs anywhere between the comment tags. It's better to use a dot that represents all characters.

#!/usr/bin/perl
use strict;
use warnings;
use File::Find;

#undef($/); Better to take care of $/ in subr as local variable

my $directory = "/home/user/perltest";
find (\&subr, $directory);

sub subr
{
    foreach ($File::Find::name=~/.*\.xsd$/) {
        open (FILE, "<", $File::Find::name);
        local $/;
        my $f=<FILE>;
        print $f;
        $f=~s/<!--.*-->//gs; #s option means dot (.) includes newline character
        close FILE;
        open (OUT, ">", $File::Find::name);
        print OUT $f;
        close OUT;
    }
}
d5e5 109 Master Poster

Also how would i do this by date also, eg if i only want to show the total profit between 2 certain dates what the code be?

There is a date field in the database.

If your date field is called 'dt', for example, you can modify your query as follows:

$query = "SELECT SUM(Profit) FROM your_tbl WHERE dt BETWEEN '2005-01-01' AND '2005-12-31'";
d5e5 109 Master Poster

As long as the duplicate rows you were getting had the same values for the columns NOT in your GROUP BY it should not cause you a problem. MySQL allows you to have columns in your SELECT that are not in your GROUP BY, but their values are arbitrarily chosen from the rows that are grouped. If the values of these non-GROUP BY columns are the same within groups, then no problem.

Other databases are not so permissive and some writers recommend that you avoid this in MySQL as well. For example, see http://www.mysqlperformanceblog.com/2006/09/06/wrong-group-by-makes-your-queries-fragile/

d5e5 109 Master Poster
<?php

$full = '%B1500000000000015^EMPLOYEEID/SMITH John^031110100000019301000000877000000?;500000000000015=0305101193010877?';
$chunks = explode('?', $full);
echo $chunks[0] . '?';

?>

It looks like you want the value of $StringVar2 to equal that of $StringVar1. Is that correct?

d5e5 109 Master Poster
<?php
require('includes/init_mysql.php');
$con = mysql_connect($db_host,$db_user,$db_pass);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("daniweb", $con);

$sql = "SELECT SUM(ct) FROM `test2`";

$result = mysql_query($sql) or die(mysql_error());

while($row = mysql_fetch_array($result)){
	echo "Total ". $row['SUM(ct)'];
}

mysql_close($con);
?>

This displays Total 6 on my browser. My code is the same as yours except for the name of the column ('ct' instead of 'Profit') and table ('test2' instead of 'table'). Are you sure your table really has a column named 'Profit' and does it have data? Is your table really named 'table'. I don't know if naming your table 'table' is causing a problem but in principle it's not good practice to name a table after an SQL reserved word such as 'table'.

d5e5 109 Master Poster

I haven't tested it but I think that either using DISTINCT or GROUP BY should eliminate the duplicate rows from your results. Try

SELECT DISTINCT clients.ClientID, clients.ClientUserID, clients.AddedByUserID, users.UserID, users.FullName, users.AccessLevel
FROM users LEFT JOIN clients on users.UserID = clients.ClientUserID
WHERE users.AccessLevel = 1  or (clients.ClientUserID = users.UserID)and clients.ClientID = ParamClientID

or else maybe

SELECT clients.ClientID, clients.ClientUserID, clients.AddedByUserID, users.UserID, users.FullName, users.AccessLevel
FROM users LEFT JOIN clients on users.UserID = clients.ClientUserID
WHERE users.AccessLevel = 1  or (clients.ClientUserID = users.UserID)and clients.ClientID = ParamClientID
GROUP BY clients.ClientID, clients.ClientUserID, clients.AddedByUserID, users.UserID, users.FullName, users.AccessLevel
d5e5 109 Master Poster
#!/usr/bin/perl
use strict;
use warnings;
my %years; #Hash to save year as key, count as value
while (<DATA>){
    chomp;
    $years{$_}++;
}
printf "%-10s %s\n",'year', 'count';
foreach (sort keys %years){
    printf "%-10s %d\n",$_, $years{$_};
}
__DATA__
1913
1913
1917
1917
1917
1917
1917
1955
1955
d5e5 109 Master Poster

You are welcome. Please mark the thread solved. It helps keep our forum organised. :)

d5e5 109 Master Poster
#!/usr/bin/perl
#compare_files.pl
use strict;
use warnings;
my $dir = '/home/david/Programming/Perl/data';
my $filename1 = '1.txt';
my $filename2 = '2.txt';

sub slurp_file {
    #This subroutine takes the path and filename of an input file
    # and returns a filehandle referencing the entire contents.
    my ($dir,$file) = @_;
    local $/;
    open my $fh,'<',"$dir/$file" or die "open of $dir/$file failed: $!\n";
    <$fh>;
    };

my $string1 = slurp_file($dir, $filename1); # $string1 now contains contents of 1.txt

my $string2 = slurp_file($dir, $filename2); # $string2 now contains contents of 2.txt

$string1 =~ /i_MMCM_ADV \(([^;]*)\);/s;
my $modcode_from_1 = $1;
undef $string1; #Don't need $string1 any more.
$modcode_from_1 =~ s/[[:cntrl:]]//gm; #Remove control characters

$string2 =~ /i_MMCM_ADV \(([^;]*)\);/s;
my $modcode_from_2 = $1;
undef $string2; #Don't need $string2 any more.
$modcode_from_2 =~ s/[[:cntrl:]]//gm; #Remove control characters

my @codes1 = split /\./, $modcode_from_1;
my @codes2 = split /\./, $modcode_from_2;

printf "%-35s %s\n", $filename1, $filename2;
my $i = 0;
foreach (@codes1) {
    unless ($codes1[$i] eq $codes2[$i]) {
        printf "%-35s is not the same as %s\n", $codes1[$i], $codes2[$i];
    }
    $i++;
}

Running this prints the following output:

1.txt                               2.txt
CLKIN1(clk_IBUF_7819),              is not the same as CLKIN1(clk_IBUF_2571),    
CLKOUT0(clk_out0_OBUF_7848),        is not the same as CLKOUT0(clk_out0_OBUF_2333),    
LOCKED(i_MMCM_ADV_ML_NEW_I1),       is not the same as LOCKED(LOCKED_OBUF_2386),
koduruabhinav commented: excellent answer +1
d5e5 109 Master Poster

The first part, storing the contents of the files into string variables and then extracting the module code from each into two string variables:

#!/usr/bin/perl
#extract_mods_to_strings.pl
use strict;
use warnings;
my $dir = '/home/david/Programming/Perl/data';
my $filename1 = '1.txt';
my $filename2 = '2.txt';

#The following way of 'slurping' files into strings adapted from
# http://www.perlmonks.org/?node_id=287647

my $string1 = do {
    local $/;
    open my $handle1,'<',"$dir/$filename1" or die "open of $dir/$filename1 failed: $!\n";
    <$handle1>;
    }; # $string1 now contains contents of 1.txt

my $string2 = do {
    local $/;
    open my $handle2,'<',"$dir/$filename2" or die "open of $dir/$filename2 failed: $!\n";
    <$handle2>;
    }; # $string2 now contains contents of 2.txt

$string1 =~ /i_MMCM_ADV \((.*)\);/s;
my $modcode_from_1 = $1;

$string2 =~ /i_MMCM_ADV \((.*)\);/s;
my $modcode_from_2 = $1;

print "Here is the module code from $filename1---------------------:\n";
print $modcode_from_1;
print "\n\n";
print "Here is the module code from $filename2---------------------:\n";
print $modcode_from_2;

I don't know how the comparison should be done and what constitutes a unit of code to compare and print.

d5e5 109 Master Poster

What database are you using? I ran something similar to the above in MySQL and didn't get the error. When I used to work with Oracle and MS-Access databases I remember getting errors like that.

If you are using MySQL as your database, do you by any chance have ONLY_FULL_GROUP_BY SQL mode enabled? See this link for the reason you shouldn't be getting this error in MySQL: http://dev.mysql.com/doc/refman/5.0/en/group-by-hidden-columns.html

d5e5 109 Master Poster

[QUOTE=keavon;1321201]Yay it works.... Uh, oh, wait, it still has the cleared variables... That's not good! when it emails me, it says @example.com
That's not good... Hmmm... I might try the other person's option, strange. My code is:

<?php
session_start();
//you are arriving from index.php
if( isset($_POST['Submitter']) && !empty($_POST['Submitter']) )
{
    //save the data you posted from index.php
    foreach($_POST as $k=>$v){
        $_SESSION[$k]=$v;
    }
}
//you submitted from verify.php
elseif( isset($_POST['Submitter2']) && !empty($_POST['Submitter2']) )
{
    //retrieve the previously saved data from index.php
    $carrier = $_SESSION['carrier'];
    $number1 = $_SESSION['number1'];
    $number2 = $_SESSION['number2'];
    $number3 = $_SESSION['number3'];

    $number = $number1.$number2.$number3;

    $pin = rand(1, 9).rand(0, 9).rand(0, 9);
    $code = $pin;



    if($carrier == 1){
        $displaycarrier = "Verison";
        $site = "vtext.com";
    } elseif($carrier == 2){
        $displaycarrier = "AT&amp;T";
        $site = "txt.att.net";
    } elseif($carrier == 3){
        $displaycarrier = "Sprint";
        $site = "messaging.sprintpcs.com";
    } elseif($carrier == 4){
        $displaycarrier = "T-Mobile";
        $site = "tmomail.net";
    } elseif($carrier == 5){
        $displaycarrier = "MetroPCS";
        $site = "mymetropcs.com";
    } elseif($carrier == 6){
        $displaycarrier = "Virgin Mobile";
        $site = "vmobl.com";
    } elseif($carrier == 7){
        $displaycarrier = "Beyond GSM";
        $site = "txt.att.net";
    } elseif($carrier == 8){
        $displaycarrier = "Centennial";
        $site = "cwemail.com";
    } elseif($carrier == 9){
        $displaycarrier = "Cellular South";
        $site = "csouth1.com";
    } elseif($carrier == 10){
        $displaycarrier = "Cincinnati Bell";
        $site = "gocbw.com";
    } elseif($carrier == 11){
        $displaycarrier = "Boost Mobile";
        $site = "myboostmobile.com";
    } elseif($carrier == 12){
        $displaycarrier = "Nextel";
        $site = "messaging.nextel.com";
    } elseif($carrier == 13){
        $displaycarrier = "Alltel";
        $site = "message.alltel.com";
    } elseif($carrier == 14){
        $displaycarrier = "Qwest";
        $site = "qwestmp.com";
    } …
d5e5 109 Master Poster

You could try running the following, which incorporates one of solutions recommended in that article about buffering

#!C:\Perl\bin\perl.exe
#test.cgi
use strict;
use warnings;
#"The CGI::Carp module will arrange that fatal error messages
#are delivered to the browser with a simple prefabricated HTTP header,
#so that the browser displays the error message properly."
use CGI::Carp 'fatalsToBrowser';

print "Content-type: text/html\n\n"; #If no error, print your header anyway.
print "Try to run system 'jmeter -t'";
system 'jmeter -t';

I can't test it because my server platform is Linux, not Windows.

d5e5 109 Master Poster

Ψ represents a letter of the Greek alphabet which, in English, is pronounced 'psi'. I guess that is why it has been used as an abbreviation for 'psychology', or sometimes, 'psychiatry', because it sounds like the first syllable of those words. See http://tagal.us/tag/%CE%A8 if I may quote myself as authority, although I'm a programmer, not a psychologist nor a psychiatrist.:)

d5e5 109 Master Poster

First show us code from the page you are running. For example, are you trying to access a page called example.php in your browser? Show us the what is in example.php if it's not too big. Otherwise show us the relevant code that specifies or attempts to navigate to a cgi application. Telling us you got an error without telling us what you did doesn't give us enough information.

d5e5 109 Master Poster

hi guys, the code below works fine:
#!C:\Perl\bin\perl.exe
print "Content-type: text/html\n\n";
print "HELLO \nWORLD!\n";

i am using windows system, and i called using the url http://localhost/cgi-bin/hello.cgi. so this works fine.

please tell how i will associate cgi with perl executable in the httpd.conf, aalthough i have examined this critically.

To d5e5: the script below works fine wen i ran from command prompt, the problem is calling it from a browser.
#!C:\Perl\bin\perl.exe
print "Content-type: text/html\n\n";

system "jmeter";

Since http://localhost/cgi-bin/hello.cgi runs OK on your server it seems to me your server already associates cgi with perl, so maybe you don't have to touch httpd.conf. I have to do something else right now but I hope to get back online this afternoon and have another look at this.

What I suspect is that the print buffering, if any, is causing a problem. Maybe the output from the called bat file is somehow preceding the "Content-type: text/html\n\n" in the print buffer. If the output arrives at the browser in the wrong sequence, that can cause the error you are getting. In the meanwhile, have a look at http://perl.plover.com/FAQs/Buffering.html

The following passage looks interesting: "The content-type and the title are printed to STDOUT, which is buffered, but [...some error...] message is printed to STDERR, which isn't buffered. Result: The content-type and title are buffered. Then the error message comes out, and then, when the program exits, the STDOUT buffer is flushed and …

d5e5 109 Master Poster

Did you remove the # from the lines containing the paths and names of your files? Line 13 is trying to open the file name stored in $f1. Mike commented out the paths to your files so the script would run on his computer.

d5e5 109 Master Poster

Hi David,
Thanks for your promt response.

but this a line curve of actual values.
Plot the data in a bars. Then create a curve over the bar chart. So that gives you 2 bell shaped curve. The curve will be through the center of each bar. Does it make sense?

See this link
http://training.ce.washington.edu/WSDOT/Modules/08_specifications_qa/normal_distribution.htm

Any help is greatly appreciated.

I looked at the example in the link you gave and the curve is not drawn through the centre of each bar. It looks like someone used their intuition to draw a bell curve that best fit the actual data represented by the bars. I doubt that GD::Graph can guess which bell curve best fits a small sample of data points. There may be statistical analysis packages that do this.

d5e5 109 Master Poster

yeah i already added that to it but it is not working.

You haven't said yet whether any of your other cgi scripts run on your server. What happens when you run a really simple one? Such as:

#!/usr/bin/perl
#hello.cgi
use strict;
use warnings;

print "Content-type: text/html\n\n";

print "Hello, world!\n";

If that runs without error, then we can look at what is different about the bat file-calling script that doesn't work.

d5e5 109 Master Poster

Ok, now that I looked at the code an stuff, I know to put it in place of my current submit (send email --> text message) button. But my question is, what exactly do I do with/is the point of those hidden inputs? What am I going to do with them? I can't exactly retrieve a a variable from them... Help please. Thanks!

The point of the hidden fields is to save the data so the form will repost them back to your script and you can retrieve them from the $_POST array. However since hielo says you have already saved the data in the $_SESSION array you can forget about the hidden fields and retrieve from $_SESSION instead, as hielo says.

The point is that any data which you don't post and don't save will disappear when you exit your script by clicking a submit button, even if the script is posting to itself. Hope, I didn't confuse the issue by suggesting hidden fields. Saving and retrieving from $_SESSION accomplishes the same thing so stick with that alternative.

d5e5 109 Master Poster

I think you need some hidden input fields in the form with the submit button that posts back to your script. Otherwise the form is posting nothing except the value of the submit button, right? Hidden input fields allow you to repost your data.

<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"
<input type="hidden" name="carrier" value="<?php echo "$carrier"; ?>" />
<input type="hidden" name="number1" value="<?php echo "$number1"; ?>" />
<input type="hidden" name="number2" value="<?php echo "$number2"; ?>" />
<input type="hidden" name="number3" value="<?php echo "$number3"; ?>" />
<input type="submit" name="Submitter" id="Submitter" value="Send the code to my phone" />
</form>
d5e5 109 Master Poster

I'm afraid it doesn't make much sense to me, maybe because I've forgotten the very little I learned about statistics over 35 years ago.

Here's what I don't understand: If you create a bar chart of actual data and draw a line through the centre of the top of each bar, I don't see how that makes two bell curves. Wouldn't you end up with just the line chart of actual data superimposed on a bar chart of the same actual data? I installed GD::Graph only after reading your question so I don't know much about it -- but I don't see any option for creating a curve. One approach might be to input the actual data points into some kind of algorithm that would create a long series of ordered pairs representing a best-fit curve, and then GD::Graph could plot that. But I don't know how to create such an algorithm. Hopefully someone else here on Daniweb acquainted with statistical analysis modules will reply to your question?

I notice that someone asked a question similar to yours at this link and the response to it sheds some light on the problem but doesn't contain the complete solution.

d5e5 109 Master Poster

Sorry, this question is way over my head. I got as far as plotting your data but it doesn't look like a bell curve... more like twin peaks. In case it helps as an example of a line graph, here's the script:

#!/usr/bin/perl
#bell_curve_line.pl
use strict;
use warnings;

use GD::Graph::lines;
my $perlscriptsdir = '/home/david/Programming/Perl';

#For some reason, installing GD::Graph didn't put save.pl in my @INC path
require "/usr/share/doc/libgd-graph-perl/examples/samples/save.pl";
my $chart_file_out = 'bell_line';
print STDERR "Processing $chart_file_out\n";

#The @data array is an array of array references
# to an array of x values and an array of y values.

my @data = (
[ qw(1 2 3 4 5 6 7 8 9 10 11 12 13 14 ) ],
[ qw(2 50 40 300 70 80 8 10 25 60 350 80 40 5 )],);

my $my_graph = new GD::Graph::lines();

$my_graph->set(
x_label => 'X',
y_label => 'Frequency?',
title => 'Frequency of Various Values of X',
y_max_value => 350,
y_min_value => 2,
y_tick_number => 10,
y_label_skip => 2,
box_axis => 0,
line_width => 3,

transparent => 0,
);

$my_graph->plot(\@data);
save_chart($my_graph, "$perlscriptsdir/data/$chart_file_out");

Running this creates a file called "bell_line.gif" (see attached).

k_manimuthu commented: Active Supporter +2
d5e5 109 Master Poster

woow... cool, that's quite a long period working in IT industry. I hope you can share some knowledge and your experiences. you seems like you've got lots of experience and you're a great programmer. and I respect and honor the senior IT professionals. they're cool ;)


hmmm, I see that's a problem. I think you should go and build your own business like a website(maybe a forum?) then the advertisements can help you with your financial problems. wachathink? :)

Well, maybe. Since I joined Daniweb a couple of years ago I've learned some Perl, Python, PHP and MySQL which were mostly new to me. My working experience was mostly IBM mainframe, Microsoft Access & Visual Basic, Crystal Reports, Oracle etc., which I don't touch now.

Eventually I may acquire the skills to build my own website. Actually I have built a website for my wife at http://fpe.awardspace.info/ but, as you can see, it would need much more content and traffic before it would interest advertisers. As for a forum, I like Daniweb and prefer hanging around here to creating my own. Of course, it is so much easier to create your own web-site than it used to be, that almost any one can have their own. The hard part is to keep it updated with new content that is somehow more interesting than everyone else's.:)

BTW, that Ÿ with umlaut reminds me of the symbol for psychology, Ψ, although it's not the same at …

d5e5 109 Master Poster

I think tesu may have solved this. However I find the query hard to test without your data, so if you still have a problem with it I would consider putting the CASE logic into a function. Then we can easily test the function without having your data and you can incorporate the function into your query, making it more readable and easier to debug.

You can create a function called determine_shift as follows (change the DEFINER to the appropriate user)

DROP FUNCTION `determine_shift`//
CREATE DEFINER=`root`@`localhost` FUNCTION `determine_shift`(ts TIMESTAMP) RETURNS varchar(5) CHARSET latin1
BEGIN
    IF ISNULL(ts) THEN RETURN NULL; END IF;
    
 CASE
     WHEN (TIME(ts) between '07:20:00' and '15:19:59') THEN RETURN 'day';
     WHEN (TIME(ts) between '15:20:00' and '23:19:59') THEN RETURN 'swing';
     WHEN (TIME(ts) BETWEEN '23:20:00' AND '23:59:59') OR (TIME(NOW()) BETWEEN '00:00:00' AND '07:19:59') THEN RETURN 'night';
     ELSE RETURN 'ERROR';
 END CASE;
END

Now we can test it as follows:

mysql> select determine_shift('2010-08-25 07:54:36') as should_be_day;
+---------------+
| should_be_day |
+---------------+
| day           | 
+---------------+
1 row in set (0.00 sec)

mysql> select determine_shift('2010-08-25 16:54:36') as should_be_swing;
+-----------------+
| should_be_swing |
+-----------------+
| swing           | 
+-----------------+
1 row in set (0.00 sec)

mysql> select determine_shift('2010-08-25 23:54:36') as should_be_night;
+-----------------+
| should_be_night |
+-----------------+
| night           | 
+-----------------+
1 row in set (0.00 sec)

Seems to work OK.

Now you can use it in your query as follows:

select day(timestamp) as tamp, tech, packer_l, packer_r,  (packed_l + packed_r) as packed, timestamp as ts
  FROM abm_status
  where
    determine_shift(timestamp) = …
d5e5 109 Master Poster

I am worried that retiring from IT contract work in 2006 without a pension may not have been a great idea, since the supply of qualified IT professionals now seems to greatly exceed the demand around here (Brockville, Ontario, CANADA). However, I like having spare time so if my wife and I can get by on savings until age 65 when pensions start then maybe it was not a mistake.

d5e5 109 Master Poster

When you say you can't INSERT data in your parent table, could you show us an example of the code you are using to attempt that and quote the error message, if any, that results when you run it?