[25258] in Perl-Users-Digest
Perl-Users Digest, Issue: 7503 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 10 00:08:25 2004
Date: Thu, 9 Dec 2004 21:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 9 Dec 2004 Volume: 10 Number: 7503
Today's topics:
Cannot compile working perl on freebsd / amd64 <mhunter@berkeley.edu>
Re: Convert text to Hex <jwillmore@fastmail.us>
Re: examples using PDF::Template <bik.mido@tiscalinet.it>
Insert JavaScript into Perl alex.osinski@gmail.com
Re: Insert JavaScript into Perl xhoster@gmail.com
Re: Insert JavaScript into Perl <alex.osinski@gmail.com>
Re: Insert JavaScript into Perl xhoster@gmail.com
Re: Insert JavaScript into Perl <sbryce@scottbryce.com>
Re: Matching words and letters <1usa@llenroc.ude.invalid>
Re: MS Perl question -- how to use hacked script to wor <bik.mido@tiscalinet.it>
Re: MS Perl question -- how to use hacked script to wor <bik.mido@tiscalinet.it>
Re: Need help with froogle and cart id prob <abigail@abigail.nl>
Re: Parsing Huge Files <bik.mido@tiscalinet.it>
Re: passing string to ksh with system command <not@invalid.invalid>
Re: passing string to ksh with system command <not@invalid.invalid>
Re: Question on loops and return values <bik.mido@tiscalinet.it>
Re: Question on loops and return values <bik.mido@tiscalinet.it>
Re: Reg Hash of Hash <wksmith@optonline.net>
Re: regular expressions problem <humbads1@hotmail.com>
Re: regular expressions problem <uri@stemsystems.com>
Re: regular expressions problem <humbads1@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 9 Dec 2004 23:51:58 +0000 (UTC)
From: Mike Hunter <mhunter@berkeley.edu>
Subject: Cannot compile working perl on freebsd / amd64
Message-Id: <slrncrhp57.1ml.mhunter@celeste.net.berkeley.edu>
Hi,
I'm hoping somebody out there has some advice for me.
I cannot compile a working perl binary for freebsd 5.2.1, 5.3, or 6.0 on
amd64. During the `make test` phase it gets into some kind of memory loop
with Config.t: It sits on this test with 99% cpu and ever-increasing memory
until finally runnnig the machine out of ram.
I have the incomplete build sitting in /tmp, and I can envoke lib/Config.t
and get it to do it straight away. kdump (strace on linux) shows it doing
break after break:
23961 perl CALL break(0x1f86000)
23961 perl RET break 0
23961 perl CALL break(0x2254000)
23961 perl RET break 0
23961 perl CALL break(0x1f88000)
23961 perl RET break 0
23961 perl CALL break(0x2258000)
23961 perl RET break 0
23961 perl CALL break(0x1f8a000)
23961 perl RET break 0
23961 perl CALL break(0x225c000)
23961 perl RET break 0
23961 perl CALL break(0x1f8c000)
23961 perl RET break 0
23961 perl CALL break(0x2260000)
23961 perl RET break 0
23961 perl CALL break(0x1f8e000)
23961 perl RET break 0
23961 perl CALL break(0x2264000)
23961 perl RET break 0
23961 perl CALL break(0x1f90000)
I'd really appreciate any advice on how to debug the problem or work around it.
Thanks,
Mike
------------------------------
Date: 9 Dec 2004 15:12:51 -0800
From: "Jim" <jwillmore@fastmail.us>
Subject: Re: Convert text to Hex
Message-Id: <1102633971.881877.61450@c13g2000cwb.googlegroups.com>
Stephane CHAZELAS wrote:
< ... >
> I actually meant that "^@^X^@^A^@^AA" was actually the character
> 0x00 followed by the character 0x18... Such characters can't be
> included in newsgroup messages, neither can't they generally be
> seen, hence the need of a representations such as ^@, ^X.
But they can if they are part of the actual code - which is what the OP
posted ... not a representation of what he wanted, but the actual code
AFAIK. If the OP says I'm wrong, so be it.
> [...]
> > ... which isn't what the OP wanted :-)
> >
> > To complicate things, he appears to be using EBCDIC, not ASCII
values as
> > the final result. '41' is 'A' in ASCII, but in EBCDIC it's
represented by
> > 'C1'. And, in your solution, you don't appear to take into account
that
> > '^' is a control character (much like the infamous '^M' you get
when
> > getting a DOS file and placing it in binary format on a Unix box).
> [...]
>
> I took it into account, that's what I explained. ^X (aka Ctrl-X)
> is the character 0x18. I assumed the ^X in OP's message was
> actually the representation of the 0x18 character.
The OP was very clear about what he wanted to see.
> You're right however about the EBCDIC issue.
The OP, however, was not clear about this.
> However if his system charset is EBCDIC (which the fact that he
> said that the result should be the hex representation suggests),
> my code would still work (pack("H*", "A") would return "C1").
>
> $ cat -vt input-file
> 01 SYSOT VALUE '^@^X^@^A^@^AA' PIC X(07)
> $ od -tc input-file
> 0000000 0 1 S Y S O T V A
L
> 0000020 U E ' \0 030 \0 001 \0 001 A '
> 0000040 P I C X ( 0 7 ) \n
> 0000057
> $ cat perl-script
> s/VALUE '(.*?)'/"VALUE X'" . unpack("H*", $1) . "'"/e
> ~$ perl -p perl-script input-file
> 01 SYSOT VALUE X'00180001000141' PIC X(07)
>
> --
> Stephane
What OS are you running? Because I did the following and got different
results. The OS I'm running is Linux (Fedora Core 2 and Red Hat 8.0 -
not sure about the kernel version on the Fedora box, but it's using
5.8.3 Perl - since I'm at work right now, but the Red Hat box is
running a 2.4.18 kernel and 5.8.0 Perl).
This is what I got duplicating your commands and files ...
[jim@oplinux tmp]$ cat -vt input-file
01 SYSOT VALUE '^@^X^@^A^@^AA' PIC X(07)
[jim@oplinux tmp]$ od -tc input-file
0000000 0 1 S Y S O T V A L
0000020 U E ' ^ @ ^ X ^ @ ^ A ^ @ ^ A
0000040 A ' P I C X
0000060 ( 0 7 ) \n
0000065
[jim@oplinux tmp]$ cat perl-script
s/VALUE '(.*?)'/"VALUE X'" . unpack("H*", $1) . "'"/e
[jim@oplinux tmp]$ perl -p perl-script input-file
01 SYSOT VALUE X'5e405e585e405e415e405e4141' PIC X(07)
[jim@oplinux tmp]$
This is starting to bug me that I got different results and executed
the *same* commands. I realize that the various characters, when
*printed* will vary, but the OP provided *code* that *should* print.
And the commands you execute *should* yield the *same* results ... and
it's not.
So ... what am I doing differently from you that produces different
results? I'm sure the OP might be interested as well ... if he's still
with us and following along and is getting what I'm getting.
Jim
------------------------------
Date: Fri, 10 Dec 2004 00:33:29 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: examples using PDF::Template
Message-Id: <pclhr0pj101f9dqqd22jaqjbjrfhlka4g9@4ax.com>
On 8 Dec 2004 09:16:04 -0800, "botfood" <botfood@yahoo.com> wrote:
>after a night of poking around, and you all's input, it looks like
>creating .pdf files on the fly is a pretty involved and painful
>process. PDF::Template has potential for what I want to do, but
>requires learning special XML syntax to set up the template, and buying
>the PDFlib for about $450. PDF::Create has some simple capabilities,
>but neither look straightforward to use in a mail-merge application as
>there are some complex issues with pagination and text position.
[snip]
>if there is somebody out there who has actually used PDF::Create and/or
>PDF::Template and would like to share some thoughts on the
>capabilities/limitations, ease of use, examples, etc, I still think it
>would be great to share some knowledge of these packages.
Well, I can't share any experience on the packages you mention, but I
may try insisting on the pdfLaTeX route. See this fictious example:
#!/usr/bin/perl
use strict;
use warnings;
die "Usage: $0 <template>\n" unless @ARGV == 1;
open my $fh, '|-', 'pdflatex' or
die "Can't pipe into pdfLaTeX: $!\n";
select $fh;
while (<>) {
s/ <<CODE>> / \\lstinputlisting{$0} /x;
print;
}
__END__
called with the following template as argument
\documentclass[a4paper,12pt]{article}
\title{A Minimal Example}
\author{Me Myself}
\date{\today}
\usepackage{color}
\usepackage[bookmarks=true,
bookmarksnumbered=true,
colorlinks=true,
linkcolor=blue,
pdfpagemode=None,
pdfstartview=FitH]{hyperref}
\makeatletter
\newcommand\org@maketitle{}
\let\org@maketitle\maketitle
\def\maketitle{%
\hypersetup{
pdftitle={\@title},
pdfauthor={\@author},
pdfsubject={Nothing more than a minimal example},
pdfkeywords={minimal example}
}%
\org@maketitle
}
\makeatother
\usepackage{listings}
\begin{document}
\maketitle
\lstset{language=Perl,
basicstyle=\small\ttfamily,
commentstyle=\color{white},
stringstyle=\color{blue},
keywordstyle=\color{red},
backgroundcolor=\color[gray]{0.80},
xleftmargin=2em,
frame=single,
framexleftmargin=2em,
showstringspaces=no,
numbers=left,
numberstyle=\tiny,
numbersep=2em}
\section{What is all this about?!?}
This is just a minimal example{\ldots} here's the code I used to
generate
this document from a template:
<<CODE>>
\end{document}
Running the perl program will leave a texput.pdf output file in the
cwd.
If you want to see a sample output, you can find it at
<http://mosquito.scumm.it/~blazar/example.pdf>.
Of course all this is very rough, and I remember having seen more
refined examples somewhere, however I don't have any link offhand.
IIRC someone even set up a TeX sort of daemon especially aimed at
"this kinda things"...
>I realize that some people feel this group is for asking questions
>after you get stuck... but I HOPE there are also people out their
>interested in sharing experiences with specific packages to help others
>evaluate alternatives before investing a lot of learning time and test
>code.
Hope the above helps.
Of course the solution I'm proposing requires having a TeX system
installed, which is not a problem for me, since I need it anyway...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 9 Dec 2004 15:16:52 -0800
From: alex.osinski@gmail.com
Subject: Insert JavaScript into Perl
Message-Id: <1102634212.258503.79110@c13g2000cwb.googlegroups.com>
I have a site running off Perl. I know nothing of Perl and have been
told to insert our standard intranet header and footer. (ack!) Our
header and footer are included into our pages via:
<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalHeader.js"></script>
&
<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalFooter.js"></script>
When I try to insert this code into the Perl run site, it never shows
up. This is the syntax I'm using for the header:
print FILE"<SCRIPT language=\"JavaScript\"
src=\"/GlobalInsideITNew/JS/InsideITGlobalHeader.js\"> \n";
print FILE"</SCRIPT> \n";
Help! What am I doing wrong?
------------------------------
Date: 09 Dec 2004 23:30:17 GMT
From: xhoster@gmail.com
Subject: Re: Insert JavaScript into Perl
Message-Id: <20041209183017.688$fL@newsreader.com>
alex.osinski@gmail.com wrote:
> I have a site running off Perl. I know nothing of Perl and have been
> told to insert our standard intranet header and footer. (ack!)
Why do you have a site running off Perl if you know nothing about
Perl?
> Our
> header and footer are included into our pages via:
>
> <script language="javascript"
> src="/GlobalInsideITNew/JS/InsideITGlobalHeader.js"></script>
I know little about javascript, but doesn't this just cause a js library
to be loaded without actually running anything in that library?
>
> &
>
> <script language="javascript"
> src="/GlobalInsideITNew/JS/InsideITGlobalFooter.js"></script>
>
> When I try to insert this code into the Perl run site, it never shows
> up.
Never shows up where?
> This is the syntax I'm using for the header:
Well, that might be the first problem. What is this header you talk
about?
>
> print FILE"<SCRIPT language=\"JavaScript\"
> src=\"/GlobalInsideITNew/JS/InsideITGlobalHeader.js\"> \n";
> print FILE"</SCRIPT> \n";
Why are you printing to FILE? Is FILE even open? In Perl CGI (or isn't
this even CGI?), the handle you print html to us generally STDOUT, not
FILE.
Perl has a great thing called "here-docs" which let you print literal
text, such as javascript, with a lot less backwhacking and other
punctuation.
print <<'EOS';
<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalHeader.js"></script>
EOS
> Help! What am I doing wrong?
There are so many possibilities, and you haven't given us enough to
go on.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 9 Dec 2004 15:48:42 -0800
From: "cassiux" <alex.osinski@gmail.com>
Subject: Re: Insert JavaScript into Perl
Message-Id: <1102636122.189261.219490@f14g2000cwb.googlegroups.com>
I've been told to add this header, I don't actually RUN the site. The
usual admin is out for a week.
I guess this is Perl CGI. Keep in mind this is all new to me.
I could be printing to a kangaroo in perl and not know the difference,
I just found print FILE off the net.
I tried your "here-docs" code w/out success. The page runs and it
never shows up. I'll research Perl tonight and see what the deal is.
Damn. Thanks though.
------------------------------
Date: 10 Dec 2004 00:07:02 GMT
From: xhoster@gmail.com
Subject: Re: Insert JavaScript into Perl
Message-Id: <20041209190702.510$WI@newsreader.com>
"cassiux" <alex.osinski@gmail.com> wrote:
> I've been told to add this header, I don't actually RUN the site. The
> usual admin is out for a week.
Hmmm, I think this is what we call an "unenviable position". Bummer.
> I guess this is Perl CGI. Keep in mind this is all new to me.
>
> I could be printing to a kangaroo in perl and not know the difference,
> I just found print FILE off the net.
Look for other print statements in the program which you are modifying,
and see if they have "FILE" (or some other file handle) on them.
> I tried your "here-docs" code w/out success. The page runs and it
> never shows up. I'll research Perl tonight and see what the deal is.
> Damn. Thanks though.
Are you looking for it in the html source, or just the rendered page?
Maybe it is there, but not in a position to actually do anything.
Maybe try something less subtle first, like:
print "<H1>Hey diddle diddle the cat played the fiddle</H1>\n";
And see if *that* shows up.
Or show us a few lines of context surrounding the place where you think
the print belongs, and maybe we can give tell you why it should or should
not.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Thu, 09 Dec 2004 17:31:24 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Insert JavaScript into Perl
Message-Id: <CcGdnf6y4eHGcyXcRVn-qg@comcast.com>
alex.osinski@gmail.com wrote:
> I have a site running off Perl.
You probably have a site made up of web pages that are generated by CGI
scripts written in Perl.
> I know nothing of Perl and have been
> told to insert our standard intranet header and footer.
Not a fun place to be.
> (ack!) Our
> header and footer are included into our pages via:
>
> <script language="javascript"
> src="/GlobalInsideITNew/JS/InsideITGlobalHeader.js"></script>
>
> &
>
> <script language="javascript"
> src="/GlobalInsideITNew/JS/InsideITGlobalFooter.js"></script>
>
> When I try to insert this code into the Perl run site,
What you probably want to do is insert the code into the HTML stream
that the CGI script is sending to the browser.
> it never shows
> up. This is the syntax I'm using for the header:
>
> print FILE"<SCRIPT language=\"JavaScript\"
> src=\"/GlobalInsideITNew/JS/InsideITGlobalHeader.js\"> \n";
> print FILE"</SCRIPT> \n";
>
> Help! What am I doing wrong?
We can only guess. Try something that looks more like:
print qq(<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalHeader.js"></script>\n);
------------------------------
Date: 10 Dec 2004 04:44:26 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Matching words and letters
Message-Id: <Xns95BAF17E8CD0Basu1cornelledu@132.236.56.8>
Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote in
news:cp9ega$6bb$1@nntp.fujitsu-siemens.com:
> Sandman wrote:
>
> [ elaborate problem description deleted ]
>
> A very simple/simplistic solution:
>
> my @words = qw(mall bill kill lot pile antilope hello);
> my $fixed = 'k';
> my $set = 'ljetilamnop' . $fixed;
>
> foreach (@words) {
> print "$_\n" if m/[$fixed]/ && m/^[$set]*$/;
> }
>
How is this a solution?
D:\Home>perl tttt.pl
kill
Sinan
------------------------------
Date: Fri, 10 Dec 2004 00:30:56 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: MS Perl question -- how to use hacked script to work correctly(was Question on loops and return values or sumpin)
Message-Id: <ubfhr0hijcnr3kabeu5dujhj78lmummaff@4ax.com>
On 9 Dec 2004 05:37:13 -0800, "James" <djcameron60616@yahoo.com>
wrote:
>Hi Rob and thanks for your time,
>
>I will try to install AdminMisc using the method you suggested after
>trying the code above.
>
>Thanks and cheers,
>
>James
Please provide some context.
PS: please do not take mine as an ad hominem attack, either.
Personally I find this (complete lack of any quoting) just as annoying
as top-posting...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 10 Dec 2004 00:30:57 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: MS Perl question -- how to use hacked script to work correctly(was Question on loops and return values or sumpin)
Message-Id: <h39hr05ik4vp60soci94js3lvscprhhj2k@4ax.com>
On 9 Dec 2004 05:27:57 -0800, "James" <djcameron60616@yahoo.com>
wrote:
>> > use lib "$ENV(HOME)/site/lib";
^ ^
^ ^
>> What do you think this does?
>
>I thought it explicitly stated where the library was.
^ ^
^ ^
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 10 Dec 2004 00:35:36 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Need help with froogle and cart id prob
Message-Id: <slrncrhrqn.k4s.abigail@alexandra.abigail.nl>
dave (shagyez@gmx.net) wrote on MMMMCXVIII September MCMXCIII in
<URL:news:cpajbe$9ge$04$1@news.t-online.com>:
`' Hi folks,
`'
`' I'm using a variation of Selena Sol's web_store.cgi as my online shop (or
`' trying to, that is).
`' I'm currently trying to put a product page on Froogle.
`' Froogle requires that the url from the Froogle results list, to the vendor
`' site, be directly to the product page and not to any category page or other
`' page before the product page.
`' My problem is that a cart id doesn't get created unless the shopper starts
`' at the storefront page, or at least at the category page.
`' So how would I modify the product page so that when the "buy this item"
`' button is clicked, a cart id is created and passed to the checkout page?
`' Any and all help will be really appreciated.
If you have problems with a particular software product, or with a
particular service, you should direct your questions to the supplier
of such product or service.
This language is about the language Perl. It isn't about random pieces
of software that happen to be written in Perl.
(Otherwise, there wouldn't have been a comp.lang.perl.* hierarchie in the
first place - since perl is written in C, we'd be discussing Perl issues
in comp.lang.c).
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Fri, 10 Dec 2004 00:30:57 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Parsing Huge Files
Message-Id: <f7lhr09d6gpbavebhia6ee4h1u4jd56bjp@4ax.com>
On Wed, 08 Dec 2004 21:21:46 -0800, BigDaDDY <ihatespam@hotmail.com>
wrote:
>I have a huge text file (around 700MB) that I am trying to parse. I was
>successful, but I don't think I have done it very efficiently. Basically
>in my program I have a hash containing some unique id numbers which are
>keyed by cartesian (x,y,z) coordinates.
I see later that you use a "HoHoH", which means lot references.
Depending on what you *really* want to do, which unfortunately I
wasn't able to understand, and on how your data looks really like, you
*may* want to use a plain string instead (say "@coords" for example!)
>#!/usr/bin/perl -w
>
>use strict;
BTW:
use warnings; # instead of -w
with recent enough perls.
>my %id;
>
>$id{"200"}{"-11"}{"199.5"} = 123456;
>$id{"201"}{"-11"}{"199.5"} = 246891;
>$id{"202"}{"-11"}{"199.5"} = 169245;
>$id{"200"}{"-45"}{"199.5"} = 274321;
>
># End of example code
This script hardly does anything, so I wonder: it is example code...
of what?!?
>Here is where it is getting difficult for me. I have 8 possible y-values,
>420 x-values and 1 z-value
^^^^^^^^^
^^^^^^^^^
Then I wouldn't use a key for it, but rather assume it implicitly...
>The format of my 700MB file is something like
>
>#ID Value
>123456 200
>274321 100
>246891 400
>169245 600
>123456 300
>274321 50
>246891 600 #each element id occurs 24 times once for each subcase
Where are the "cartesian (x,y,z) coordinates" now? What do they have
to do with *this* format?
>So basically, given a fixed y and z value, loop over all x values and get
>element ids which are then searched for in the big file and reformatted
>into individual files for each unique y-value. Is there a very efficient
>way to do this in Perl?
I'm afraid that notwithstanding your good will and the verboseness of
the description of the problem you gave, (i) it's perfectly clear what
the input file looks like, (ii) it's *not* quite clear what it is that
you want to extract from it.
Since you wrote that it worked in the first place, please show the
actual code you used. Then we may suggest "better" alternatives, if
any exists...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 10 Dec 2004 14:58:00 +1000
From: Matthew Braid <not@invalid.invalid>
Subject: Re: passing string to ksh with system command
Message-Id: <cpbaco$tni$1@bunyip.cc.uq.edu.au>
joez3@yahoo.com wrote:
> Hi all,
> I have a perl scirpt that needs to pass some data to a ksh script, but
> my problem is that one of the strings that I need to pass has a space
> in it. So my ksh script thinks that this is 2 different strings. This
> is how I have this coded right now:
> $type = "com+ app";
> system "runshell.ksh ".$item." "$type;
>
> When the runshell.ksh run it looks like it only sees the com+ and not
> the 2nd half of the string. Is there a way to encase my type string in
> "". I have already tried using "/"com+ app/"" that that didn't seam to
> help.
> Thanks,
> Zim
>
If you're not using any shell meta characters (eg &, *, ? etc), you can
use the multi-argument form of system:
system('runshell.ksh', $item, $type);
This spawns runshell.ksh with arguments that _exactly match what you set
them to_. No shell gets in the way to process the arguments.
Of course if you _need_ to use shell metacharacters, you can't do it
this way - you'll need to quote the space yourself. You can either do it
like so:
$type = 'com+\ app'; # May not work in some shells
system("runshell.ksh $item $type");
or
$type = '"com+ app"';
system("runshell.ksh $item $type");
MB
------------------------------
Date: Fri, 10 Dec 2004 15:00:40 +1000
From: Matthew Braid <not@invalid.invalid>
Subject: Re: passing string to ksh with system command
Message-Id: <cpbaho$tni$2@bunyip.cc.uq.edu.au>
Matthew Braid wrote:
> If you're not using any shell meta characters (eg &, *, ? etc), you can
> use the multi-argument form of system:
>
> system('runshell.ksh', $item, $type);
>
> This spawns runshell.ksh with arguments that _exactly match what you set
> them to_. No shell gets in the way to process the arguments.
>
> Of course if you _need_ to use shell metacharacters, you can't do it
> this way - you'll need to quote the space yourself. You can either do it
> like so:
>
> $type = 'com+\ app'; # May not work in some shells
> system("runshell.ksh $item $type");
>
> or
>
> $type = '"com+ app"';
> system("runshell.ksh $item $type");
>
> MB
Just to be clear - by 'need to use shell metacharacters' I meant 'need
the shell to interpret shell metacharacters'. You can still use say:
system('grep', 'foo', 'a.*');
but it will try to grep for foo in a file literally named a.* - it won't
find all files starting with 'a.'
MB
------------------------------
Date: Fri, 10 Dec 2004 00:30:53 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Question on loops and return values
Message-Id: <29bhr016v5c732hfvjv2t8qip73l7b6uaq@4ax.com>
On 8 Dec 2004 12:04:24 -0800, "James" <djcameron60616@yahoo.com>
wrote:
>Hi Jim,
[snip]
>Thanks again.
>
>James
Please provide some context quoting the relevant parts of the message
you're answering to. In *most* situations it's the Right Thing(TM) to
do. Even if your followup is addressed specifically to "Jim", if it is
posted here, rather than mailed personally to him, it is to be
implicitly intended that you're doing so for the benefit of everybody
who could read it, or at least it is reasonable to assume so.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 10 Dec 2004 00:30:54 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Question on loops and return values
Message-Id: <gtbhr09gg3rnb3m7souvj1rd7jc4bgqsij@4ax.com>
On 8 Dec 2004 12:22:16 -0800, "James" <djcameron60616@yahoo.com>
wrote:
>It was .. for some reason I had the misguided idea that each math
>expression had to be in an eval. I don't know why.
Please provide some context.
PS: I saw a similar line of code in a script written by a friend of
mine. I wonder if there could be a common source/explanation for this
oddity...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Thu, 9 Dec 2004 19:00:40 -0500
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Reg Hash of Hash
Message-Id: <sK5ud.1435$nZ2.1360@fe12.lga>
"Shashank Khanvilkar" <shashank@mia.ece.uic.edu> wrote in message
news:cpa79v$594$1@newsx.cc.uic.edu...
> Hi,
> I have a program as shown below, which should print out all keys which
> have a degree of one. For example the below program should print
> (e, c) = 10
> since "e" has a a degree of one. But it does not work//
>
> $Hoh{"e"}{"c"} = 10;
> $Hoh{"c"}{"f"} = 1;
> $Hoh{"c"}{"d"} = 1;
>
> foreach $n1 (keys %Hoh) {
> my $deg = keys(%{$Hoh{$n1}});
> # print "deg[$n1] = $deg\n";
>
> if ($deg eq 1){
> $n2 = %{$aa{$n1}};
$n2 = (keys %{$aa{$n1}})[0];
> print "($n1, $n2) = $aa{$n1}{$n2}\n";
> }
> }
>
>
> However if i use the below program it works.
> $Hoh{"e"}{"c"} = 10;
> $Hoh{"c"}{"f"} = 1;
> $Hoh{"c"}{"d"} = 1;
>
> foreach $n1 (keys %Hoh) {
> my $deg = keys(%{$Hoh{$n1}});
> # print "deg[$n1] = $deg\n";
>
> if ($deg eq 1){
> foreach $n2 (sort keys %{$Hoh{$n1}}) {
> print "($n1, $n2) = $aa{$n1}{$n2}\n";
> }
> }
> }
I am not sure what the value of $n2 is in you first case. You have
assigned a hash to a scalar. In the second case, the value is a key of
that hash. My fix selects the first key of the hash. (if %aa has the
same structure as %Hoh, it is the only key.)
Bill
------------------------------
Date: 9 Dec 2004 19:16:01 -0800
From: "Shailesh Humbad" <humbads1@hotmail.com>
Subject: Re: regular expressions problem
Message-Id: <1102648561.402299.289440@c13g2000cwb.googlegroups.com>
Ask for regex help in a VBScript forum? Cmon. Besides, my OP didn't
mention VBScript, but seeked a regex solution. Anyway, I solved it on
my own, and I present it here in Perl for those pedants who would
rather complain about formalities than help someone.
#!/usr/bin/perl -W
$TestString = qq{
<td style="text-align: right;" nowrap="nowrap">433</td>
</tr>
<tr class="odd">
<td style="text-align: right;" nowrap="nowrap">99</td>
<td style="text-align: right;" nowrap="nowrap">111</td>
<td style="text-align: right;" nowrap="nowrap">52255</td>
<td style="text-align: right;" nowrap="nowrap">333</td>
<td style="text-align: right;" nowrap="nowrap">2323</td>
</tr>
<tr class="totals">
<td style="text-align: right;" nowrap="nowrap">122</td>
};
# get the second-to-last row
$TestString = reverse($TestString);
$TestString =~ m/slatot\"=ssalc rt<\s*>rt\/<([\s\S]*?)>rt\/</gi;
$LastRow = reverse($1);
print $LastRow."\n";
# Get the columns in the second-to-last row
$LastRow =~ m/\s*<tr[\s\S]*?<td[\s\S]*?>([\s\S]*?)<\/td>
\s*<td[\s\S]*?>([\s\S]*?)<\/td>
\s*<td[\s\S]*?>([\s\S]*?)<\/td>/gix;
print $1."\n";
print $2."\n";
print $3."\n";
# etc.
------------------------------
Date: Fri, 10 Dec 2004 04:03:51 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: regular expressions problem
Message-Id: <x71xdyajfd.fsf@mail.sysarch.com>
>>>>> "SH" == Shailesh Humbad <humbads1@hotmail.com> writes:
SH> Ask for regex help in a VBScript forum? Cmon. Besides, my OP didn't
SH> mention VBScript, but seeked a regex solution. Anyway, I solved it on
SH> my own, and I present it here in Perl for those pedants who would
SH> rather complain about formalities than help someone.
and i bet your regex solution isn't even compatible with vbscript's.
SH> # get the second-to-last row
SH> $TestString = reverse($TestString);
SH> $TestString =~ m/slatot\"=ssalc rt<\s*>rt\/<([\s\S]*?)>rt\/</gi;
^^^^^^
why do that? slow and for sure that is a perlish feature.
why escape the "? it is not special in a regex.
SH> $LastRow = reverse($1);
SH> print $LastRow."\n";
SH> # Get the columns in the second-to-last row
SH> $LastRow =~ m/\s*<tr[\s\S]*?<td[\s\S]*?>([\s\S]*?)<\/td>
SH> \s*<td[\s\S]*?>([\s\S]*?)<\/td>
SH> \s*<td[\s\S]*?>([\s\S]*?)<\/td>/gix;
and that is impossible to read. choose an alternate delimiter. use /x
properly by breaking it up more and adding comments.
so as a pedant, i say your solution is poor and not as useful as you
claim it is. /x will almost surely be another perlish thing that other
regexes don't have.
so try again. see if you can keep up the high quality of your work while
answering all the posts that are off topic. why don't you help the
electrician track down his stalker too?
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 9 Dec 2004 20:50:39 -0800
From: "Shailesh Humbad" <humbads1@hotmail.com>
Subject: Re: regular expressions problem
Message-Id: <1102654239.302481.323740@c13g2000cwb.googlegroups.com>
That code is a contrived and translated version of my actual
(VBScript--actually windows scripting) code solely to show the solution
here in the ng, so that it might help someone in the future. Last I
checked, there is no newsgroup for regular expressions, so I thought
this would be the closest thing.
My question should really have been this. Is there a way, in Perl
regular expressions, to search backward in a string after searching
forward to a particular anchor point? In words, the algorithm would
be:
1. Search forward until you match 'b'.
2. Then search backward until you match 'a'.
3. Give me the contents between 'a' and 'b'.
('a' and 'b' are some pattern)
So is there a regex way to do this?
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 7503
***************************************