If
you have a question on how to do something in Perl, or
you need a Perl solution to an actual real-life problem, or
you're unsure why something you've tried just isn't working...
then this is the place to ask.
However, you might consider asking in the chatterbox first (if you're a
registered user). The response time tends to be quicker, and if it turns
out that the problem/solutions are too much for the cb to handle, the
kind monks will be sure to direct you here.
I'm very new to Perl TK (read my first info this morning, so be easy correcting my possible slip ups in terminology...)
I'm assisting a co-worker in editing an existing Perl TK application we use for debug. Currently it is a window, with a single frame, and a canvas in that frame.
We would like to split the window so that we have the same content in an upper and lower view of the same data we had in the canvas already, but with independant scroll bars.
We find that using this tool it would be helpful to have the header information that is printed at the top most of the time, but fairly often it would be nice to pull down the top canvas so we can compare things going on above and below (like splitting an editor screen in half and seeing 2 parts of the same file...at least in concept)
We think we can solve this by duplicating the entirety of the canvas objects, but that seems heavy handed and sometimes the data that goes into generating these is fairly complex and time consuming.
I wanted to believe that there was an easier way to do this than duplication, but my searches (for the last few hours) has come up empty.
$top->title("Diagram Viewer");
$top->configure(-background => 'white');
#<a menu bar at the top>...skipping some details
my $menu_bar = $top->Frame()->pack(-side => 'top', -fill => 'x');
#skipping adding buttons to menu_bar....
# the next frames
my $top_canvas_frame = $top->Frame()->packAdjust(-side => 'top', -expa
+nd => 'both', -fill => 'both');
my $bottom_canvas_frame = $top->Frame()->pack(-side => 'bottom', -expa
+nd => 'both', -fill => 'both');
my $blankCanvas = { canvas => newCanvas($top_canvas_frame)};
# here is where I can't figure out a way to insert another view $blank
+Canvas into $bottom_canvas_frame so we can get dual views...
<readmore>
Hi all,
we have a shell script from which we invove the perl i.e
a.sh
----
#!/bin/sh -
-- we set a lot of environment variables here and then call perl script finally as :-
$PERL_BIN/perl a.pl "$@"
-----
The perl script has the following first line i.e
---
#!/usr/local/bin/perl
use lib (...)
...
Usual processing ...
----
But when we invoke it we get the error
a.sh bin/perl: Argument list too long
The arguments we are passing are way within the limits i.e not more than 400 characters then why is the perl complaining on the argument list ?
This is running on Linux box.
Is there some limit on the number of environment variables we can set ?
I have a script which finds all the directories within a given directory and stores them in an array. In the original version of the script, I used something like this:
my $dirname=cwd();
my $sys_get_dirs = "ls -l $dirname | egrep \'^d\'";
my @dirlist=`$sys_get_dirs`;
I want to expand the script as a cross-platform script; both Linux and Windows. Is there a Perl function, command, structure - or something - I can employ in my script to somehow "detect" what OS it's running on? Is it something plainly obvious that I'm missing?
This is confusing me. I had a function that returned an array of answers if it found one or more answers, else it returned undef. On return, the result was assigned to an array and I tested the array for being defined or not.
I thought that if my function returned undef and that was assigned to an array, the array should also test as not defined. Buuuut....noooooOOOOoooo.... :-(
Why does my array, assigned "undef", then tell me it is defined? :-(... Very sad. I thought undef was the opposite of defined (sort of). I mean "undef" is a value (or an "unvalue"?), and defined is a test to see if a 'value' doesn't evaluate to 'undef', no? I'm sure there's a good reason for this, but at this point it sure doesn't seem "intuitive"...Arrg....
(this is what I get for doing whatever it is that I've done to deserve this! :-))....
Maybe I'm tired but really I can't solve such a situation!
I have the following script retrieving data from MySQL:
#!/usr/bin/perl -w
use strict;
use warnings;
use DBI;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use utf8;
use Encode qw(decode decode);
binmode(STDOUT, ":encoding(utf8)");
my ($datasource, $user, $passw, $dbh, $sth);
my ($id_testo, $indice, $parole, $posizione);
my (@row, $field);
$datasource = "DBI:mysql:database=Test;host=xxxxxxx;";
$user = "xxxxxxxx";
$passw = "";
$dbh = DBI->connect($datasource, $user, $passw) || die "Error opening
+db: $DBI::errstr\n";
$dbh->do("SET NAMES 'utf8'");
$sth = $dbh->prepare("SELECT indice, GROUP_CONCAT(parole SEPARATOR ' '
+) FROM testo GROUP BY indice");
$sth->execute();
print header(-type => "text/html", -charset => "utf-8"),
start_html(-encoding => 'utf-8', "My_database"), "\n",
h2("ARET 1.1"), "\n";
while (@row = $sth->fetchrow_array) {
for $field(@row) {
$field =~ s/([à]+)/<i>$1<\/i>/g; # lower --> italic
$field =~ s/(\p{Lu}+)/lc($1)/ge; # upper --> lower
$field =~ s/-=(.{1,4})/<sup>$1<\/sup>/g; # OK
}
print p(),
decode("utf8", "$row[0]\t$row[1]\n");
}
$sth->finish();
$dbh->disconnect() || die "fallita disconnessione\n";
It gives me back the following output:
.. various html tag and meta ..
r.1,1 1 ʾà-da-um-=TUG2-II 1 AKTUM-=TÚG 1 IB2-IV-=TÚG SA₆ DAR
r.1,2 g_*NI-ra-ar-=KI
r.1,3 2 ʾa3-da-um-=TÚG-II 1 ʾa3-da-um-=TÚG-I
Well, I really don't understand why the substitution regex doesn't work with unicode character such as accented wovel à (or Ú, or even the sign ʾ). I tried and change the à with its corresponding x{2be}, but nothing happens. My data originate from a MySQL table set with a utf8 charset. Is it possible that I didn't yet decoded my output when I send it to the for loop and to the sobstutions regex? Thank you
I have a program that uses DBI to perform sql tasks into an oracle database. I want to quit the program if an error is returned from the sql command. however, I want the error to go to STDERR and I want to print a custom message to STDOUT before dieing.
my $dbh = DBI->connect('dbi:Oracle:miemsdb', 'ipse', 'ipse', {AutoComm
+it => 0}) || die "RC-E\n";
open (STDERR, ">ERR/ERRORS_${myPID}");
###########################
my $DirChk = $dbh->prepare($sqlChkDir) || die "RC-E\n";
$DirChk->execute($DirName) || die "RC-E\n";
With this code I do get the oracle error and the "RC-E" into the ERRORS_$ file. But I want to send the RC-E to stdout.
Is there an equivalent of splice() that's accessible via XS?
The closest I found was av_delete() which effectively undefs the element at the given index. Any way to shrink the AV?
Thanks.
Ladies and Gentlemen, I have been trying to add a data file to windows executable created with pp. The program cannot find the file unless it is in the same folder as .exe file as a separate file. The original .pl file expects the data file to be in the same directory as the script. It is in the archive, and I've tried placing it in /, /script, /lib. Nothing works. I can copy both the .exe file and the data file somewhere else and it does work but I want to not have to copy the data file, since it's already in the archive. I thought that the -a flag is for this purpose. I must be missing something here.
test script named test.pl
#!/usr/bin/perl
# OS is windows XP perl 5.8.8 build 820
open FH,"hello.txt" or die "$!\n";
while ( <FH> ) {
print;
}
I have a text file in the same directory as the script named
hello.txt. I then want to make an executable using pp:
>pp -a hello.txt -o test.exe test.pl
This creates an executable, but unless a copy of hello.txt is in the same folder, it will not find it. The -a flag did put the hello.txt file in the archive, but the script can't find it. Any ideas?
Please point out the obvious to me :-)
I've read in a file and built a hash with a single key and value pair.
assume $input{red}= "yellow";
I'm trying to build a second hash using the values in the first hash. for example:
$newhash = {
new_value => $input{red}
};
with the hope that $newhash{new_value} would have a value of "yellow".
I am obviously doing something wrong.... Can someone please help me with this? Is there a different approach I should be taking?
Thanks!
I seek to split text, based on a bunch of keyword in the text,
and shove it into a hash. I've been staring at 'Chapter 6:
Pattern Matching' in the Perl Cookbook, but I just can't seem to
get my mind around it. I'm pretty sure I need to be using the \G
anchor, and non-greedy matching, but...
I have an array of keywords like