I have been given a new Windows 7 desktop at work and would like to have Perl doing stuff.
I installed Strawberry Perl, which I usually use, and went from there...
One of the things I wanted to be able to do was write GUI applications in Perl, and found to my dismay that a lot of the tools I tried would not build OOTB.
I have found three that do, so I thought I'd share them here in case anybody else is in the same situation.
Installed OK:
Failed to install:
- Tk (crashed 3 times then failed to install)
- Win32::GUI this may help
- Gtk2
- Qt - I wasn't up for having to install 525MB of libraries to get a little GUI app working!
read this
Why does Deparse do this?
Given:
#!/usr/bin/perl
use warnings;
use strict 'refs';
use Data::Dumper;
my(@array1) = (1, 2, 3, 4);
my(@array2) = ('a', 'b', 'c', 'd', 'e', 'f');
If I have this:
push my @array3, @array1, @array2;
I get:
Parentheses missing around "my" list at try.pl line 12.
If I do:
push (my @array3, @array1, @array2);
it doesn't complain...
but if I run the code through -MO=Deparse
It changes the:
push (my @array3, @array1, @array2);
back to:
push my @array3, @array1, @array2;
!!!
I'm trying to get the values out of an enum field in MySQL
At the moment I have:
#!/usr/bin/perl
use warnings;
use strict;
use DBI;
my $db_host = "mysql";
my $db_port = "3306";
my $db_user = 'web-user';
my $db_pass = 'pass4monks';
my $db_name = 'order_dev';
my $dbh = DBI->connect(
"DBI:mysql:database=$db_name;host=$db_host;port=$db_port",
$db_user, $db_pass
) || die ("ERROR: Unable to connect to '$db_name': $DBI::errstr" );
my ($enum_qry) = $dbh->prepare(
"SELECT column_type
FROM information_schema.columns
WHERE table_name = 'orders' AND column_name = 'request_status'
LIMIT 1;"
);
$enum_qry->execute;
my $enum_ref = $enum_qry->fetchrow_hashref;
(my $enum_types = $$enum_ref{'column_type'}) =~ s/^enum\((.*)\).*/$1/;
foreach my $enum_type ( eval $enum_types ) {
print qq[<option value="$enum_type">$enum_type</option>\n];
}
This can be tested without the DB stuff using:
my $enum_types = "'On Order','Waiting, Pending Payment','Dispatched','
+Cancelled','Renewal','Amend\'ed'";
# NB: one value has a , in it and another a ' just to make this challe
+nging... ;-)
foreach my $enum_type ( eval $enum_types ) {
print qq[<option value="$enum_type">$enum_type</option>\n];
}
Consensus is that eval should be spelled 'evil' and should be evoided where possible...
Anno wrote this //g syntax which works fine:
while ( $enum_types =~ m/('(.*?)'|([^']*?))($|,\s*)/g ) {
my $match = $3 || $2;
print qq[<option value="$match">$match</option>\n] if $match;
}
I'm wondering what syntax I'd need to replace the eval using split...
The closest I have at the moment is:
#!/usr/bin/perl
use warnings;
use strict;
my $enum_types = "'On Order','Waiting, Pending Payment','Dispatched','
+Cancelled','Renewal','Amen'ded'";
foreach my $enum_type ( split /(?:^'|','|'$)/, $enum_types ) {
print qq[<option value="$enum_type">$enum_type</option>\n];
}
But that also gives me the ^ as a value:
$ ./try.pl
<option value=""></option>
<option value="On Order">On Order</option>
<option value="Waiting, Pending Payment">Waiting, Pending Payment</opt
+ion>
<option value="Dispatched">Dispatched</option>
<option value="Cancelled">Cancelled</option>
<option value="Renewal">Renewal</option>
<option value="Amen'ded">Amen'ded</option>
Any suggestions?
Read between the lines... ^^^
In the description of "Custom Node Title Definition" in Display Settings it says "Don't use [ nor ]"
I think "Do not use X nor Y" is a double negative where it is not intended...
"Don't use X ... Y" is the same as "Do not use either X or Y" ("Do not use neither..." would be a double negative and incorrect)
The "or" works like a comma in a list of things that have been negated by the "not" in Don't.
It should either be "Use neither X nor Y" or "Don't use X or Y".
Further reading:
Efficient use of space on multiple CDs
Compiling modules for ARM:
my $command = '/usr/local/bin/program_with_multiline_output';
chomp(my(@output) = `$command`);
my $output = join($/, grep(/./, @output));
my $returned = $? >> 8;
print "Returned: [$returned]\n";
print "Message: [$output]\n";
and all is quiet...
[link://?node_id=3989&BIT=search term|search term] search term
If you have a look at Super Search:Ananymous
last hour of cb
serf
|