[6864] in Perl-Users-Digest
Perl-Users Digest, Issue: 489 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 16 19:07:18 1997
Date: Fri, 16 May 97 16:00:30 -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 Fri, 16 May 1997 Volume: 8 Number: 489
Today's topics:
Re: "email me when the URL changes" script? <rootbeer@teleport.com>
$filename = ($event->file =~ /([^.]+)/, $1); <kshaw@plight.lbin.com>
Re: $filename = ($event->file =~ /([^.]+)/, $1); (Mike Stok)
$number = hex("ffff1c20") no work (Tony Whyte)
Re: [Q] Non-intermeshing output streams when capturing (Gerben Vos)
Re: [Q] Non-intermeshing output streams when capturing (Mike Stok)
Accessing/changing NT file permissions from Perl <s.mckee@kainos.com>
Re: Analyzing my() variables in the debugger <jay@rgrs.com>
Re: Can you help with a perl module? <rootbeer@teleport.com>
Re: Can you help with a perl module? <mark@sierra-inc.com>
Re: Cant get Perl up and running <rootbeer@teleport.com>
Re: Creating Complex Data Structure <rootbeer@teleport.com>
Does Perl have the case statement or do I have to use i (David Dougal)
Re: Does Perl have the case statement or do I have to u (Even Holen)
Re: Does Perl have the case statement or do I have to u <dean@tbone.biol.sc.edu>
Re: Does Perl have the case statement or do I have to u (Abigail)
Re: Does Perl have the case statement or do I have to u (Jeff Stampes)
Error: keys $main::element->attributes() <kshaw@plight.lbin.com>
Re: Error: keys $main::element->attributes() (Mike Stok)
File Locking (Tsoi Tung Yin Tony)
help - grep lines between two line patterns <help@cadvision.com>
Re: help - grep lines between two line patterns (Mike Stok)
Re: help - grep lines between two line patterns (Tad McClellan)
Re: help - grep lines between two line patterns (Abigail)
Re: How to put an normal array into an associative one <rootbeer@teleport.com>
I need a programmers assistance... winnt@winnt.icss.com
Re: I need a programmers assistance... (Nathan V. Patwardhan)
Internet for free worldwide (Future Net)
Re: ls vs. readdir (Frank Miles)
Re: Mystery characters? (Even Holen)
Password Authorisation <dhayden@netcomuk.co.uk>
Perl 5.003 patches? <senelson@negentropy.com>
Pipes and buuffering? (M Melick)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 16 May 1997 12:52:54 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: ctbates <ctbates@tva.gov>
Subject: Re: "email me when the URL changes" script?
Message-Id: <Pine.GSO.3.96.970516124803.20078E-100000@kelly.teleport.com>
On Thu, 15 May 1997, ctbates wrote:
> Could anyone recommend a Perl script that will monitor a URL
> periodically and kick off an email when a certain string appears?
[ I suspect that you want to know when the content of a web page changes,
rather than when the URL changes. URLs are like telephone numbers; they
don't change by themselves! :-) ]
I can't recommend such a script, but if I wrote one (using cron to run it
periodically, using LWP to send the web request, and then calling sendmail
to send off the notice), then I'd be glad to recommend it. :-) And it
should be fairly easy to write and should all fit as one screenful of
text, more or less.
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 16 May 1997 12:43:41 -0700
From: kendall shaw <kshaw@plight.lbin.com>
Subject: $filename = ($event->file =~ /([^.]+)/, $1);
Message-Id: <52hgg3i4nm.fsf@plight.lbin.com>
What is the more concise way of doing this?
------------------------------
Date: 16 May 1997 20:46:33 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: $filename = ($event->file =~ /([^.]+)/, $1);
Message-Id: <5lih39$nso@news-central.tiac.net>
In article <52hgg3i4nm.fsf@plight.lbin.com>,
kendall shaw <kshaw@plight.lbin.com> wrote:
>
>What is the more concise way of doing this?
($filename = $event->file) =~ s/\..*//;
maybe?
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@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 16 May 1997 19:45:28 GMT
From: whyte@sector.kodak.com (Tony Whyte)
Subject: $number = hex("ffff1c20") no work
Message-Id: <5lidgo$qap$1@thetimes.pixel.kodak.com>
My sparc 10 insists that this is negative number and Ill
be damned if I can sprintf my way out of it. I want it to
interpret it as big unsigned number not negative.
How to?
Tony W.
---
____ ______
Tony Whyte | / / |
Eastman Kodak Company | / / |
Optical Storage Products | / / |
460 Buffalo Road |( ( KODAK |
Rochester, NY 14652-3846 | \ \ |
E-mail: whyte@kodak.com | \ \ |
Voice: 716-588-0277 | \ \ |
Fax: 716-588-5578 ---- ------
------------------------------
Date: 16 May 1997 19:50:20 GMT
From: gerben@localhost.cs.vu.nl (Gerben Vos)
Subject: Re: [Q] Non-intermeshing output streams when capturing STDOUT in a pipe
Message-Id: <5lidps$qfl@star.cs.vu.nl>
David S. Patterson writes:
[...]
>However, if I do try to pipe the output to another
>process (perlprog | tee foo.out -for example)
>the output of the program(s) invoked by my main perl
>program go to STDOUT first, and the prints from the
>main perl program are supressed until that program
>terminates. Upon termination, all the stored up
>prints from the main perl program print out.
Perl's standard output is block buffered when it is connected to a pipe,
which means the output buffer is only flushed (and the real outputting is
done) when it is full. When connected to a terminal, the standard output
is usually line buffered.
Luckily, Perl can automatically flush your output when you set
the $| variable to 1. See also the perlvar manual page.
. . . . . . . . . . . . . . . . . . . . . . . . . . . G e r b e n V o s <><
mailto:gerben@cs.vu.nl http://www.cs.vu.nl/%7Egerben/
Ceci n'est pas une .signature .
------------------------------
Date: 16 May 1997 20:24:26 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: [Q] Non-intermeshing output streams when capturing STDOUT in a pipe
Message-Id: <5lifpq$m95@news-central.tiac.net>
In article <337C912B.1CFB@boeing.com>,
David S. Patterson <david.s.patterson@boeing.com> wrote:
>As long as I do not try to pipe the output of my
>main perl program to another process when I invoke
>it from the command line, everything works as expected.
>What is going on here?
You need to set $| = 1 as stdio bufferes stdout differently depending on
whether the output's a tty-like device (in which case it's usually in line
mode and flushes each time it sees a \n) or another type of file (in which
case it's buffered into block size chunks) Setting $| to 1 will cause the
output buffers to be flushed after each print.
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@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 15 May 1997 15:15:44 GMT
From: "Sam McKee" <s.mckee@kainos.com>
Subject: Accessing/changing NT file permissions from Perl
Message-Id: <01bc6143$1e2b7980$330dc3c1@topgun.kainos.com>
(First posted to comp.lang.perl.misc on 10th May - but didn't seem appear
on the newsgroup!)
I am currently attempting to develop a Perl program which will periodically
synchronise the data on two (NTFS) file systems. To do so I need to be able
to determine the file permissions (the ACL) on the original system and to
then impose those permissions on the replicated files.
The Perl stat() function is crippled under NT and while it may be possible
to fudge the issue by calling some of the various NT command-line utilities
which allow manipulation of ACLs this approach seems inelegant and
inefficient. I have looked at some of the Win32 API function calls which
interface to the NT SID and it looks as if these might provide a route but
don't really have the background in NT coding (or even calling these
routines from Perl!) to be sure.
Has anyone else encountered this problem?
Are there any Perl modules which could be used to provide a solution?
Any help will be greatly appreciated.
Thanks, Sam
---------------------------------------
Sam McKee
Senior Systems Engineer
Kainos Software Ltd
---------------------------------------
------------------------------
Date: 16 May 1997 16:59:09 -0400
From: Jay Rogers <jay@rgrs.com>
To: Allen Choy <achoy@us.oracle.com>
Subject: Re: Analyzing my() variables in the debugger
Message-Id: <82k9kzjfqa.fsf@shell2.shore.net>
Allen Choy <achoy@us.oracle.com> writes:
> Does anyone know if it's possible to look/analyze my-type variables
> in the debugger? It's a pain to put print statements.
use the x command
--
Jay Rogers
jay@rgrs.com
------------------------------
Date: Fri, 16 May 1997 13:09:08 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: mark <mark@sierra-inc.com>
Subject: Re: Can you help with a perl module?
Message-Id: <Pine.GSO.3.96.970516130453.20078I-100000@kelly.teleport.com>
On Thu, 15 May 1997, mark wrote:
> I've written a pretty extensive program using perl modules for the first
> time. At first everything was running well, but then I tried running my
> program from a shell script.
Did that script change the current directory? Otherwise, it should still
work, probably.
> Turns out the 'use' command will only work for modules if they're
> located in one of the 'official' directories (listed in @INC) or the
> local directory. Is there any way I can include a '.pm' file located in
> an arbitrary directory?
Sure. That's what 'use lib' is for.
> I've already tried:
>
> >use lib ("/path/to/my/lib");
Oh. Well, maybe you included something wrong in the path. For example, you
shouldn't include the module name; your example should work if 'lib' is a
directory containing your module, but not if your module is named 'lib' or
'lib.pm'. Does that help? Good luck!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Fri, 16 May 1997 11:15:41 -0400
From: mark <mark@sierra-inc.com>
Subject: Re: Can you help with a perl module?
Message-Id: <337C7A1D.5020@sierra-inc.com>
In response to a private email:
>
> I've written a pretty extensive program using perl modules for the first
> time. At first everything was running well, but then I tried running my
> program from a shell script. Turns out the 'use' command will only work
> for modules if they're located in one of the 'official' directories
> (listed in @INC) or the local directory. Is there any way I can include
> a '.pm' file located in an arbitrary directory?
>
> I've already tried:
>
> >use lib ("/path/to/my/lib");
>
> and
>
> >push (@INC, "/path/to/my/lib");
>
> to no avail. I still get errors that the modules cannot be found.
>
> Also, could you possibly email me the response in addition to posting
> it?
Below is a snippet of the code at the top of the program I'm trying to
run:
>$file_base = "/home/kitfox";
>
>push (@INC, "$file_base/perl/");
>#use lib ("$file_base/perl");
>
>use crt_maze;
Origionally the line starting with 'push' wasn't included and the line
starting with 'use lib' wasn't remmed out. And the path to crt_mase is
literally
/home/kitfox/perl/crt_maze.pm
This particular path isn't included in the initial @INC array (thus the
need to push it on there, although perl subsequently ignores it). Is
there any way to get perl to recognize this new path from inside this
program?
Could anyone help? (Please send email).
------------------------------
Date: Fri, 16 May 1997 13:00:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: ddean@aracnet.net
Subject: Re: Cant get Perl up and running
Message-Id: <Pine.GSO.3.96.970516125745.20078H-100000@kelly.teleport.com>
On Thu, 15 May 1997 ddean@aracnet.net wrote:
> I've just installed perl on a Unix box. For some reason it installed it
> in /opt/perl5 instead of /usr/local/bin/perl5.
The location of Perl is one of the configuration questions. What version
of Perl were you installing, and did it really not honor your request?
> Anyway, the installation went fine
Does that mean that 'make test' reported that all tests were successful?
> but when I try to run a script is tells me that it cannot
> execute the file.
What tells you that? Is it perl or the shell? Is the error message listed
in perldiag(1)?
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Fri, 16 May 1997 13:16:26 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Karl Vietmeier <karlv@wayback.er.usgs.gov>
Subject: Re: Creating Complex Data Structure
Message-Id: <Pine.GSO.3.96.970516131102.20078J-100000@kelly.teleport.com>
On Thu, 15 May 1997, Karl Vietmeier wrote:
> Here is the desired format for my data file....
> %quiz_items =
> (
> "questions" =>
> {
> question1 => 'text',
> url => 'http://...',
Looks like Perl. :-)
Maybe you want to simply use require() to read in and execute the data
file. That will work... But you'll need to be sure that you trust the data
file, and whoever has access to it.
A safer way, which is more trouble (of course) would be to actively parse
the file. A recursive set of routines should make that possible.
Another way to be safe would be to use the Safe (Opcode) module. Again,
more work, but it could keep you from having to worry about what's there.
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 16 May 1997 18:22:45 GMT
From: serenite@concentric.net (David Dougal)
Subject: Does Perl have the case statement or do I have to use if statements?
Message-Id: <5li8ll$ed2@chronicle.concentric.net>
Does Perl have the case statement? I can't find any information about case in
Perl.
------------------------------
Date: 16 May 1997 19:43:46 GMT
From: evenh@bigblue.pvv.ntnu.no (Even Holen)
Subject: Re: Does Perl have the case statement or do I have to use if statements?
Message-Id: <slrn5npe7i.qei.evenh@bigblue.pvv.ntnu.no>
In article <5li8ll$ed2@chronicle.concentric.net>, David Dougal wrote:
>Does Perl have the case statement? I can't find any information about case in
>Perl.
No...
You have to rewrite it to a lot of if-statements, or do something else
instead of using the case-statements...
Regards,
Even Holen
--
<>< Even Holen, evenh@pvv.ntnu.no, http://www.pvv.ntnu.no/~evenh/ :-)
------------------------------
Date: 16 May 1997 15:40:50 -0400
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: Does Perl have the case statement or do I have to use if statements?
Message-Id: <m1n2pv19z1.fsf@nauplius.psc.sc.edu>
serenite@concentric.net (David Dougal) writes:
> Does Perl have the case statement? I can't find any information about
> case in Perl.
Did you check the manual pages? In this case, the "perlsyn" page
would have yielded the following, had you checked:
Basic BLOCKs and Switch Statements
A BLOCK by itself (labeled or not) is semantically
equivalent to a loop that executes once. Thus you can use
any of the loop control statements in it to leave or
restart the block. (Note that this is NOT true in eval{},
sub{}, or contrary to popular belief do{} blocks, which do
NOT count as loops.) The continue block is optional.
The BLOCK construct is particularly nice for doing case
structures.
SWITCH: {
if (/^abc/) { $abc = 1; last SWITCH; }
if (/^def/) { $def = 1; last SWITCH; }
if (/^xyz/) { $xyz = 1; last SWITCH; }
$nothing = 1;
}
There is no official switch statement in Perl, because
there are already several ways to write the equivalent.
In addition to the above, you could write
SWITCH: {
$abc = 1, last SWITCH if /^abc/;
$def = 1, last SWITCH if /^def/;
$xyz = 1, last SWITCH if /^xyz/;
$nothing = 1;
}
(That's actually not as strange as it looks once you
realize that you can use loop control "operators" within
an expression, That's just the normal C comma operator.)
or
SWITCH: {
/^abc/ && do { $abc = 1; last SWITCH; };
/^def/ && do { $def = 1; last SWITCH; };
/^xyz/ && do { $xyz = 1; last SWITCH; };
$nothing = 1;
}
or formatted so it stands out more as a "proper" switch
statement:
SWITCH: {
/^abc/ && do {
$abc = 1;
last SWITCH;
};
/^def/ && do {
$def = 1;
last SWITCH;
};
/^xyz/ && do {
$xyz = 1;
last SWITCH;
};
$nothing = 1;
}
or
SWITCH: {
/^abc/ and $abc = 1, last SWITCH;
/^def/ and $def = 1, last SWITCH;
/^xyz/ and $xyz = 1, last SWITCH;
$nothing = 1;
}
or even, horrors,
if (/^abc/)
{ $abc = 1 }
elsif (/^def/)
{ $def = 1 }
elsif (/^xyz/)
{ $xyz = 1 }
else
{ $nothing = 1 }
A common idiom for a switch statement is to use foreach's
aliasing to make a temporary assignment to $_ for
convenient matching:
SWITCH: for ($where) {
/In Card Names/ && do { push @flags, '-e'; last; };
/Anywhere/ && do { push @flags, '-h'; last; };
/In Rulings/ && do { last; };
die "unknown value for form variable where: `$where'";
}
Another interesting approach to a switch statement is
arrange for a do block to return the proper value:
$amode = do {
if ($flag & O_RDONLY) { "r" }
elsif ($flag & O_WRONLY) { ($flag & O_APPEND) ? "a" : "w" }
elsif ($flag & O_RDWR) {
if ($flag & O_CREAT) { "w+" }
else { ($flag & O_APPEND) ? "a+" : "r+" }
}
};
-Dean
--
N. Dean Pentcheff <pentcheff@acm.org> WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83 A0 BF CB C0 D1 0E 76 C0
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"
------------------------------
Date: Fri, 16 May 1997 21:05:56 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Does Perl have the case statement or do I have to use if statements?
Message-Id: <EAAL9w.9C0@nonexistent.com>
On 16 May 1997 18:22:45 GMT, David Dougal wrote in comp.lang.perl.misc
URL: news:5li8ll$ed2@chronicle.concentric.net:
++ Does Perl have the case statement? I can't find any information about
++ case in
++ Perl.
Then you didn't look hard enough.
- Page 104/105 of the Camel II.
- man perlsyn.
- The faq: http://www.perl.org/CPAN/doc/manual/html/pod/perlfaq7/How_do_I_create_a_switch_or_case.html
- Dejanews, querying on 'switch'.
Abigail
------------------------------
Date: 16 May 1997 21:30:48 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: Does Perl have the case statement or do I have to use if statements?
Message-Id: <5lijm8$drk$1@neocad.com>
David Dougal (serenite@concentric.net) wrote:
: Does Perl have the case statement? I can't find any information about case in
: Perl.
See the perl FAQ: "How do I create a switch or case statement" at:
http://www.perl.org/CPAN/doc/manual/html/pod/perlfaq.html
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: 16 May 1997 12:41:43 -0700
From: kendall shaw <kshaw@plight.lbin.com>
Subject: Error: keys $main::element->attributes()
Message-Id: <52iv0ji4qw.fsf@plight.lbin.com>
Hi,
Sorry to be uneducated:
In the debugger if I
p $main::element->attributes()
It says HASH(0x4...).
If I say:
p keys $main::element->attributes()
I get an error message:
Type of arg 1 to keys must be hash (not subroutine entry) at (eval 21)
line 2, near "->attributes;"
How do I get at the hash returned by attributes?
------------------------------
Date: 16 May 1997 20:43:34 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Error: keys $main::element->attributes()
Message-Id: <5ligtm$nkv@news-central.tiac.net>
In article <52iv0ji4qw.fsf@plight.lbin.com>,
kendall shaw <kshaw@plight.lbin.com> wrote:
>If I say:
>
> p keys $main::element->attributes()
>
>I get an error message:
>
>Type of arg 1 to keys must be hash (not subroutine entry) at (eval 21)
>line 2, near "->attributes;"
>
>How do I get at the hash returned by attributes?
Perl doesn't automatically dereference references so if
$main::element->attributes() is returning a hash reference you have to say
@keys = keys %{$main::element->attributes()};
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@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 16 May 1997 16:57:42 GMT
From: eg_tty@uxmail.ust.hk (Tsoi Tung Yin Tony)
Subject: File Locking
Message-Id: <5li3m6$n8n@ustsu10.ust.hk>
I want to lock up a flock using perl that running on the web, in order to
prevent multiple access to the data file. What command should I use? I have try flock() but it seems wrong. Can anyone help me?
Tony ( HKUST student )
------------------------------
Date: Fri, 16 May 1997 10:35:15 -0600
From: CADVision Helpdesk <help@cadvision.com>
Subject: help - grep lines between two line patterns
Message-Id: <337C8CC3.1E5E@cadvision.com>
I need to print out lines between two line patterns such as
foobar1 ....
.
.
hello world etc ..
.
.
foobar2 ....
My script has to grep 'hello world' line between the foobar1 and foobar2
patterns.
Thanks
------------------------------
Date: 16 May 1997 20:21:20 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: help - grep lines between two line patterns
Message-Id: <5lifk0$m5o@news-central.tiac.net>
In article <337C8CC3.1E5E@cadvision.com>,
CADVision Helpdesk <help@cadvision.com> wrote:
>I need to print out lines between two line patterns such as
>
>foobar1 ....
>.
>.
>hello world etc ..
>.
>.
>foobar2 ....
>
>My script has to grep 'hello world' line between the foobar1 and foobar2
>patterns.
Maybe ou want something like
while (<INPUT>) {
print if /^foobar1/ .. /^foobar2/ and /hello wrrld/;
}
(but you may need more logic as .. is a toggle)
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@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Fri, 16 May 1997 15:09:07 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: help - grep lines between two line patterns
Message-Id: <3teil5.0c1.ln@localhost>
CADVision Helpdesk (help@cadvision.com) wrote:
: I need to print out lines between two line patterns such as
^^^^^^^
^^^^^^^
: foobar1 ....
: ..
: ..
: hello world etc ..
: ..
: ..
: foobar2 ....
: My script has to grep 'hello world' line between the foobar1 and foobar2
: patterns.
I think if you did a word search for "between" in the FAQ for this
newsgroup, you would find:
faq.6:=head2 How can I pull out lines between two patterns that are themselves on different lines?
: Thanks
Uh huh.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Fri, 16 May 1997 21:39:37 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: help - grep lines between two line patterns
Message-Id: <EAAMu1.C29@nonexistent.com>
On Fri, 16 May 1997 10:35:15 -0600, CADVision Helpdesk wrote in
comp.lang.perl.misc URL: news:337C8CC3.1E5E@cadvision.com:
++ I need to print out lines between two line patterns such as
++
++ foobar1 ....
++ .
++ .
++ hello world etc ..
++ .
++ .
++ foobar2 ....
++
++ My script has to grep 'hello world' line between the foobar1 and foobar2
++ patterns.
while (<>) {
/foobar1/ .. /foobar2/ and /hello world/ and print;
}
Abigail
------------------------------
Date: Fri, 16 May 1997 13:18:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Pascal Houde <houde@fox.cisti.nrc.ca>
Subject: Re: How to put an normal array into an associative one
Message-Id: <Pine.GSO.3.96.970516131701.20078K-100000@kelly.teleport.com>
On Thu, 15 May 1997, Pascal Houde wrote:
> That's what I want to do:
> $a{'array1'} = @somearray;
> The problem is that @somearray is a LOCAL array returned by a
> subroutine.
I think you may want this. It makes a new, anonymous array, and puts a
reference to it into the hash. Hope this helps!
$a{array1} = [ @somearray ];
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Fri, 16 May 1997 15:51:17 -0600
From: winnt@winnt.icss.com
To: winnt@winnt.icss.com
Subject: I need a programmers assistance...
Message-Id: <863815431.6607@dejanews.com>
Here's my problem,
I have a file on my server './jobs.txt'
and here's what I want to do. I want to
write a subroutine to open the file,
add the numbers in the file which has this
form in the text file,
7
8
9
15
,add all the numbers line by line and
print out the total. All that I've been
able to do so far is print out the file
using the source listed below.
sub score {
print ("more ./scorecard");
}
Can someone assist me in going to the
next level here and make this thing
work?
I have very little programming experience
so please be patient with me.
Thanks.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 16 May 1997 21:08:38 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: I need a programmers assistance...
Message-Id: <5liicm$4oj@fridge-nf0.shore.net>
winnt@winnt.icss.com wrote:
: 7
: 8
: 9
: 15
: ,add all the numbers line by line and
: print out the total. All that I've been
perl -e '$i=0; while(<>){$i+=$_;} print $i,"\n";' number_file.txt
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Fri, 16 May 1997 22:36:30 GMT
From: netfree@hotmail.com (Future Net)
Subject: Internet for free worldwide
Message-Id: <337ce09e.11906476@bang-olufsen.dk>
Free adult internet connection worldwide via our BBS.
Please visit as much as possible our sponsor pages,
its how we are paid...
Follow the link and enjoy...
http://www.cybercity.hko.net/LA/interbbs/index.htm
------------------------------
Date: 16 May 1997 15:31:26 GMT
From: fpm@u.washington.edu (Frank Miles)
Subject: Re: ls vs. readdir
Message-Id: <5lhuke$s5m@nntp6.u.washington.edu>
>fpm@u.washington.edu (Frank Miles) writes:
>
>> -- When I do a opendir(); readdir(), the returned list does not include
>> the names of subdirectories (this is with Perl 5.003 under Linux[Debian]).
>> Is there any way of getting these from these functions? Must one use
>> ls or some other o.s. function?
For reasons that I cannot explain, it's all working now. Yes, of course
I'm using "#!/usr/bin/perl -w" and 'use strict;". I'd been using the list
return form of readdir() [after all, the blue book examples all used this
form], and most of you used the multiple-call, single-return form. But now
they both work!?^#$&*! The self- and super- directories '.' and '..' had
always been returned, but an added subdirectory './foo' hadn't been
reported. For the time being, I guess I will retain my state of confusion.
Thanks again to all for your help.
-frank
------------------------------
Date: 16 May 1997 19:52:13 GMT
From: evenh@bigblue.pvv.ntnu.no (Even Holen)
Subject: Re: Mystery characters?
Message-Id: <slrn5npend.qei.evenh@bigblue.pvv.ntnu.no>
In article <5li5q2$g9p$1@nntp1.ba.best.com>, mikane@best.com wrote:
>The most frustrating part of programming is when you have a situation
>where what you see is not what you get.
The most frustrating part of answering news is when the problem isn't
described properly... :)
>I have a script that generates a string representing a path to a file.
>The string will not open the directory. When I hard code the exact same
>string, it does work. I can print the string generated by the script and compare
>it with the hard coded one and they look exactly alike.
>
>I have tried removing blanks, tabs etc with $path=~s/\s//;
>Still no luck. Is there a way to view or print all hidden characters?
Try posting pieces of your script with the part that doesn't function,
and give examples of what you want and what's your problem..
Regards,
Even Holen
--
<>< Even Holen, evenh@pvv.ntnu.no, http://www.pvv.ntnu.no/~evenh/ :-)
------------------------------
Date: 16 May 1997 15:34:01 GMT
From: "Dave Hayden" <dhayden@netcomuk.co.uk>
Subject: Password Authorisation
Message-Id: <01bc620e$33db3740$6502a713@fce04438.jubilee.ford.com>
Help, I need a PERL script to check passwords on my site and allow users to
change passwords as required. I am new to CGI/PERL and would appreciate
some hlp on setting this up. My Web Site is due to be uploaded to the Web
Hosting Company in a couple of weeks and this needs to be in place before
hand. However I have no way of testing the scripts as I am using W95 to
create pages and have no server software and pages will be hosted on a UNIX
based system.
------------------------------
Date: Fri, 16 May 1997 12:10:25 -0700
From: Steve Nelson <senelson@negentropy.com>
Subject: Perl 5.003 patches?
Message-Id: <337CB121.4FE3@negentropy.com>
Hello all--
I'm trying to upgrade our Perl from 5.003 Patchlevel 0 to Patchlevel 2,
in order to use sfio. My sysadmin doesn't want us to upgrade all the
way to the Perl 5.004 beta quite yet, and wants the minimal number of
patches applied to use sfio. Unfortunately, I can't find patches 1 and
2 to perl5.003 anywhere, including CPAN. Can anyone tell me where to
find these?
TIA,
=SN
------------------------------
Date: 16 May 1997 15:07:44 GMT
From: mmelick@gpu4.srv.ualberta.ca (M Melick)
Subject: Pipes and buuffering?
Message-Id: <5lht80$7iu$1@pulp.ucs.ualberta.ca>
Hi,
I am having trouble doing a tail on some files when using a pipe.
I can't seem to get the most recent data through, but it is there
if I dump a bunch of data into one of the files that I am tailing
on. (That's why I think that it is being buffered, but I am not
sure where I can turn this off.)
Here's the basics of what I am trying to do.
open (PIPE,"$tail_string |") || die "Could not open the process to tail on the files\n";
#where $tail_string = "tail --follow --quiet --lines 0 file1 file2 ...."
while ( $temp = <PIPE> )
{
print $temp;
}
I have tried a couple of ways to turn of buffering, but neither seemed to work.
The first being:
use FileHandle;
PIPE->autoflush(1);
The second being:
select PIPE; $| = 1; # Turn off the buffering from the pipe process
Any suggestions or ideas on how to fix this would be greatly appreciated.
BTW : OS=Linux, Perl Version = 5.003
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 489
*************************************