[9861] in Perl-Users-Digest
Perl-Users Digest, Issue: 3454 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 15 16:07:17 1998
Date: Sat, 15 Aug 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 Sat, 15 Aug 1998 Volume: 8 Number: 3454
Today's topics:
Re: create a user account + shadow pass on REDHAT Unix (Nathan V. Patwardhan)
Re: file upload problem <xuchu@comp.nus.edu.sg>
Re: here's an implementation of diff in perl (Mark-Jason Dominus)
Re: here's an implementation of diff in perl (Ilya Zakharevich)
Re: How to read multiline variable? <danboo@negia.net>
Re: Link to a CGI script in a CGI script (-)
New Module List Posted (Andreas Koenig)
Re: NT redirect to file (Nicholas Carey)
Re: Perl 4 compile on Solaris 2.6 (John D Groenveld)
Re: perl5 large integer conversion bug <tchrist@mox.perl.com>
Re: perl5 large integer conversion bug (Ilya Zakharevich)
Re: Q: How to read all the file name in a directory (Mark-Jason Dominus)
Re: Q: How to read all the file name in a directory <grant.griffin@iowegian.com>
Randal-addnl help <arm@home.net>
Random access <no_brain@mailcity.com>
Re: Random access <merlyn@stonehenge.com>
Search for a character <arm@home.net>
Re: verify password tigger@io.nospaam.com
Re: verify password tigger@io.nospaam.com
Re: Web Applications Programmer <perlguy@inlink.com>
What about $/... was help parsing mail file <maierc@chesco.com>
Re: What about $/... was help parsing mail file (Larry Rosler)
Re: What about $/... was help parsing mail file (Craig Berry)
Re: X-file (?=...), case postponed. (Ronald J Kimball)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Aug 1998 16:10:51 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: create a user account + shadow pass on REDHAT Unix with perl ?? help
Message-Id: <6r4bub$ouu@fridge.shore.net>
cadic (ccadic@cadic.com) wrote:
: I would like to offer to my www visitors the way to create an adduser user
: account from a www html form working with a perl cgi.
This is an inherently dangerous thing to do if you don't know what
you're doing. And it's even worse if you're doing it through the web,
unsecured, with the same stipulation.
But if you must, I believe that there was such a program, or skeletons
of -- in a recent copy of _The Perl Journal_. See the issue with the
"typewriter" on the cover. I think that the code for the web/password
thing is somewhere near the end of the issue.
--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>
------------------------------
Date: Sun, 16 Aug 1998 01:26:13 +0800
From: wings <xuchu@comp.nus.edu.sg>
Subject: Re: file upload problem
Message-Id: <Pine.SOL.3.96.980816012205.18583B-100000@sun450.iscs.nus.edu.sg>
well, here is my code.. true that "cant write xxx" is what i put there,
not the system error. (actually i dont know how to debug cgi.. have to do
this awkwardly). what should be the correct priviledge set on the
directories? i set 'assignment' 777. 'test.dat' is what i want to create.
and dirs b4 assignment r world-readable, not writable.
# header generation snipped
...
unless (open (FP,
">/home/course/cs2104/admin/assignment/test.dat")) {
&fail("cant write xxx");
exit;
}
$file = param('file');
while (<$file>) {
print FP $_;
}
close $file;
close FP;
exit;
sub fail {
#generate a html page of wrong messages passing in
}
thx for enlightenment.
wings
------
World is a book, those dont travel read only one page.
Email: xwings@usa.net, xuchu@iscs.nus.edu.sg
ICQ UIN: 1440319
http://gump.iscs.nus.edu.sg
------------------------------
Date: 15 Aug 1998 17:18:41 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: here's an implementation of diff in perl
Message-Id: <6r4fth$k49$1@picasso.op.net>
In article <6r3acj$m7v@tako.wwa.com>,
Tushar Samant <scribble@pobox.com> wrote:
>Is the running time for "common subsequence" O(mn)?
Mine is. There are slightly faster algorithms. All this assumes that
the time to compare two lines is constant, which is a reasonable
assumption ifg you're dealing with reasonable lines.
>Then one way to implement a "quality" parameter would be to consider
>k lines as a "line". Cuts the time by k**2,
Could be. Of course, you've also increased the time to compare two
`lines' by a factor of k.
I suppose you're planning to start out with k large and then make it
smaller to re-examine the `lines' that are found to be different.
That's an interesting idea, and I'd like to see a careful analysis.
But I think that unless there are very long stretches of unchanged
text, you'll see it get a lot slower, since you're making multiple
passes over the text. If you divide the text into two `lines', and
then divide each changed line into two sub-lines, etc., you've just
made O(m+n)/log(2) passes over the text. In the early passes, the LCS
part of the algorithm is very fast, but the tradeoff is that the `compare a
line' part has gotten rather slow, because each `line' contains half
the entire file.
>In the extreme case -- suppose you change exactly one line in a
>file, and start off with clusters half the size of the file, and
>dig in repeatedly, what you have got is a binary search of some
>sort. Unless I am ignoring a huge bloat somewhere else...
With binary seach, you can narrow the scope of the search by half
every time. But on this problem, after the first pass, you might find
that each half of file A was different from either half of file B, and
that on the second pass you'll be comparing every part of every file
with every part of every other.
But don't let me discourage you; I'd be interested to see what comes
of it.
--
mjd@pobox.com Mark-Jason Dominus
mjd@plover.com Plover Systems, Philadelphia, PA
------------------------------
Date: 15 Aug 1998 19:01:48 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: here's an implementation of diff in perl
Message-Id: <6r4lus$2as$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Mark-Jason Dominus
<mjd@plover.com>],
who wrote in article <6r4fth$k49$1@picasso.op.net>:
> >Then one way to implement a "quality" parameter would be to consider
> >k lines as a "line". Cuts the time by k**2,
>
> Could be. Of course, you've also increased the time to compare two
> `lines' by a factor of k.
Sure not. Time to compare strings depends logarithmically on the
length (if strings are randomly distributed, obviously this should be
modified if there are common prefixes).
But this is irrelevant, since the algorithm would not work. Consider
k=2, and two files which differ by deletion of the first row.
Ilya
------------------------------
Date: Sat, 15 Aug 1998 14:47:59 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: How to read multiline variable?
Message-Id: <35D5D7DF.3933F582@negia.net>
Ken Williams wrote:
>
> This is an easy questions for someone:
>
> #!/usr/bin/perl
> $Output = `/bin/ls -l'`;
>
> while (<$Output>)
> {
> (Do something with single line)
> print $Output;
> }
>
> How would I accomplish the above? I can't use the while the way it is there,
> because $Output isn't a file handle, its a variable. I simply want to read
> the output of /bin/ls($Ouput) one line at a time so I can do something with it
> first.
>
simply put your backticks into a list context and you will magically
have the lines separated:
@output = `/bin/ls -l'`;
for (@output) {
print;
}
or:
for (`/bin/ls -l'`) {
print;
}
depending upon your needs.
cheers,
--
Dan Boorstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: Sat, 15 Aug 1998 16:30:58 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Link to a CGI script in a CGI script
Message-Id: <35d5b72e.21231725@news2.cais.com>
Knarf <knarf@dvd-dream.dyn.ml.org> Said this:
>Hi, this is my first time posting here, i'm french and spent a lot of
>time reading this newsgroup.
>
>I'm trying to write a script that produces links to different parts of a
>
>database in an HTML document. CGI.pm allows me to get params from a
>search form i've already made. Thus, i can read complex parameter values
>
>including spaces, without "unwebify" my form results.
>
>But how can i make a script react to an "unwebified" parameter ???
>
>example:
>
>I can read the output a a texfield called "thing_value" by doing this:
>
>my $thing = param("thing_value");
>chomp ($thing);
>
>So if i typed 'foo foo foo' into my textfield, now $thing value is "foo
>foo foo" (i hope so :-))
>But now if i want to link to another script that can react to "foo foo
>foo":
>
>print "<a
>href=$my_url/cgi-bin/another.cgi?react_param=$my_foo_foo>$thing</a>\n";
>
>How can i set up $my_foo_foo? Is there any function (already included)
>that could take a param from an HTML form without "unwebifying" it. This
>
>could allow me to store it before "unwebification" and use it later in
>another.cgi.
>
>Any help, FAQ, url swould be great !!
>Sorry if the question is lame. :-)
>
I know that some cgi library/modules have a function for "encoding" as
well as "unencoding" strings. cgi-lib.pl I believe does this. I
don't think, but I'm not sure, that CGI.pm has this sort of
functionality though.
Basically, a quick but not very reliable way is to just use a regexp
to convert spaces to +'s.
$foo =~ s/\s/+/g;
Of course, there are other characters you may need to deal with as
well, like &, and % for example. But this can work absent any other
solution.
------------------------------
Date: 15 Aug 1998 19:53:57 GMT
From: andreas.koenig@franz.ww.tu-berlin.de (Andreas Koenig)
Subject: New Module List Posted
Message-Id: <6r4p0l$5tk$1@mamenchi.zrz.TU-Berlin.DE>
Keywords: FAQ, Perl, Module, Software, Reuse, Development, Free
The Perl 5 Module List, v2.49
=============================
Today I posted a new module list to the newsgroups
comp.lang.perl.modules, comp.answers, and news.answers. The HTML
version of the list has been uploaded to CPAN as well:
http://www.perl.com/CPAN/modules/00modlist.long.html
As usual, comments, corrections and suggestions are highly
appreciated. Not only to the new entries below but to the whole module
list. Please mail them to modules@perl.org.
Due to extreme tuit shortage I have *not* been able to take all mails
into account we received since the last posting of the module list in
June. Please accept my apologies for that. I have registered new users
up to the 499th CPAN developer today. That's a cuuute number just in
time for the conference and a gret pleasure for me to announce here.
As I'll be on vacation after the conference, I'd like to ask all
developers who have pending requests for inclusion into the module
list to mail them again in September so I do not have to wade through
lots of old mail. Thank you.
Recent Changes in the modules database (! for changes, "+" for new entries)
---------------------------------------------------------------------------
2) Perl Core Modules, Perl Language Extensions and Documentation Tools
----------------------------------------------------------------------
B::
::Graph bdpr Perl Compiler backend to diagram OP trees SMCCAM !
Module::
::Reload Rdpf Reloads files in %INC based on timestamps JPRIT +
Perl adcO Create Perl interpreters from within Perl GSAR +
constant Supf Define compile-time constants P5P !
3) Development Support
----------------------
Devel::
::Leak Rdcf Find perl objects that are not reclaimed NI-S +
VCS::
::PVCS i PVCS Version Manager (intersolv.com) BMIDD +
4) Operating System Interfaces, Hardware Drivers
------------------------------------------------
Async::
::Group adpO Deal with simultaneous asynchronous calls DDUMONT +
::Process i class to run sub-processes DDUMONT +
Proc::
::Background bdpO OS independent background process objects BZAJAC +
::ProcessTable adcO Unix process table information DURIST +
Unix::
::UserAdmin Rdpf Interface to Unix Account Information JZAWODNY +
5) Networking, Device Control (modems) and InterProcess Communication
---------------------------------------------------------------------
CORBA::
::IDLtree adpf IDL to symbol tree translator OMKELLOGG +
Net::
::Dict cdpO Client of Dictionary Server Protocol (DICT) ABIGAIL !
SNMP::
::Monitor adpO Accounting and graphical display JWIED +
6) Data Types and Data Type Utilities (see also Database Interfaces)
--------------------------------------------------------------------
Algorithms::Numerical::
::Sample RDph Knuth's sample algorithm ABIGAIL !
::Shuffle Rdph Knuth's shuffle algorithm ABIGAIL !
Data::
::Locations RdpO Handles nested insertion points in your data STBEY !
Decision::
::Markov bdpO Build/evaluate Markov models for decisions ALANSZ !
Math::
::Fourier i Fast Fourier Transforms AQUMSIEH +
::Integral i Integration of data AQUMSIEH +
::MatrixBool RdcO Matrix of booleans (Boolean Algebra) STBEY +
Statistics::
::MaxEntropy Rdpf Maximum Entropy Modeling TERDOEST +
::OLS bdpO ordinary least squares (curve fitting) SMORTON +
Tie::
::DB_Lock rdpO Tie DB_File with automatic locking KWILLIAMS !
::TextDir rdpO ties a hash to a directory of textfiles KWILLIAMS !
7) Database Interfaces (see also Data Types)
--------------------------------------------
DBD::
::ODBC amcO ODBC Driver for DBI DBIML +
Db::
::dmObject cdpO Object-based interface to Documentum EDMS JGARRISON +
9) Interfaces to or Emulations of Other Programming Languages
-------------------------------------------------------------
Clips adpO Interface to the Expert System Clips MSULLIVAN +
ShellScript::
::Env adpO Simple sh and csh script generator SVENH +
10) File Names, File Systems and File Locking (see also File Handles)
---------------------------------------------------------------------
File::
::BSDGlob bdcf Secure, csh-compatible filename globbing GBACON +
::Df adpf Free disk space utilities (h2ph required) FTASSIN +
Filesys::
::Df Rdpr Disk free based on Filesys::Statvfs IGUTHRIE !
::DiskFree adpO OS independant parser of the df command ABARCLAY +
::Statvfs Rdcf Interface to the statvfs() system call IGUTHRIE +
11) String Processing, Language Text Processing, Parsing and Searching
----------------------------------------------------------------------
ERG Rdpf An extensible report generator framework PHOENIXL +
Parse::
::Yapp adpO Generate Perl OO parsers from LALR1 grammars FDESAR +
SQL::
::Builder adpO OO interface for creating SQL statements ZENIN +
Text::
::FillIn rdpo Fill-in text templates KWILLIAMS +
::Graphics RdpO Graphics rendering toolkit with text output SFARRELL !
::Vpp RdpO Versatile text pre-processor DDUMONT !
13) Internationalization and Locale
-----------------------------------
I18N::
::Charset Rdpf Character set names and aliases MTHURN +
14) Authentication, Security and Encryption (see also Networking)
-----------------------------------------------------------------
RADIUS::
::Dictionary bdpO Object interface to RADIUS dictionaries CHRMASTO !
::Packet bdpO Object interface to RADIUS (rfc2138) packets CHRMASTO !
::UserFile bdpO Manipulate a RADIUS users file OEVANS +
15) World Wide Web, HTML, HTTP, CGI, MIME etc (see Text Processing)
-------------------------------------------------------------------
HTML::
::EP adpO Modular, extensible Perl embedding JWIED +
::SimpleParse bdpO Bare-bones HTML parser KWILLIAMS +
16) Server and Daemon Utilities
-------------------------------
NetServer::
::Generic adpO generic OOP class for internet servers CHSTROSS +
21) File Handle, Directory Handle and Input/Output Stream Utilities
-------------------------------------------------------------------
Expect RdpO Close relative of Don Libes' Expect in perl AUSCHUTZ +
23) Miscellaneous Modules
-------------------------
Geo::
::METAR Rdpf Process Aviation Weather (METAR) Data JZAWODNY +
::WeatherNOAA Rdpf Current/forecast weather from NOAA MSOLOMON +
MIDI cdpO Object interface to MIDI files SBURKE +
Penguin RdpO Remote Perl in Secure Environment AMERZKY +
Silly::
::StringMaths adpf Do maths with letters and strings SKINGTON +
24) Interface Modules to Commercial Software
--------------------------------------------
AltaVista::
::SearchSDK cdcf Perl Wrapper for AltaVista SDK functionality JTURNER +
Recent Changes in the users database (both new entries and updates)
-------------------------------------------------------------------
AEPAGE Andrew E Page <aep@world.std.com>
ANDREWF Andrew Ford <andrew@icarus.demon.co.uk>
BHOLZMAN Benjamin Holzman <bholzman@bender.com>
CHOUPT Chuck Houpt <choupt@world.std.com>
CHSTROSS Charlie Stross <charlie@antipope.org>
CHTHORMAN Chris Thorman <chris@thorman.com>
GBAUER Georg Bauer <gb@hugo.westfalen.de>
GTHYNI Gvran Thyni <goran@bildbasen.se>
JBODNAR Jason Bodnar <jbodnar@tivoli.com>
PMKANE Patrick Michael Kane <modus-cpan@pr.es.to>
RBERJON Robin Berjon <robin@idl-net.com>
SHAWNPW Shawn P. Wallace <shawn@as220.org>
SRIEHM Stephen Riehm <Stephen.Riehm@pc-plus.de>
TIMPOTTER Tim Potter <tpot@acsys.anu.edu.au>
--
andreas koenig
------------------------------
Date: Sat, 15 Aug 1998 19:46:04 GMT
From: ncarey@harlequin.com (Nicholas Carey)
Subject: Re: NT redirect to file
Message-Id: <35d5e483.74184752@newshost.harlequin.com>
On Fri, 14 Aug 1998 07:58:17 GMT, jkirving@mosquitonet.com (Ken
Irving) wrote:
> On Thu, 13 Aug 1998 19:28:50 GMT, ncarey@harlequin.com (Nicholas
> Carey) wrote:
[ELIDED]
> >Now try the following and it should give you *exactly* what you want:
> >
> > processor.pl detail.txt > summary.txt
> >
> I've tried this in the past, got simple redirection to work, but then
> it didn't work in a pipe. I'd try again if the following actually
> works:
>
> type detail.txt | processor.pl > summary.txt
You may have to use parentheses to get the grouping your want
(operator precedence, you know). You may have to do this as on of:
(type detail.txt | processor.pl) >summary.txt
type detail.txt | (processor.pl >summary.txt)
or even more simply
processor.pl <detail.txt >summary.txt
Cheers,
N.
--
------------------------------
Date: 15 Aug 1998 14:18:20 -0400
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: Perl 4 compile on Solaris 2.6
Message-Id: <6r4jdc$e07$1@tholian.cse.psu.edu>
What version of Oracle are you running under Solaris 2.6 that will allow
you to link with Kevin Stock's oraperl? Are you aware that Y2000 patches
exist for Solaris 2.3-2.5.1? Have you confirmed that the Oracle you are
running is supported under 2.6 or any other Solaris version?
John
groenveld@acm.org
------------------------------
Date: 15 Aug 1998 16:38:36 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: perl5 large integer conversion bug
Message-Id: <6r4dic$e6a$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Jaakko Hyvdtti <jaakko@hyvatti.iki.fi> writes:
:Just found out this:
So, like, don't *do* that. :-)
I sure wish folks would stop expecting Perl's numbers to stop behaving
like the hardware's numbers. :-( Don't be surprised if strange things
happen on integers that have the high bit set when represented as 32-bit
signed integers, including very large numbers or any negative numbers.
In particular, bitwise operations on such numbers are highly suspect.
So too is bitwise operations on things that might never have been
numerically evaluated.
--tom
--
"I discount everything Djikstra has to say because he doesn't actually
run his programs" --Rob Pike, On Djikstra's belief that bugs in your
program are a moral failure to prove your program mathematically correct.
------------------------------
Date: 15 Aug 1998 19:12:05 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: perl5 large integer conversion bug
Message-Id: <6r4mi5$3hv$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <6r4dic$e6a$1@csnews.cs.colorado.edu>:
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
> Jaakko Hyvdtti <jaakko@hyvatti.iki.fi> writes:
> :Just found out this:
>
> So, like, don't *do* that. :-)
>
> I sure wish folks would stop expecting Perl's numbers to stop behaving
> like the hardware's numbers. :-(
Oh, stop this, Tom! People expect that Perl numbers behave as, well,
numbers. We can laugh at them when they expect number-like behaviour
from floating point quantities, but I see no laughing point when Perl
misbehaves with integers wich may be exactly represented in Perl
internal formats.
When Perl exposes the internal mess of integer-vs-float-stored-value,
it is a bug in Perl. Somehow I'm more forgiving about
number-against-string-stored-value, do not know why.
Hmm, probably here is the difference: the above bug is *very* easy to
fix (with a *significant* performance penalty): always convert to
double, cache the integer value only if it is equal to double value.
Ilya
------------------------------
Date: 15 Aug 1998 16:47:34 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Q: How to read all the file name in a directory
Message-Id: <6r4e36$j9d$1@picasso.op.net>
In article <6r3s5o$168$2@csnews.cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
>standing right outside the soup question.
Joke or accident?
I was delighted.
--
mjd@pobox.com Mark-Jason Dominus
mjd@plover.com Plover Systems, Philadelphia, PA
------------------------------
Date: Sat, 15 Aug 1998 14:55:53 +0100
From: Grant Griffin <grant.griffin@iowegian.com>
Subject: Re: Q: How to read all the file name in a directory
Message-Id: <35D59369.3AB3@iowegian.com>
Tom Christiansen wrote:
> [courtesy cc of this posting and politeness denied due to poster's
> obnoxious address munging policy, which is illegal and must be
> chastised]
OK, now that I've been trashed, I just learned something I didn't know.
(Did you know everything when _you_ were first hatched?)
> We'll put you on idiot-answering service for a few years and we'll
> see how sweet you remain.
>
Last I heard, idiot-answering service was a voluntary job. If the pay
is no good and the job is no good, why not quit? (You _can't_ be in it
for the health benefits!)
I guess I'm still not wise enough to understand how hurting people...er,
excuse me...hurting "idiots" is ever helpful. It might be OK to squash
a bug, but remember that behind every "idiot" there is a "person" who
has feelings. (I bet you've even been there yourself.)
The following quote suggests a more constructive approach to your goal,
which will cause you far less trouble:
Silence is the most perfect expression of scorn.
-- George Bernard Shaw
I submit to you that those who receive this form of scorn rather than
_your_ form are even _less_ likely to continue to ask stupid questions:
after all, some idoits might _enjoy_ the scorn . Plus, this approach
has the advantage of "saving disk space on countless servers around the
world". Sadly, though, it does not have the side benefit of increasing
one person's ego at the expense of another.
I hereby pledge to use Shaw's approach to your postings in the future.
-Grant
--
------------------------------
Date: Sat, 15 Aug 1998 19:46:39 GMT
From: Alan Melton <arm@home.net>
Subject: Randal-addnl help
Message-Id: <35D5E479.5565BE56@home.net>
You had written a short perl program to convert
individual ascii files arranged vertically into
a single database, comma delimited.
i.e. original file:
new
Villanova Alumnus
NY
November
1997
@
12M
1
0.99
0.99
12M. The "Window Decal", Category: GIFTS
*
0.99
0.00
6.00
0.0
0.00
6.99
your program:
#!/usr/local/bin/perl
# Age and erase stale audit files.
open OUTPUT, ">>source.dat" or die "cannot append to output: $!";
chdir "/home/web/ushop/public_html/audit" or die "Cannot chdir: $!";
for $filename (<*>) { # get all filenames in current directory
open IN, $filename or die "Cannot read $filename: $!";
@a = <IN>; # read all lines of this file
chomp (@vals=@a[1,2,3,4,6,6,7,8]);
print OUTPUT join (",",@vals), "\n"; # print lines 1,3,7 etc (offset
by one)
chomp (@vals=@a[1,2,3,4,11,11,12,13]);
print OUTPUT join (",",@vals), "\n"; # print lines 1,3,7 etc (offset
by one)
chomp (@vals=@a[1,2,3,4,16,16,17,18]);
print OUTPUT join (",",@vals), "\n"; # print lines 1,3,7 etc (offset
by one)
chomp (@vals=@a[1,2,3,4,21,21,22,23]);
print OUTPUT join (",",@vals), "\n"; # print lines 1,3,7 etc (offset
by one)
chomp (@vals=@a[1,2,3,4,26,26,27,28]);
print OUTPUT join (",",@vals), "\n"; # print lines 1,3,7 etc (offset
by one)
chomp (@vals=@a[1,2,3,4,31,31,32,33]);
print OUTPUT join (",",@vals), "\n"; # print lines 1,3,7 etc (offset
by one)
close IN;
unlink $filename or die "Cannot delete $filename: $!";
}
result:
Villanova Alumnus,NY,November,1997,12M,12M,1,0.99
Villanova Alumnus,NY,November,1997,*,*,0.99,0.00
Villanova Alumnus,NY,November,1997,0.00,0.00,6.99
Villanova Alumnus,NY,November,1997,,,,
Villanova Alumnus,NY,November,1997,,,,
Villanova Alumnus,NY,November,1997,,,,
New problem: in the original single file which could be many lines long:
there is always an @ and a *
new
Student
OH
August
1998
@
1002
1
28.25
28.25
Accounting:Conc.+Appl.-Std.Gde.1-14 5th 96 New
1004
1
84.45
84.45
Accounting:Concepts & Application 1st New
*
112.70
0.00
12.50
5.75
6.48
131.68
I would like to do the same as before but only pull out the data
after the @ sign and put that into one file
and pull out the data after the * and put that into a different file.
I appreciated your direct help before and made a lovely
contribution to your legal fund. Could we try for this as well.
Thanks,
Alan Melton, MD
------------------------------
Date: Sat, 15 Aug 1998 19:07:56 +0200
From: "No Brain" <no_brain@mailcity.com>
Subject: Random access
Message-Id: <6r4f5l$n4v$1@dalen.get2net.dk>
I want a short example to make, write and read files with random access.
:-)) No Brain
------------------------------
Date: Sat, 15 Aug 1998 19:26:36 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Random access
Message-Id: <8ciuju9hcw.fsf@gadget.cscaper.com>
>>>>> "No" == No Brain <no_brain@mailcity.com> writes:
No> I want a short example to make, write and read files with random access.
No> :-)) No Brain
OK, useful challenge. Here goes:
open F, "+>there_can_be_only_one" or die;
print F "1";
seek F, 0, 0;
$one = <F>;
print $one;
Any shorter and it would have fit on one line. :)
Tinker with that for a while. All parts are described in "man
perlfunc" and friends.
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Sat, 15 Aug 1998 16:06:54 GMT
From: Alan Melton <arm@home.net>
Subject: Search for a character
Message-Id: <35D5B0F7.DB44B1AA@home.net>
I have written a short perl program to convert
individual ascii files arranged vertically into
a single database, comma delimited,then delete the original file.
i.e. original file:
new
NY
November
1997
*
0.99
0.00
6.00
0.0
0.00
6.99
the program:
#!/usr/local/bin/perl
# Age and erase stale audit files.
open OUTPUT, ">>source.dat" or die "cannot append to output: $!";
chdir "/home/web/ushop/public_html/audit" or die "Cannot chdir: $!";
for $filename (<*>) { # get all filenames in current directory
open IN, $filename or die "Cannot read $filename: $!";
@a = <IN>; # read all lines of this file
chomp (@vals=@a[1,2,3,4,5,6,7,8,9,10]);
print OUTPUT join (",",@vals), "\n"; # print lines 1,3,7 etc (offset
by one)
close IN;
unlink $filename or die "Cannot delete $filename: $!";
}
result:
NY,November,1997,*,0.99,0.00,6.00,0.0,0.00,6.99
New problem: in the original single file, there is always a *
new
OH
August
1998
* <--------------------
112.70
0.00
12.50
5.75
6.48
131.68
I would like to do the same as before but only pull out the data
after the * sign and put that into one file.
Any suggestions on how to search for the * and then
read ONLY the lines after them, and export them to a file
as in the original program?
Thanks,
Alan Melton
------------------------------
Date: 15 Aug 1998 16:22:46 GMT
From: tigger@io.nospaam.com
Subject: Re: verify password
Message-Id: <6r4ckm$hmh$1@hiram.io.com>
Tom Phoenix <rootbeer@teleport.com> spewed forth with:
> On Sat, 15 Aug 1998, Craig Nuttall wrote:
>> My problem is that I can't seem to get the script to run as root,
> On some systems, the kernel doesn't allow set-id scripts. In that case,
> Perl should (almost certainly) be compiled to make that possible. Hope
> this helps!
Actually, the kernel *has* to allow setuid scripts to work, or your /bin/passwd
program would never work. However, it is possible to mount a filesystem so that
no executable in the filesystem will be able to run as setuid, even if the proper
chmod was done. Do a mount command with no options, and the system should report
under which each filesystem was mounted. If you see a 'nosuid', then that's your
problem.
Good luck,
Paul Archer
------------------------------
Date: 15 Aug 1998 16:32:48 GMT
From: tigger@io.nospaam.com
Subject: Re: verify password
Message-Id: <6r4d7g$hmh$2@hiram.io.com>
> Actually, the kernel *has* to allow setuid scripts to work, or your /bin/passwd
> program would never work. However, it is possible to mount a filesystem so that
> no executable in the filesystem will be able to run as setuid, even if the proper
> chmod was done. Do a mount command with no options, and the system should report
> under which each filesystem was mounted. If you see a 'nosuid', then that's your
> problem.
> Good luck,
I should clarify this: the nosuid is what you'll see on the original poster's Linux
system. Other systems' mount command behave differently. Solaris, for example, won't
show you anything if the filesystem disalows setuid programs. Read the man page, YMMV,
etc.
Paul Archer
------------------------------
Date: Sat, 15 Aug 1998 13:33:41 -0500
From: Brent Michalski <perlguy@inlink.com>
To: ebs@ricochet.net
Subject: Re: Web Applications Programmer
Message-Id: <35D5D485.6582217B@inlink.com>
Maybe you should try posting to the:
comp.i.am.a.dumb.ass.and.post.to.unrelated.groups
newsgroup. I am sure that there area plenty of people perfect to fill
the job you are looking for...
HTH,
Brent
Courtesy Copy E-mailed to the poster :-)
--
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: Sat, 15 Aug 1998 12:12:05 -0400
From: Charles Maier <maierc@chesco.com>
Subject: What about $/... was help parsing mail file
Message-Id: <35D5B355.419D0194@chesco.com>
Abigail wrote:
>
> Mark-Jason Dominus (mjd@plover.com) wrote on MDCCCV September MCMXCIII in
> <URL: news:6qnv6r$uaa$1@netnews.upenn.edu>:
> ++
> ++ { local $ = "";
>
> That should be
>
> local $/ = "";
>
> ++ $header = <INPUT>; # Read entire header
> ++ }
>
I tried this very same thing the other day to get the entire contents of
a file into a single variable. Setting the $/ = "" DID NOT get the
entire file. <SOMETHING>... which I did not pursue.. triggered the end
of line sencing in the middle of the file. Since I only wanted to insure
that all the data got in.. I filled the $/ with "known garbage" and it
worked fine.
Reading this responce has me revisiting this piece of trivia. What can
"match" a record separator of "" ???
--
Chuck Maier
CDM Consulting Services
http://www.cdmcon.com
------------------------------
Date: Sat, 15 Aug 1998 10:18:58 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: What about $/... was help parsing mail file
Message-Id: <MPG.103f62e2fc3861c19897cc@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <35D5B355.419D0194@chesco.com> on Sat, 15 Aug 1998 12:12:05 -
0400, Charles Maier <maierc@chesco.com> says...
...
> Reading this responce has me revisiting this piece of trivia. What can
> "match" a record separator of "" ???
The behavior of $/ is described fully in perlvar. After reading it,
please let the newsgroup know if there is something that requires further
explanation.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 15 Aug 1998 19:23:14 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: What about $/... was help parsing mail file
Message-Id: <6r4n72$87j$1@marina.cinenet.net>
Charles Maier (maierc@chesco.com) wrote:
[wrt using $/=undef to slurp entire files...]
: I tried this very same thing the other day to get the entire contents of
: a file into a single variable. Setting the $/ = "" DID NOT get the
: entire file.
And why did you expect it to? Is "" the same thing as undef? Nope. And
in 'perldoc perlvar' we read that *only* setting $/ to undef has the
special file-slurping magic associated with it.
As came up on a thread regarding _Teach Yourself Perl 5 in 21 Days_,
people really _really_ need to learn the deep differences between undef,
0, and ''. The fact that they often quietly interconvert is no excuse to
ignore those differences, for if you do so, they will surely bite your
ass.
: <SOMETHING>
Please don't use valid Perl syntax (and style) for emphasis. I spent 30
seconds trying to read that as a read-from-filehandle-SOMETHING before the
light dawned.
: ... which I did not pursue..
...other than bothering us about it, rather than reading 'perldoc
perlvar'...
: triggered the end of line sencing in the middle of the file.
>From 'perldoc perlvar', the section on $/, opening sentences:
The input record separator, newline by default.
Works like awk's RS variable, including treating
empty lines as delimiters if set to the null string.
As you can see, $/='' is magic too, but a different sort of magic than
$/=undef. Your read halted at the first empty line.
: Since I only wanted to insure
: that all the data got in.. I filled the $/ with "known garbage" and it
: worked fine.
If you want to use scary hacks like that rather than reading the docs,
that's between you, your code, and (if any) your employer/clients. But it
sure doesn't make the code any easier to maintain, or sturdier in the face
of "known garbage" suddenly showing up in some later version of the
file(s).
: Reading this responce has me revisiting this piece of trivia. What can
: "match" a record separator of "" ???
Honestly: Why did you choose to ask us, rather than perlvar?
---------------------------------------------------------------------
| 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: Sat, 15 Aug 1998 11:01:56 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: X-file (?=...), case postponed.
Message-Id: <1ddsuhb.1rjd9k01cal2lwN@bay1-121.quincy.ziplink.net>
Patrick Timmins <ptimmins@netserv.unmc.edu> wrote:
> In closing, regexes obey mathematical rules of parenthetical precedence.
> Regexes are not evaluated from the inside out (I never said they were).
> Regexes are evaluated from left to right.
>
> (Hey Ronald, you got 2 out of 3 right, that's not bad! And the way they
> accomplish the first is through backtracking ;)
I must admit that I had misunderstood what you meant by saying that
regexes obey mathematical rules of parenthetical precedence. Actually,
I was confused about exactly how the mathematical rules of parenthetical
precedence work.
I'm glad that I was able to get 2 out of 3 right, and I concede the 3rd
to you.
I apologize for being so adamant in arguing my point. Particularly
since I was wrong. :-)
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
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 3454
**************************************