[9643] in Perl-Users-Digest
Perl-Users Digest, Issue: 3237 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 23 16:07:21 1998
Date: Thu, 23 Jul 98 13:00:19 -0700
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, 23 Jul 1998 Volume: 8 Number: 3237
Today's topics:
Re: '!' instead of filename in output of warn() merzky@my-dejanews.com
-e glob $filename returns true and false in identical c <John.Adams@BentonvilleAR.ncr.com>
Re: [Perl for WIn32] -e Command line script? scott@softbase.com
Re: [Perl for WIn32] -e Command line script? (Larry Rosler)
Re: [Perl for WIn32] -e Command line script? <JKRY3025@comenius.ms.mff.cuni.cz>
Re: comparing files in perl <jdporter@min.net>
Re: Connecting to MS Access DB on NT from Linux/Apache <frankie@etsetb.upc.es>
Re: delete while iterating over array ((null))
eval and CGI::Carp qw(fatalsToBrowser) <frankie@etsetb.upc.es>
Re: extracting price from string merzky@my-dejanews.com
Re: has anyone attempted a script that can replicate it (John Moreno)
Re: Hash tree problems. <jdporter@min.net>
Help - Need disclaimer for code/exe in pTK and p2xstd(a chuckkovacs@my-dejanews.com
Re: Last Name First... <jdporter@min.net>
Re: Last Name First... (Craig Berry)
Re: Location Command (Robert Saunders)
Re: MsDev Automation with Perl scott@softbase.com
parsing question <alexb@sig.net>
Re: parsing question (Larry Rosler)
Re: Perl array name <tchrist@mox.perl.com>
Re: Perl for Embedded Systems? Misc Qestions... <jhi@alpha.hut.fi>
Re: Perl with SSI (Rachel J King)
Re: question about the @_ variable (Craig Berry)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 23 Jul 1998 19:07:10 GMT
From: merzky@my-dejanews.com
To: bdbeck@ix.netcom.com
Subject: Re: '!' instead of filename in output of warn()
Message-Id: <6p81ku$cds$1@nnrp1.dejanews.com>
In article <6p7j25$qva$1@nnrp1.dejanews.com>,
spacy13@my-dejanews.com wrote:
> Hi,
>
> I'm pretty new to programming in Perl, so please forgive me if this is a
> stupid question. Hope it's not. I couldn't find anything useful by searching
> dejanews either.
>
> I'm using Perl 5.004_04 on a FreebSD system. The following code...
>
> --- snip: test.pl ---
> #!/usr/local/bin/perl
>
> # line 1!
> warn('hello');
> --- snip ---
>
> produces this output
>
> --- snip ---
> $ ./test.pl
> hello at ! line 1.
> $
> --- snip ---
>
> If I remove any character from
> # line 1!
> I get the expected output:
> --- snip ---
> $ ./test.pl
> hello at ./test.pl line 4.
> $
> --- snip ---
>
> Does anybody have an idea why this happens? Did I miss something?
confirmed on Linux 2.0.34 using 'perl, version 5.004_04 built for i386-linux'.
Valid for every comment line matching /^ *# *line ?! *$/ (only spaces,
no tabs...). Warn (or die) can follow anywhere, any number of times (at least
for warn), also eval'ed and in subroutines, and with any message. It does not
effect external packages.
Strange thing indeed... :-) *sratch*
Andre.
>
> Please respond also by email to bdbeck@ix.netcom.com because I don't monitor
> this group regularily.
>
> Thanks
> Bernhard
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
>
--
Andre Merzky
pinocchio@earthling.net
http://pino.home.pages.de/
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 23 Jul 1998 13:58:32 -0500
From: John Adams <John.Adams@BentonvilleAR.ncr.com>
Subject: -e glob $filename returns true and false in identical cases
Message-Id: <35B787D8.3DEC@BentonvilleAR.ncr.com>
This really has me going. There's a minor oddity, and then there's a
major headache.
Now, using two identical versions of 5.004_004, installed on
nearly-identical systems, using the same input, I'm getting a real big
headache. Here's the code, with most all the slop removed:
#!/usr/bin/perl -d
chdir("/home/data/archives/.inventory/");
@ARGV = "/home/adamsj/numzone.txt";
while (<>) {
chomp;
($key,$value) = split;
$numzone{$key} = $value;
}
print "One more time for the...\n\n";
open(LOOKAME,">/tmp/lookame");
if (-e glob "isp0001.inventory.????????????") { print "0001okay!\n"; }
if (-e glob "isp0002.inventory.????????????") { print "0002okay!\n"; }
print "Just for the heck of it...\n\n";
foreach $key (sort keys %numzone) {
print "$key\t$numzone{$key}\n";
$storefile = "isp" . "$key" . ".inventory.????????????";
if (-e glob $storefile) {
print glob $storefile;
print "\n";
print LOOKAME "Yassir! $key\n";
} else {
print LOOKAME "Nossir! $key\n";
}
}
close(LOOKAME);
print "for key = 0002 numzone = $numzone{0002}\n";
First, the minor oddity.
Here's what happens on one machine...
$ ./inver_maker
Loading DB routines from perl5db.pl version 1.01
Emacs support available.
Enter h or `h h' for help.
main::(./inver_maker:2):
chdir("/home/data/archives/.inventory/");
DB<1> n
main::(./inver_maker:3): $invholddir =
"/home/data/archives/.inventory/";
DB<1>
main::(./inver_maker:4): @ARGV = "/home/adamsj/numzone.txt";
DB<1>
main::(./inver_maker:11): print "One more time for
the...\n\n"; <----Notice the sequence!
DB<1>
main::(./inver_maker:6): chomp;
DB<1>
main::(./inver_maker:7): print;
Here's what happens on the other...
main::(./inver_maker:2):
chdir("/home/adamsj/archives/.inventory/");
DB<1> n
main::(./inver_maker:3): $invholddir =
"/home/adamsj/archives/.inventory;
DB<1>
main::(./inver_maker:4): @ARGV = "/home/adamsj/numzone.txt";
DB<1>
main::(./inver_maker:5): while (<>)
{ <----Normally sequenced!
DB<1>
main::(./inver_maker:6): chomp;
DB<1>
main::(./inver_maker:7): print;
But here's the really puzzling part. Both versions do this:
0001okay!
0002okay! <----both globs are true the first
time around...
Just for the heck of it...
0001 648M00 <----...but here, only the glob on
0001 is true
isp0001.inventory.199807061643
0002 123D56 <----while the glob on 0002 returns
false
0003 322K30
Now, puh-LEEZE tell me the answer to this question:
Why did one -e glob $filename return false and one return true, when
both of them returned true in the first, hard-coded version?
I can work around this, no problem, with a system("ls...") thingy, but
the way this is acting makes no sense to me, and I want to know what's
happening!
John A
...speaking only for himself, not his employer...
...but speaking preetty loudly anyhoo, I'd say...
------------------------------
Date: 23 Jul 1998 19:19:47 GMT
From: scott@softbase.com
Subject: Re: [Perl for WIn32] -e Command line script?
Message-Id: <35b78cd3.0@news.new-era.net>
Mike Arms (marms@sandia.gov) wrote:
> I am an experienced perl user under Unix, and have just started
> with perl for Win32. I cannot figure out how to pass a simple
> perl script via the command line in a Win95 MSDOS window. Should
> be something like:
> perl -e 'print "Hello world\n"'
> It complains about the quote delimiters.
You have to put the command line in quotes if you're using the
COMMAND.COM/cmd.exe shell interpreters. You can't embed quotes, that I
know of. You can use ' within the string, so you can use Perl ' strings.
You can also use a different shell, like a UNIX port, if you need
UNIX-like behavior.
Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more.
------------------------------
Date: Thu, 23 Jul 1998 12:30:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: [Perl for WIn32] -e Command line script?
Message-Id: <MPG.10212f16c384ad5298973f@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy sent to Mike Arms
<marms@sandia.gov>.]
In article <35B781DE.428A@sandia.gov> on Thu, 23 Jul 1998 12:33:02 -0600,
Mike Arms <marms@sandia.gov> says...
> I am an experienced perl user under Unix, and have just started
> with perl for Win32. I cannot figure out how to pass a simple
> perl script via the command line in a Win95 MSDOS window. Should
> be something like:
>
> perl -e 'print "Hello world\n"'
>
> It complains about the quote delimiters. I have tried backslashing
> the quotes, no luck. What would I need to type to get MSDOS to
> correctly pass my command line perl script. (I do this so often
> under Unix that it has become second nature to me.) Yes, I did
> search both of the perl for Win32 FAQ's.
This has been here before, lots of times!
perl -e "print qq{Hello world\n}"
Explanation: The default so-called 'command interpreters' on Win32 don't
understand single quotes as quoting characters. You have to use double-
quotes. Then the easiest way to get a double-quoted string inside them
is to use qq{}.
(I do this so often under DOS that it has become second nature to me
under Unix :-)
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 23 Jul 1998 21:40:32 -0700
From: Jan Krynicky <JKRY3025@comenius.ms.mff.cuni.cz>
Subject: Re: [Perl for WIn32] -e Command line script?
Message-Id: <35B81040.2AD1@comenius.ms.mff.cuni.cz>
Mike Arms wrote:
>
> I am an experienced perl user under Unix, and have just started
> with perl for Win32. I cannot figure out how to pass a simple
> perl script via the command line in a Win95 MSDOS window. Should
> be something like:
>
> perl -e 'print "Hello world\n"'
>
> It complains about the quote delimiters. I have tried backslashing
> the quotes, no luck. What would I need to type to get MSDOS to
> correctly pass my command line perl script. (I do this so often
> under Unix that it has become second nature to me.) Yes, I did
> search both of the perl for Win32 FAQ's.
>
> Thanks for any feedback.
>
> --
> Mike Arms
comand.com and cmd.exe understand only doublequotes!
Furthermore, you may not escape the dblquote anyhow.
Things like
c:\> perl -e "...\"...\"..."
will not work.
You wil need to write your code as:
c:\> perl -e "print qq{Hello world\n}"
Anyway since you seem to be a unix guy, go get a unix like shell.
I have seen BASH for example. Sorry do not have pointers, search the
Net.
Jenda
------------------------------
Date: Thu, 23 Jul 1998 19:20:18 GMT
From: John Porter <jdporter@min.net>
Subject: Re: comparing files in perl
Message-Id: <35B78E82.490B@min.net>
Mark-Jason Dominus wrote:
>
> I imagined that the real work of the LCS subroutine would be done by
> a recursive helper function whose arguments were indices into the two
> sequences, rather than the two sequences themselves, and the indices
> would be two integers....
Actually, I have already whipped up a version that does exactly that.
It was AMAZINGLY faster than without memoize.
I have two input files with about 16 lines each, and various minor
differences. Without memoize, the LCS was not computed within
about 10 minutes (I gave up). With memoize, it took 1-2 seconds.
--
John Porter
------------------------------
Date: Thu, 23 Jul 1998 21:10:15 +0200
From: Francesc Guasch <frankie@etsetb.upc.es>
To: Steve Linberg <linberg@literacy.upenn.edu>
Subject: Re: Connecting to MS Access DB on NT from Linux/Apache
Message-Id: <35B78A97.37C3E1D2@etsetb.upc.es>
Steve Linberg wrote:
>
> In article <6oj6jq$5m6$1@camel15.mindspring.com>, "Doug Younger"
> <cgi-bin@mindspring.com> wrote:
> > I've seen references to DBI, DBD::ODBC, and win32 modules and I'm not sure
> > what is needed where. I've also seen some FAQ's that say it's not possible
> > to access a remote server using DBI.
That's not true. I use DBI and DBD::ODBC and a SQL server in a NT
from a solaris box.
--
mailto:frankie@etsetb.upc.es http://www.etsetb.upc.es/~frankie
^-^.-----,
o o _ ) Linux, Windows 95, and Windows NT
Y (_, (__(Ssss (also known as the Good, the Bad, and the Ugly)
------------------------------
Date: 23 Jul 1998 19:30:25 GMT
From: mike@stok.co.uk ((null))
Subject: Re: delete while iterating over array
Message-Id: <6p830h$83b@news-central.tiac.net>
In article <6p73ft$a71$1@nnrp1.dejanews.com>, <dwiesel@my-dejanews.com> wrote:
>Hi,
>
>I have an array where some keys are empty ( "" ). How do I do to delete them?
>I understand that I can't use splice when iterating over the array.
>
>Any suggestions?
You can say
@array = grep {$_ ne ''} @array;
if you don't mind the space it takes.
There's no reason not to use splice if you know what you're doing,
generally working from the "right" of the array wil avoid too many
surprises about subscripts changing - in the debugger:
DB<4> @l = ('a', '', 'b', '', '', 'c', 'd', 'e', '')
DB<5> for ($i = $#l; $i >= $[; $i--) {splice @l, $i, 1 if $l[$i] eq ''}
DB<6> X l
@l = (
0 'a'
1 'b'
2 'c'
3 'd'
4 'e'
)
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Thu, 23 Jul 1998 21:19:42 +0200
From: Francesc Guasch <frankie@etsetb.upc.es>
Subject: eval and CGI::Carp qw(fatalsToBrowser)
Message-Id: <35B78CCE.D4B5A2DF@etsetb.upc.es>
I got a cgi perl script ( the question is more perl than cgi, for sure)
I do:
use CGI::Carp qw(fatalsToBrowser);
so when the cgi dies I see the message in the browser.
I wanted to use eval, but the die message for eval
is showed in the browser ( and passed to $@ )
I really searched the docs for a way to get rid from
the use CGI::Carp in the eval block but I just can
find it.
Could you give me a keyword or something please ?
thank you
--
mailto:frankie@etsetb.upc.es http://www.etsetb.upc.es/~frankie
^-^.-----,
o o _ ) Linux, Windows 95, and Windows NT
Y (_, (__(Ssss (also known as the Good, the Bad, and the Ugly)
------------------------------
Date: Thu, 23 Jul 1998 19:10:25 GMT
From: merzky@my-dejanews.com
Subject: Re: extracting price from string
Message-Id: <6p81r1$cgf$1@nnrp1.dejanews.com>
In article <6p7it4$qs8$1@nnrp1.dejanews.com>,
dwiesel@my-dejanews.com wrote:
> Hi,
>
> I have a small problem. I have a string could look either like this
>
> $string = 'product||500.00||';
>
> or like this
>
> $string = 'product|||500.00||';
>
> I want to extract the price from $string. I have done it like this...
>
> $string =~ /\|\|(.*?)\|\|/;
>
> but then $1 eq '|500.00'.
>
> Can you help me?
$string =~ /\|*([\d\.]*?)\|*/;
^^^^^^ looks only for dezimals and dot.
see man perlre.
Andre.
> // Daniel
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
>
--
Andre Merzky
pinocchio@earthling.net
http://pino.home.pages.de/
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 23 Jul 1998 15:56:05 -0400
From: phenix@interpath.com (John Moreno)
Subject: Re: has anyone attempted a script that can replicate itself and then run the copy?
Message-Id: <1dcmmht.7i1oil6ig0luN@roxboro0-034.dyn.interpath.net>
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
> In article <6p5p5u$qes$1@nnrp1.dejanews.com>,
> jhestyr@my-dejanews.com writes:
> > text
>
> By lack of meaningful content, We'll just use the subject:
>
> Subject: has anyone attempted a script that can replicate itself
> and then run the copy?
>
> yes.
Didn't Abigail have one as a sig a little while ago? Cool, but I
couldn't make heads or tails of it. Line noise (but short - only a
couple of lines).
--
John Moreno
------------------------------
Date: Thu, 23 Jul 1998 19:22:41 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Hash tree problems.
Message-Id: <35B78F12.6123@min.net>
Michael Bowler wrote:
>
> Mark-Jason Dominus wrote:
> >
> > But I thought that `exists' was not supposed to trigger any sort of
> > autovivification; if it does, that is certainly a bug. I wonder what
> > version of Perl Michael is using?
>
> I am using 5.002. I suppose that this is pretty old. If this is a bug that
> has been fixed in later releases I will push our sys admin to upgrade.
I have 5.004_04, and it still does this.
As tchrist pointed out, we're stuck with it.
It's not a bug, it's a feature. :-)
--
John Porter
------------------------------
Date: Thu, 23 Jul 1998 18:46:48 GMT
From: chuckkovacs@my-dejanews.com
Subject: Help - Need disclaimer for code/exe in pTK and p2xstd(aka perl2exe)
Message-Id: <6p80eo$b6t$1@nnrp1.dejanews.com>
All,
I've written a useful pTk program, a alarm/reminder thingy.
1) written in pTk and available as a .pl
2) compiled with p2xstd beta (aka perl2exe)
I would like to distibute both for free, but what sort
of disclaimer/legal mumbo-jumbo do I need to include?
Thanks,
Chuck
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 23 Jul 1998 19:16:23 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Last Name First...
Message-Id: <35B78D98.3C20@min.net>
Al Gordon wrote:
>
> I have a text tab-delimeted file ...
> The third field contains names of businesses and individuals.
> Businesses might be something like: "Joe Smith Corp." (without the
> quotes) and individuals are listed like "Smith, Joe" or "Smith, Joe
> W." (again, without the quotes).
>
> I need to convert the "lastname, firstname" formatted text in the file
> to "firstname lastname" (both without quotes). The business names in
> the third field will not contain commas (or at least I hope they
> don't).
while(<>) {
my @a = split /\t/;
if ( $a[1] =~ /,/ ) { $a[1] = "$' $`"; }
print join("\t",@a);
}
--
John Porter
------------------------------
Date: 23 Jul 1998 19:37:13 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Last Name First...
Message-Id: <6p83d9$igp$2@marina.cinenet.net>
Al Gordon (al@ioa.com) wrote:
: I have a text tab-delimeted file that follows a format something like
: this:
:
: field 1<tab>field 2<tab>field 3<tab> ... etc.
OK, so (leaving out the trivial code to open the input and output files,
and loop over the lines of input) the first step is to do
my @fields = split /\t/;
on each line to split the fields into array elements.
: The third field contains names of businesses and individuals.
: Businesses might be something like: "Joe Smith Corp." (without the
: quotes) and individuals are listed like "Smith, Joe" or "Smith, Joe
: W." (again, without the quotes).
:
: I need to convert the "lastname, firstname" formatted text in the file
: to "firstname lastname" (both without quotes). The business names in
: the third field will not contain commas (or at least I hope they
: don't).
OK, so we're talking about $fields[2]. Here's how I'd write it:
$fields[2] =~ s/(.*?)\s*,\s+(.*)/$2 $1/;
If there's no comma in the field, this is a no-op; otherwise, it reverses
the chunks before and after a comma (and its surrounding whitespace).
Then you'd just print out the transformed data, rejoined into the original
tab-separated format:
print join "\t", @fields;
You can actually do this without splitting and joining, but the regex
involved gets much hairier. I'd suggest this as a good, easy to
understand approach unless you're going to run this thing often on huge
files.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Thu, 23 Jul 1998 19:46:22 GMT
From: robert@iminet.com (Robert Saunders)
Subject: Re: Location Command
Message-Id: <E310008A4B77F5FF.FF1250DF77E9C966.15215187310D0F43@library-proxy.airnews.net>
I found the answer myself.. but I wanted to share it with everyone..
print "Window-target: top\n";
print "Location: $FORM{'cgi_select'} \n\n";
That did the trick
Robert
On Thu, 23 Jul 1998 16:49:37 GMT, robert@iminet.com (Robert Saunders)
wrote:
>
>Question..
>
>I am using the location command..
>
>print "Location: $FORM{'cgi_select'} \n\n";
>
>which works fine.. but I have a application that I want to target a
>framed page with .. so the script is called from say the bottom
>frame.. but I want the page to load in the top frame.. is there a way
>to do this in perl.. or do I have to do a javascript thing..
>
>Robert Saunders
>robert@iminet.com
>
>Thanks in advance
>
>
------------------------------
Date: 23 Jul 1998 19:17:33 GMT
From: scott@softbase.com
Subject: Re: MsDev Automation with Perl
Message-Id: <35b78c4d.0@news.new-era.net>
eoloughlin@my-dejanews.com wrote:
> I'm trying to do an automated nightly build with DevStudio using perl & OLE.
Easy! Well, once you know how! I've been trying to find someone
to publish this code in a magazine as an article -- anyone need
some filler?
Change the variable $dswfile to point to your project.
Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Perl code to rebuild a project in Developer Studio 97
#
# The variable $dswfile needs to be set to the full path to the
# project you want to rebuild. This script is a bare bones
# skeleton that shows you the basic steps required to rebuild
# a project using Perl and Automation. It could be made much fancier
# by, for example, e-mailing the results to someone.
use OLE;
$dswfile = "g:/scott/oc/oc.dsw";
print "\nRebuilding project $dswfile...\n";
# In addition to just building the project, we also keep track
# of how long it takes.
$begin = time;
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
$mon++;
print("Begin at $hour:$min:$sec on $mon/$mday/$year\n");
# Developer Studio's Automation interface is MSDEV.Application.
# You can find this and info on the object model in the InfoView
# window by drilling down to Developer Products > Visual C++ >
# Devloper Studio Env. User's Guide > Automating Tasks in Dev Studio >
# Devloper Studio Objects.
$ds = CreateObject OLE 'MSDEV.Application'
or die "Couldn't create new instance of DS97!";
#Uncomment this to make DS97 visibile as it does the following steps
#$ds->{Visible} = 1;
$p = $ds->Documents->Open($dswfile);
$ds->RebuildAll();
$ds->Quit();
$end = time;
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
$mon++;
print("Ending at $hour:$min:$sec on $mon/$mday/$year\n");
$e = $end - $begin;
print("Elapsed time = $e seconds\n");
------------------------------
Date: Thu, 23 Jul 1998 14:20:31 -0500
From: Alexander Bibighaus <alexb@sig.net>
Subject: parsing question
Message-Id: <35B78CFE.5AC3636A@sig.net>
hello, if this question is off topic excuse me.
have a question about how to parse a file of a specific format.
The format of the file looks like the following: (except for comments)
Weekday Month Day Year TimeStamp
name = value # note, these lines are indented with a
tab
name = "ascii value"
name = value
name = value
# note: <blank line>
Weekday Month Day Year TimeStamp
name = value
name = value
name = value
name = value
# <blank line>
I can read line by line looking for lines that do not begin with a tab
like I do below. However, I would like to read the whole "record" from
the
date to the blank line into a string. Then parse the record from that
point.
Any suggestion???
while(<>)
{
if(!/^\t/) {
if( /^[MTWFS]/ ) {
# we found the date, so we are reading a new record
}else {
# we found the blank line
}
}else {
# extract value
}
}
thanks,
alexander
------------------------------
Date: Thu, 23 Jul 1998 12:35:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: parsing question
Message-Id: <MPG.102130498309f393989740@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy sent to Alexander Bibighaus
<alexb@sig.net>.]
In article <35B78CFE.5AC3636A@sig.net> on Thu, 23 Jul 1998 14:20:31 -
0500, Alexander Bibighaus <alexb@sig.net> says...
...
> I can read line by line looking for lines that do not begin with a tab
> like I do below. However, I would like to read the whole "record" from the
> date to the blank line into a string. Then parse the record from that point.
> Any suggestion???
Yes. This is perlfaq5: "How can I read in a file by paragraphs?"
Use the $\ variable (see the perlvar manpage for details). You can either
set it to "" to eliminate empty paragraphs ("abc\n\n\n\ndef", for
instance, gets treated as two paragraphs and not three), or "\n\n" to
accept empty paragraphs.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 23 Jul 1998 17:54:47 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl array name
Message-Id: <6p7td7$ljo$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, kpreid@ibm.net (Kevin Reid) writes:
:For opening files, I prefer:
:
:$FILE = '/etc/motd';
:open FILE or die "open of $FILE failed: $!";
:while (<FILE>) {
1) I am afraid of an || sneaking in there.
2) That doesn't help your warn and die messages.
3) That only works on globals.
--tom
--
The X server has to be the biggest program I've ever seen that doesn't
do anything for you. --Ken Thompson
------------------------------
Date: 23 Jul 1998 22:07:07 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Perl for Embedded Systems? Misc Qestions...
Message-Id: <oeebtqgjsis.fsf@alpha.hut.fi>
Wolfgang Denk <wd@uebemc.siemens.de> writes:
>
> Sorry for f'up to my own posting:
>
> >is there anybode using Perl in Embedded Systems? I've looked through
> >the FAQ's and Web pages, but found no or only very few information...
>
> There are two nother question I was unable to answer:
>
> * Is there a way to configure (and compile, but this part is the easy
> one) Perl in a Cross Development Environment?
No. I tried that (and almost finished it) for ChorusOS. Configure
needed quite a lot of kicking. Or actually that was the easy part.
The Makefile was worse.
> * Is there a way to install modules from the CPAN in a Cross
> Development Environment?
No. MakeMaker needs some kicking.
I hope to find some time to integrate my cross-compilation changes to
post-5.005 Perl.
> Thanks in advance,
>
> Wolfgang Denk
>
> --
> Office: (+49)-89-722-27328, Fax -36703 Wolfgang.Denk@oen.siemens.de
> Private: (+49)-89-95720-110, Fax -112 wd@denx.muc.de
> Nail here --X-- for new monitor.
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: 23 Jul 1998 19:51:11 GMT
From: rjking@blue.seas.upenn.edu (Rachel J King)
Subject: Re: Perl with SSI
Message-Id: <6p847f$c8h$1@netnews.upenn.edu>
This question was asked just a few weeks ago, if I remember correctly.
In most cases, it is impossible to get the resulting web page to process
the SSI. The way I've dealt with it is to open the file, read it in, and
just print it to the page like you are the rest of the html. Or, you can
put your SSI in the form of its own perl script and use 'require'.
-Rachel
: Ryan Morgan <rmorgan@cse.unl.edu> writes:
: > is there anyway to enbed ssi directives within perl scripts? I know
: > that you can set up which files are parsed for ssi using the SetHandler
: > command (in the apache config.) , but when the html is generated from a
: > perl script, (eg.. login.pl) the web server wont parse it since its
: > not coming from a file with a .shtml extension. Anyone have a work
: > around?
--
Rachel Jamie King * University of Pennsylvania
rjking@eniac.seas.upenn.edu * Engineering and Applied Science
http://www.seas.upenn.edu/~rjking * Computer Science and Engineering
------------------------------
Date: 23 Jul 1998 19:29:40 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: question about the @_ variable
Message-Id: <6p82v4$igp$1@marina.cinenet.net>
Larry (larryq@nospam.tuttle.com) wrote:
: I've got a little subroutine that does something like the following:
:
: sub MySub
: {
:
: $tempvar=@_;
:
: print length($tempvar);
: }
:
: the subroutine gets called like so:
:
: $hello="hello world";
:
: &MySub($hello);
:
: What's strange is that the print $length($tempvar) statement above always
: prints out a "1".
Of course; anything else would be wrong. After all, you're assigning an
array @_ to a scalar $tempvar. That puts evaluation of the array in a
scalar context, which as we all know results in the number of elements in
the array -- 1, in this case.
What you want to pull values out of @_ looks like
my ($tempvar) = @_;
or
my $tempvar = shift;
or
my $tempvar = $_[0];
I tend to prefer the first form.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 3237
**************************************