Hello everyone:
I am trying to comprehend Perl following the way describe in the book "Minimal Perl".
I've uploaded all source txt files onto my own server : results folder
I got the output from using several bash commands in a "chain" like this:
cat run*.txt | grep '^Bank[[:space:]]Balance'|cut -d ':' -f2 | grep -E '\$[0-9]+'
I kn...
I find it a bit weird that I have to wrap defined subroutines anonymously when specifying the -command argument for Tkx widgets.
An excerpt from a TkDocs tutorial demonstrates this:
my $cb = $frm->new_ttk__button ( -text => "Calculate",
-command => sub {calculate();} );
sub calculate {
$meters = in...
I want to have such pipe in bash
#! /usr/bin/bash
cut -f1,2 file1.txt | myperl.pl foo | sort -u
Now in myperl.pl
it has content like this
my $argv = $ARG[0] || "foo";
while (<>) {
chomp;
if ($argv eq "foo") {
# do something with $_
}
else {
# do another
}
}
But why the Perl script can't recognize the parameter passed t...
Problem...
Since MacPerl is no longer supported on 64bit perl, I am trying alternative frameworks to control Terminal.app.
I am trying the ScriptingBridge, but have run into a problem passing an enumerated string to the closeSaving method using the PerlObjCBridge.
I want to call:
typedef enum {
TerminalSaveOptionsYes = 'yes ' /* ...
Hi,
I have inherited a web project that is perl based and I'm attempting to set up a local testing server so changes can be made internally to the project.
The server architecture
Ubuntu 9.10
php 5.2.10
mysql 5.1.37
perl 5.10.0-24ubuntu4
All the dependent modules and packages are installed such as DateTime.pm, TemplateToolkit.pm but r...
I have a perl CGI script that needs to send back some HTML
print qq^Content-type: text/html\n\n
<HTML>
<HEAD>
<TITLE>some title</TITLE>
...
...
...
...
^:
Instead of seeing the rendered HTML in the browser, I see the entire HTML along with the tags and the 'content-type' line in plain text. Below is how things look in the browser -
C...
I need to define some modules and use them all in the same file. No, I can't change the requirement.
I would like to do something like the following:
{
package FooObj;
sub new { ... }
sub add_data { ... }
}
{
package BarObj;
use FooObj;
sub new {
...
# BarObj "has a" FooObj
my $se...
System OSX or Linux
I'm trying to automate my work flow at work, each week I receive an excel file, which I convert to a csv.
An example is:
,,L1,,,L2,,,L3,,,L4,,,L5,,,L6,,,L7,,,L8,,,L9,,,L10,,,L11,
Title,r/t,needed,actual,Inst,needed,actual,Inst,needed,actual,Inst,needed,actual,Inst,neede d,actual,Inst,needed,actual,Inst,needed,actua...
I am having some trouble trying to print from a file. Any ideas? Thanks
open(STDOUT,">/home/int420_101a05/shttpd/htdocs/receipt.html");
#Results of a sub-routine
&printReceipt;
close(STDOUT);
open(INF,"/home/int420_101a05/shttpd/htdocs/receipt.html"); $emailBody = <INF>;
close(INF);
print $emailBody;
ERRORS: Filehandle STDOUT reop...
I know this is a real basic and stupid question but how do I run a Perl script on OS X? I honestly can't find the answer anywhere! Presumably I have to run a command in Terminal but what?
...
I am trying to send an HTML email using Perl.
open(MAIL,"|/usr/sbin/sendmail -t");
## Mail Header
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
## Mail Body
print MAIL "Content-Type: text/html; charset=ISO-8859-1\n\n"
. "<html><head></head><body>@emailBody";
cl...
While trying to do:
perl -I'/v1/data/site_perl' -MCPAN -e 'install Log::Dispatch';
I continue to get "Can't locate Params/Validate.pm in @INC." When looking at the output, /v1/data/site_perl is NOT in the @INC displayed, even though I used -I.
I am not root so I have changed my CPAN config so that:
'makepl_arg' => q[LIB=/v1/data/si...
Sometimes I see people use http://codepad.org as a way to quickly run/test their Perl snippets (it supports doing that with a wide variety of languages, from C to Scheme to Perl).
It's pretty obvious that there must be some limitations as to what code/features can be tested with codepad - does anyone know what those limitations are for...
We have Oracle Server " Oracle Version: 10.2.0.4.0 - 64bit". I like to connect to this server with Perl from my RHEL machine. I am able to connect via sqlplus successfully. I can use 32-bit or 64-bit Perl. I have few questions.
Which files I should download from Oracle.com and where should I install them?
What are the environment s...
I have list of IPs:
238.51.208.96/28
238.51.209.180-199
238.51.209.100-109
238.51.213.2-254
...
How can I easily parse them? I need first and last IP from range.
For the first line I can use Net::Netmask CPAN module, but what can I do with others lines?
...
I am using Perl running in user space (not installed via root) and installing modules via the command-line cpan. I would like to know if there is a simple way to remove a module without having to do a lot of work deleting individual files.
I searched for this question on the internet and found some answers, but the answers I've found se...
I am using Perl to read UTF-16LE files in Windows 7.
If I read in an ASCII file with following code then each "\r\n" in file will be converted into a "\n" in memory:
open CUR_FILE, "<", $asciiFile;
If I read in an UTF-16LE(windows 1200) file with following code, this inconsistency cause problems when I trying to regexp lines with li...
Hi, When I learning to print array variables, I found the white space inserted when double quoter used. Snippet code as below. Could you please tell me why?
#!/usr/bin/perl -w
use strict;
use warnings;
my @str_array = ("Perl","array","tutorial");
my @int_array = (5,7,9,10);
print @str_array;
print "\n";
# added the double quotes
print...
UPDATE (FIGURED OUT):
I figured this out on my own, this is not documented anywhere. The array reference passed needs to have each array item be a hash reference using either the a categoryName or categoryId key identifier. Meaning:
'categories' => [
{'categoryName' => 'CatName1'},
{'categoryName' => 'CatName2'},
],
The quest...
I'm playing around with error handling and got a little problem.
I connect with a database using the DBI module.
I do my own error handling by using a subroutine that I call upon an error.
I can catch my own dies and handle them just fine but when my database connection fails, the DBI module apparently prints out it's own die :
DBI co...