[23610] in Perl-Users-Digest
Perl-Users Digest, Issue: 5817 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 17 18:05:48 2003
Date: Mon, 17 Nov 2003 15:05:11 -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 Mon, 17 Nov 2003 Volume: 10 Number: 5817
Today's topics:
Re: arrange form data in same order as on form <flavell@ph.gla.ac.uk>
Re: Bit counting benchmarks Was: count of 1s in a binar (Roy Johnson)
Re: Calling a different shell than the inherited one <nobull@mail.com>
Re: Calling a different shell than the inherited one <jwillmore@remove.adelphia.net>
Re: comments on JAPH? <go@away.spam>
Re: comments on JAPH? <go@away.spam>
Re: Creating UNICODE filenames with PERL 5.8 (Allan Yates)
Re: extract block of text (Tad McClellan)
Re: extract block of text (Tad McClellan)
Re: extract block of text (Sara)
Re: Learn Regex or Perl Frist? <uri@stemsystems.com>
Re: long running perl programs & memory untilization <stanb@panix.com>
Re: multilinepattern match (Tad McClellan)
Re: multilinepattern match (Sara)
PERL array of arrays (BKennedy)
Re: PERL array of arrays <usenet@dwall.fastmail.fm>
Re: PERL array of arrays (Tad McClellan)
Perl Newbie Question <velvety@she.was.velvety>
Re: Perl Newbie Question <noreply@gunnar.cc>
Re: Perl Newbie Question <usenet@dwall.fastmail.fm>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 17 Nov 2003 20:33:43 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: arrange form data in same order as on form
Message-Id: <Pine.LNX.4.53.0311171701500.22311@ppepc56.ph.gla.ac.uk>
On Mon, 17 Nov 2003, Gunnar Hjalmarsson wrote:
> If I didn't make some stupid mistake, the comparison shows that the
> compilation+execution time for parsing a simple query string with 4
> name/value pairs is about 30 times longer when you use CGI.pm compared
> to my code. CGI.pm needs about 0.2 seconds!
And how long does a typical do-nothing browser HTTP transaction and
CGI invocation need in comparison?
> You also disregard my view that CPU may be a critical issue for
> certain users.
Sorry, I really don't "disregard" it. I'm saying the need is to
review the overall process, including server invocation from the
client and the subsequent CGI process creation, which I'm afraid your
benchmarks don't do.
In fact with some rough benchmarking of the overall process (using
LWP::Simple to run the tests against a local webserver), it seemed to
me as if our (otherwise lightly-loaded) server could run about 14
invocations per second of wallclock with your economy-model script,
compared with some 7 per second with CGI.pm, so - a factor of around 2
(wallclock) overall, compared with your measurement of 30 (cpu) for
some portion of the process. On Windows, I even got a factor
approaching 3 between them for the overall process. (Server in both
cases was a version of Apache 1.3.*, on linux and on Win2000
respectively).
While I must admit the factor is somewhat larger than I had expected,
this does rather put your measurement of a factor of 30 into a rather
more realistic context, I feel.
> My program is already dual-mode, but I don't see how CGI.pm would have
> made that easier. On the contrary, certain versions of CGI.pm don't
> work with certain mod_perl versions:
I'm sorry if you felt it had been improper of me not to mention
versioning issues, but it seems to me that adopting use of mod_perl
would inevitably call for a review of the version compatibility of any
related Perl modules that will be used, and CGI.pm would be no
exception there. mod_perl doesn't lack documentation about such
matters.
But if one is genuinely serious about saving CPU cycles, then such an
approach would seem to me to be indispensible. You can see, by the
comparison between your numbers and mine, just what a large proportion
of the execution of CGI is not accounted for by the CGI script itself.
> Surprised? That is my view, and I think I have presented reasons for
> it far beyond "energetic handwaving".
>
> This is the benchmark code:
As I say, that focuses on one part of the invocation of a Perl script
in CGI context, namely the Perl code itself. But that's only a part
of the overall process, as I think we have seen.
Nevertheless, I will concede that any rule can have exceptions. What
I usually say about CGI.pm is that those who have genuinely got the
expertise to *not* use CGI.pm will know why they are doing that, and
will need no advice from me. On the other hand anyone who's in a
position to seek advice is going to get my best advice (and you know
what that's going to be, in the overwhelming proportion of cases).
I'm clearly aware that CGI.pm is in no way magical - the code doesn't
do anything that one couldn't just as well code for oneself. And the
author admits that it's grown too big, and might benefit from being
modularised. I've found the odd bug in it myself on occasion. So
this is not the uncritical adulation that some trolls accuse us of.
Nevertheless, it's overall the best thing available for doing CGI in
Perl, because the author is actively working on it and is actively
adapting it to the changing situation, to encapsulate the gathered
knowledge of browser bugs, workarounds etc.
A proportion of extra CPU cycles isn't usually too high a price to pay
for that. And as we've seen - if it _is_ too high a price to pay,
then the most productive place to make real savings is elsewhere.
Can we call a truce on this, then?
all the best
------------------------------
Date: 17 Nov 2003 09:07:32 -0800
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: Bit counting benchmarks Was: count of 1s in a binary number
Message-Id: <3ee08638.0311170907.17f98e3b@posting.google.com>
But if you unroll the table sub, it retakes the lead. At least on my box.
sub table {
my $x = shift;
$table[ $x & 0xff ] + $table [ ($x >> 8) & 0xff ] +
$table [ ($x >> 16) & 0xff ] + $table [ ($x >> 24) & 0xff ];
}
------------------------------
Date: 17 Nov 2003 17:40:08 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Calling a different shell than the inherited one
Message-Id: <u9ad6uuc5j.fsf@wcl-l.bham.ac.uk>
dn_perl@hotmail.com (dn_perl@hotmail.com) writes:
> I often use C-shell for reasons beyond my control.
>
> I want to call 'sqlplus' from within a perl script while
> using c-shell.
Why do you think that you want to do this?
> But I want the sqlplus to run in k-shell or bash-shell.
Why do you think that you want to do this?
> How can I do this?
If you want system() to start a process via a specific shell:
system('/bin/bash', '-c', 'sqlplus')
> This is just an academic doubt.
Oh.
> If I use :
> system("sqlplus username/password << EOH");
You are confused. What are you expecting that here-doc to do? Do you
think that it is a shell here doc or a Perl one? You are passing '<<
EOH' to be parsed by /bin/sh but you are then putting the here-doc in
the Perl script.
> sqlplus statement one
> sqlplus statement two
> EOH
I suspect you are trying to pass stuff to the sqlplus process STDIN.
You don't do that with system(). You do that with open().
> ... then won't the sqlplus run within the inherited C shell?
What do you mean by the 'inherited C shell'?
Did you mean the inherited environment setting? $ENV{SHELL} = '/bin/csh'
No, perl's system() ignores $ENV{SHELL}
Did you consider the possibilty of looking up the system() function in
the Perl reference manual at all?
> Or is there no such thing as the called sqlplus (or any other
> called command) running within some shell?
In some sense there is - but I don't think that is the sense in which
you meant it.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 17 Nov 2003 18:03:37 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Calling a different shell than the inherited one
Message-Id: <20031117130336.77dfac6b.jwillmore@remove.adelphia.net>
On 16 Nov 2003 18:55:51 -0800
dn_perl@hotmail.com (dn_perl@hotmail.com) wrote:
> I often use C-shell for reasons beyond my control.
So do I at work. However, on servers that have bash installed, I just
type 'bash' and I get to use a real shell :-)
> I want to call 'sqlplus' from within a perl script while
> using c-shell. But I want the sqlplus to run in k-shell
> or bash-shell. How can I do this? This is just an academic doubt.
Huh?
> If I use :
> system("sqlplus username/password << EOH");
> sqlplus statement one
> sqlplus statement two
> EOH
As I posted before ....
--untested--
my $sql_cmd = <<EOH;
username/password
sqlplus statement one
sqlplus statement two
EOH
system("sqlplus $sql_cmd");
--untested--
Now, at the command line, type
perldoc -q "Why don't my <<HERE documents work"
> ... then won't the sqlplus run within the inherited C shell?
> Or is there no such thing as the called sqlplus (or any other
> called command) running within some shell?
And then, after you're done reading that, type at the command line
perldoc -q "environment"
and then
perldoc perlvar
and search for "%ENV"
You may want to check out the DBI module - so you can interact with
the database from Perl without having to use another shell :-)
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Help! I'm trapped in a PDP 11/70!
------------------------------
Date: Mon, 17 Nov 2003 19:40:12 GMT
From: "LaDainian Tomlinson" <go@away.spam>
Subject: Re: comments on JAPH?
Message-Id: <wu9ub.10268$C14.703382@twister.southeast.rr.com>
"Thomas Kratz" wrote:
> Comments anyone?
Sure.
http://www.perlmonks.com/index.pl?node=Obfuscated%20Code
You might get more response over there. This newsgroup is leans more toward
problem solving than Perl's silly side.
Brandan L.
--
$_=q$,197+,27S,137,08(),09-K,13,11%1332230!b#>:!+'t{$;srand$=;sub'x{$$$x+=po
p}$
qw=sub{$q++;$i[pop@a]=pop};unshift@a,x$_
for(map{reverse+split$,}/(\d*)!/g);&{$
qw}($+)while(s=,}?(\d{2})==x);$t=y*3012**d?reverse+split$i[@i]:die$_;@f=map$
i[$
_]?chr$i[$_]:chop$t,0..--$q+length;print+chr(int(rand(58)+65)^ord)for@f,m$JA
PH$
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.541 / Virus Database: 335 - Release Date: 11/14/2003
------------------------------
Date: Mon, 17 Nov 2003 20:09:23 GMT
From: "LaDainian Tomlinson" <go@away.spam>
Subject: Re: comments on JAPH?
Message-Id: <TV9ub.10275$C14.706030@twister.southeast.rr.com>
"LaDainian Tomlinson" wrote:
> --
>
$_=q$,197+,27S,137,08(),09-K,13,11%1332230!b#>:!+'t{$;srand$=;sub'x{$$$x+=po
> p}$
> qw=sub{$q++;$i[pop@a]=pop};unshift@a,x$_
> for(map{reverse+split$,}/(\d*)!/g);&{$
>
qw}($+)while(s=,}?(\d{2})==x);$t=y*3012**d?reverse+split$i[@i]:die$_;@f=map$
> i[$
>
_]?chr$i[$_]:chop$t,0..--$q+length;print+chr(int(rand(58)+65)^ord)for@f,m$JA
> PH$
I think it's time for a decent newsreader.
Brandan L.
--
bclennox AT eos DOT ncsu DOT edu
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.541 / Virus Database: 335 - Release Date: 11/14/2003
------------------------------
Date: 17 Nov 2003 13:01:08 -0800
From: allan@yates.ca (Allan Yates)
Subject: Re: Creating UNICODE filenames with PERL 5.8
Message-Id: <d6f51524.0311171301.168edab3@posting.google.com>
The key was the missing "-C". I didn't clue in from the documentation
that this was important. Once I added that command line parameter, the
file was created with the correct name.
My next step was to read the file name from the directory. However, I
thought I read in some documentation somewhere that 'readdir' is not
UNICODE aware. I seemed to prove this by reading the directory
containing the file I just created. It comes back with a two character
file name that 'ord' into 0xd8 and 0xb6 as you indicated.
Do you know of a method of reading directories to get the UNICODE file
names?
Thanks,
Allan.
"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in message news:<Pine.LNX.4.53.0311171438540.22311@ppepc56.ph.gla.ac.uk>...
> On Mon, 17 Nov 2003, Allan Yates wrote:
>
> > I have been having distinct trouble creating file names in PERL
> > containing UNICODE characters. I am running ActiveState PERL 5.8 on
> > Windows 2000.
>
> N.B I have limited expertise in this specific area, but some of the
> locals around here seem to look to me to answer Unicode questions of
> any kind, so I'll give it a try, as long as you take the answers with
> the necessary grains of salt...
>
> First important question is - have you set the option for wide
> character API in system calls?
>
> > For a simple test, I picked a UNICODE character that could be
> > displayed by Windows Explorer. I can select the character(U+0636) from
>
> that'd be Arabic letter DAD, right?
>
> Its utf-8 representation will be two octets: 0xd8, 0xb6.
>
> > 'charmap' and cut/paste into a filename on Windows Explorer and the
> > character displays the same as it does in 'charmap'. This proves that
> > I have the font available.
>
> (I think that's the least of your worries at the moment...)
>
> > When I attempt to create the same filename with PERL, I end up with a
> > filename two characters long: ض
>
> Those look like 0xd8 and 0xb6 to me...
>
> At a quick glance, I suspect we are seeing the pair of octets that
> represent the character in utf-8 (Perl's internal representation)
> rather than as what Win32 would use, which AIUI is utf-16LE (which in
> this case would come out as 0x3606, IINM). However, I'm not sure that
> (other than for diagnostic purposes) you should ever need to tangle
> with it in that form, since Perl ought to know what to do in a (wide)
> system call.
>
> The system call is evidently treating them as two one-byte characters,
> hence my question about wide system calls. Look for the reference to
> wide system calls in the perlrun page, and the other references to
> which it links.
>
> > I somebody could point me in the correct direction, I would very much
> > appreciate it. I have read the UNICODE documents included with PERL as
>
> OK, but there are also some Win32-specific documents/web-pages that
> come with the ActivePerl distribution. In some situations they might
> be just what you need.
>
> > well searching the newgroups and the web, and everything appears to
> > indicate this should work.
>
> If the above is not the answer, then maybe Win32API::File has
> something for you - but I've never been there myself, so don't pay too
> much attention to that.
>
> > Perl program:
>
> But did you start it with the -C option, or set the wide system calls
> thingy? I think that may prove to be the key.
>
> Good luck, and please report your findings.
------------------------------
Date: Mon, 17 Nov 2003 10:07:30 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: extract block of text
Message-Id: <slrnbrhsi2.d13.tadmc@magna.augustmail.com>
Christoph Schuch <christoph.schuch@gmx.at> wrote:
> **** Post for FREE via your newsreader at post.usenet.com ****
^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
I'll add that to my scorefile. Thanks.
> The following Code should handle your task
>
>
> open(filein,"<file")
That has a syntax error.
You should use UPPER CASE filehandles.
You should always, yes *always*, check the return value from open():
open(FILEIN, 'file') or die "could not open 'file' $!";
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 17 Nov 2003 10:14:32 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: extract block of text
Message-Id: <slrnbrhsv8.d13.tadmc@magna.augustmail.com>
mike <s99999999s2003@yahoo.com> wrote:
> how can i extract the data from "Heading2" to "Heading3" such that
> i have this output without the "Headings" and without the empty lines.
--------------------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
my $record = '';
while ( <DATA> ) {
if ( m#/\* ----------------- Heading\d+ ----------------- \*/# ) {
$record =~ s/^\s+//;
$record =~ s/\s+$//;
print "$record\n-----\n";
$record = ''; # clear buffer
}
else {
$record .= $_;
}
}
# final record
$record =~ s/^\s+//;
$record =~ s/\s+$//;
print "$record\n-----\n";
__DATA__
/* ----------------- Heading1 ----------------- */
line: Heading1 type: b
#owner: you@company.com
/* ----------------- Heading2 ----------------- */
line: Heading2 type: c
command: echo "hi"
owner: me@company.com
machine: server
/* ----------------- Heading3 ----------------- */
....
--------------------------------------------------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Nov 2003 11:08:10 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: extract block of text
Message-Id: <776e0325.0311171108.2f2d6105@posting.google.com>
"Christoph Schuch" <christoph.schuch@gmx.at> wrote in message news:<3fb8e7d0@post.usenet.com>...
> **** Post for FREE via your newsreader at post.usenet.com ****
>
> The following Code should handle your task
>
>
> open(filein,"<file")
>
> while ($line=<filein>) {
>
> if ( $line =~ m/\/\* -+ Heading2 -+ \*\/ ) { $flag=0 };
>
> if ( $flag == "1" && ! ( $line =~ m/^$/ )) {
> print $line;
> }
>
> if ( $line =~ m/\/\* -+ Heading1 -+ \*\/ ) { $flag=1 };
> }
>
>
> christoph
>
>
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> *** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
> http://www.usenet.com
> Unlimited Download - 19 Seperate Servers - 90,000 groups - Uncensored
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Bleech- if you're looping through this data line by line you might as
well use Basic or Fortran.. and if you INSIST on looping at least
slurp the file into an array with my @f = <F> , close the file, then
loop over the array (its debuggable for one thing).
But hey let's use the power of Perl as long we we're using Perl? I'm
not going to solve your entire problem but here is a nice approach
(with no looping) and it has a much more useful output should your
requirements change later (as they often do in the real world) (don;t
ya hate parenthetical expressions?):
#!/usr/bin/perl -wd
$_ =
'/* ----------------- Heading1 ----------------- */
line: Heading1 type: b
#owner: you@company.com
/* ----------------- Heading2 ----------------- */
line: Heading2 type: c
command: echo "hi"
owner: me@company.com
machine: server
/* ----------------- Heading3 ----------------- */
line: Heading3 type: x
command: echo "hi"
owner: me@company.com
machine: server
';
@a = split /\n*\/\*\s*\-+\s*Heading(\d+)[^\n]+\n\n*/;
shift @a unless $a[0]; # toss off empty element
my %a = @a;
print "done\n";
*************************************************************************
The neat part is you have what you wanted (cleaned up blocks), but
stored in a HASH with a hashkey that is the header number, voila!
DB<1> x %a
0 1
1 'line: Heading1 type: b
#owner: you@company.com'
2 3
3 'line: Heading3 type: x
command: echo "hi"
owner: me@company.com
machine: server
'
4 2
5 'line: Heading2 type: c
command: echo "hi"
owner: me@company.com
machine: server'
So now you can do whatever you like with the blocks, and in fact the
whole program was really like 3 lines, no loops, very easily debugged
and changed.
G
------------------------------
Date: Mon, 17 Nov 2003 18:23:20 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Learn Regex or Perl Frist?
Message-Id: <x77k1ykg6f.fsf@mail.sysarch.com>
>>>>> "JWK" == John W Krahn <krahnj@acm.org> writes:
JWK> Uri Guttman wrote:
>>
>> >>>>> "JWK" == John W Krahn <krahnj@acm.org> writes:
>>
JWK> Ben Morrow wrote:
>> >>
>> >> One of the things it can be is a regex, and there is a special
>> >> operator '=~' in Perl which means 'match this regex against this
>> >> string'.
>>
JWK> Actually =~ is the binding operator and if used with tr/// there is no
JWK> regex involved.
>>
>> that is a good point that is not mentioned often enough. but what does
>> this do?
>>
>> 'abc' =~ ( foo() . $bar ) ;
JWK> Something similar to:
JWK> 'abc' =~ /@{[ foo() ]}$bar/ ;
correct (except for the context. in mine foo() is called in scalar
context and yours calls it in list context).
my point is that =~ is the binding operator but given just an expression
on the right side (no //, m//, s/// or tr///) it will assume m// for the
expression and compile it as such. so =~ has some regex flavor to it as
well as binding. but i do dislike it being called the regex op (mostly
by newbies who don't know about tr/// and that it is not a regex op).
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: Mon, 17 Nov 2003 16:35:26 +0000 (UTC)
From: Stan Brown <stanb@panix.com>
Subject: Re: long running perl programs & memory untilization
Message-Id: <bpatce$qoe$2@reader2.panix.com>
In <bp5gho$e4a$1@wisteria.csv.warwick.ac.uk> Ben Morrow <usenet@morrow.me.uk> writes:
>Stan Brown <stanb@panix.com> wrote:
>> In <bp1547$h0a$2@wisteria.csv.warwick.ac.uk> Ben Morrow
>> <usenet@morrow.me.uk> writes:
>> >Stan Brown <stanb@panix.com> wrote:
>> >> In <20031113163837.417$N1@newsreader.com> ctcgag@hotmail.com writes:
>> >>
>> >> >Stan Brown <stanb@panix.com> wrote:
>> >> >>
>Part of providing a minimal example is removing all modules that can
>be removed while still leaking. IMHO (and not really having much
>justification for this beyond instinct), the only modules likely to
>cause leaks here are Image::Magick, Imager and V::C::V4l. As you say
>below that it still leaks if you use system() to run v4lctl, I reckon
>your problem may be with Image::Magick. What happens if you just run
>your addtime() routine in a loop?
Good catch, I replaced the addtiem subroutine with a simple rename call,
which does aeverything that the original subroutine does _except_ adding
the timestamp to the image, and that appears to ahve stoped teh memory
leak.
I grabed the majority of the code for that loop from a perl script that I
found on one of my debian machines. Unfortunately teh comments were in
French, which I don't speak, so perhaps I munged up the use of it.
I'm enclosing a copyt of just thta subroutine, in the hope that someone can
point out how I'm miss using it. Or sugest an alternative way of doing the
same thing.
Thanks for everyone's patienace with thie!
sub addtime($$$$$) {
##################################################################
#
# reads in temporary capture file adds timestamp, and writes
# it to the permanent location
#
# Argument 1 is filename that the labled image should be stored as
#
# Argument 2 is the label to apply
#
# Argument 3 is the filename that the image is curently in
#
# Argument 4 is the color to label the image with
#
# Argument 5 is the font size to use for the label
#
###################################################################
my $final_filename = $_[0];
my $l_tstamp = $_[1];
my $l_tmpfile = $_[2];
my $l_lbl_color = $_[3];
my $l_lbl_size = $_[4];
my $image = Image::Magick->new(magick=>'GIF',font=>'clean');
$image->Read($l_tmpfile);
#On ajoute le text
$image->Annotate(fill=>'white',
pointsize=>$l_lbl_size,
text=>$l_tstamp,
gravity=>'SouthWest',
stroke=>$l_lbl_color,
fill=>'black',
y=>(int($l_lbl_size * 1.4)));
#On écrit le fichier
$image->Write($final_filename);
}
The call to this subroutine is followed (in main() imediately by:
unlink($tmpfile);
Anyone see anything wrong with this?
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
------------------------------
Date: Mon, 17 Nov 2003 10:03:36 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: multilinepattern match
Message-Id: <slrnbrhsao.d13.tadmc@magna.augustmail.com>
Sunil <sunil_franklin@hotmail.com> wrote:
> Hi,
> I have to match a string like
>
> "end;
> /"
>
> in a file. Any suggestions on how to do this?
All of these will match that string:
//
/./
/.*/s
/e/
/;/
/end/
/"/
/"end;\n\/"/
m#"end;\n/"#
1) post real Perl code as suggested in the Posting Guidelines.
I cannot tell if those double quotes are in the string or not...
2) tell us what it is about the string that you want to match on,
else any of the above will do what you have asked for.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Nov 2003 10:42:37 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: multilinepattern match
Message-Id: <776e0325.0311171042.1adbfb60@posting.google.com>
"Sunil" <sunil_franklin@hotmail.com> wrote in message news:<Np%tb.1$U71.32@news.oracle.com>...
> Hi,
> I have to match a string like
>
> "end;
> /"
>
> in a file. Any suggestions on how to do this?
>
> Thanks,
> Sunil.
look at the "s" and "m" switches in perl regexes, for starters they
are very useful for multiline inputs.
On this other hand you can do this match with no switches:
#!/usr/bin/perl -wd
$_ = "a bunch of
stuff
is here..
end;
/
thats all
folks";
print "Eureka!\n" if /end;\n\//;
************************************************************************
I guess would be one way?
-G
------------------------------
Date: 17 Nov 2003 13:39:51 -0800
From: b_t_k@hotmail.com (BKennedy)
Subject: PERL array of arrays
Message-Id: <53240d5a.0311171339.9595521@posting.google.com>
I've done some reading and I'm having difficulties implementing an
'array of arrays'. I've made a random number generator that places 10
numbers (0 to 100) into an 10 element array(A). I'm now trying to
make and print back another 10 element array (B) that contains 10 of
the first arrays (A) (I don't want to flatten each array (A) into a
single array (B)).
Example:
1 74 45 23 ...etc
34 15 33 0 ...etc
23 44 11 5 ...etc
Any examples are appreciated. Thanks in advance.
------------------------------
Date: Mon, 17 Nov 2003 21:46:32 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: PERL array of arrays
Message-Id: <Xns9436AAA62A4EEdkwwashere@216.168.3.30>
BKennedy <b_t_k@hotmail.com> wrote:
> I've done some reading and I'm having difficulties implementing an
> 'array of arrays'.
Have you looked at 'perldoc perllol' ? That has a number of examples
that should get you started.
--
David Wall
------------------------------
Date: Mon, 17 Nov 2003 16:29:30 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: PERL array of arrays
Message-Id: <slrnbriiua.dkt.tadmc@magna.augustmail.com>
BKennedy <b_t_k@hotmail.com> wrote:
> I've done some reading
Did it include:
perldoc perllol
??
> and I'm having difficulties implementing an
Show us your implementation, and we will help you fix it.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 17 Nov 2003 22:11:38 -0000
From: "Nadine" <velvety@she.was.velvety>
Subject: Perl Newbie Question
Message-Id: <bpbgvm$2j8$1@newsg1.svr.pol.co.uk>
Hey all, I'm new to Perl, trying to create a Perl script that retrieves text
from another web page, does anyone know of any similar examples on the net
or anything? I just want something simple to get me going really. I'm
assuming I'd use HTTP::Request?
TIA
--
Nadine
"I think that witchy lady been cooking up some spells, 'cause when she
walks on by you know I love the way she smells"
------------------------------
Date: Mon, 17 Nov 2003 23:18:41 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl Newbie Question
Message-Id: <bpbhmj$1m9fav$1@ID-184292.news.uni-berlin.de>
Nadine wrote:
> Hey all, I'm new to Perl, trying to create a Perl script that
> retrieves text from another web page, does anyone know of any
> similar examples on the net or anything? I just want something
> simple to get me going really. I'm assuming I'd use HTTP::Request?
Check out LWP::Simple. (It makes use of HTTP::Request, among other
things, behind the scenes.)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 17 Nov 2003 22:46:58 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Perl Newbie Question
Message-Id: <Xns9436B4E5AF52Cdkwwashere@216.168.3.30>
Nadine <velvety@she.was.velvety> wrote:
> Hey all, I'm new to Perl, trying to create a Perl script that
> retrieves text from another web page, does anyone know of any
> similar examples on the net or anything? I just want something
> simple to get me going really. I'm assuming I'd use HTTP::Request?
Try LWP::Simple -- it may be all you need.
------------------------------
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.
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 5817
***************************************