[8654] in Perl-Users-Digest
Perl-Users Digest, Issue: 2270 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 7 20:07:31 1998
Date: Tue, 7 Apr 98 17:00:32 -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 Tue, 7 Apr 1998 Volume: 8 Number: 2270
Today's topics:
$value=~ s/"/\*/gi; to translate " to * <INFO@ARKSON.COM>
Re: $value=~ s/"/\*/gi; to translate " to * <matt@whiterabbit.co.uk>
Re: Annoucement (was Re: Calling all Newbies) <sneaker@mediaone.net>
CGI.pm passing variables into param? ahayes@ingenia.com
Clever algorithms for generating robots.txt from list o <ernestm@towery.com>
Re: Database sorting problem (Matthew Cravit)
Re: Database sorting problem <lr@hpl.hp.com>
Explicit file handling: Cannot update file (Perl for OS (Oliver Heidelbach)
Re: File Bug in Perl of Sun-Solaris` (Jonathan Stowe)
fork() and exec() example needed please... (Michael Shavel)
Help! How do you use DBM Hashes in Win32? <ifcl@mssite01.ion.chevron.com>
Help: Sending a command to another command... <khn@engr.uark.edu>
Re: How do I sort without having a space before the rec <rootbeer@teleport.com>
Re: Is it just me? (error/bug? with "my") <rootbeer@teleport.com>
Re: Korn to Perl, Help! (Jonathan Stowe)
Re: Need help with simple for loop <lr@hpl.hp.com>
Re: Need Reg Expr to yield today's cron jobs <gwynne@utkux.utk.edu>
Open Read File of size GT 2 Gig <ken.kohl@mci.com>
Re: Packing? <ben@wallroyds.demon.co.uk>
Re: Packing? (Jonathan Stowe)
Parsing the command line <andrewf@cp.pathfinder.com>
Re: Password of the day <andrewf@cp.pathfinder.com>
Re: Perl and ODBC (Jonathan Stowe)
Perl in Visual Studio <webmaster@mvrs.com>
Re: Perl in Visual Studio (Kevin B Cohen)
Re: Perl in Visual Studio (Warren Jones)
Perl on VMS <reddys2@uofs.edu>
Re: please help with script <andrewf@cp.pathfinder.com>
Re: please help with script (Tad McClellan)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 07 Apr 1998 23:21:07 GMT
From: "Brendan Murphy" <INFO@ARKSON.COM>
Subject: $value=~ s/"/\*/gi; to translate " to *
Message-Id: <DxyW.798$8%2.4170137@news.inreach.com>
Hello!
I am trying to replace " by a * so that it would not mess up a form where I
use the data ..... for some reason I cannot replace it.... I have tried
everything except of course the right thing...
$value=~ s/"/\*/gi; # translate " to *
Please help!
Brendan.
------------------------------
Date: Wed, 08 Apr 1998 00:31:29 +0100
From: Matt Pryor <matt@whiterabbit.co.uk>
To: Brendan Murphy <INFO@ARKSON.COM>
Subject: Re: $value=~ s/"/\*/gi; to translate " to *
Message-Id: <352AB751.90D2AB24@whiterabbit.co.uk>
You're going to kick yourself...
Try escaping the " character with \"
That should do it.. you don't need to worry about the /i argument either
as you're not comparing alphas.
Hope it works!
Matt
> $value=~ s/"/\*/gi; # translate " to *
--
http://www.whiterabbit.co.uk/design
------------------------------
Date: Tue, 07 Apr 1998 23:00:09 GMT
From: Sneaker's Nest <sneaker@mediaone.net>
Subject: Re: Annoucement (was Re: Calling all Newbies)
Message-Id: <352AAE7A.7FF@mediaone.net>
> :Management wouldn't agree to it, afraid
> :of all the 'bad' perl hackers out here
> :in Internet land... They need a clue :-)
> :
> :So, I have abandoned that idea entirely.
>
> It is possible to use one of the public chat sites such asI mentioned
> (ICQ, communityware, etc) so that there is no software involved at
> your site.
>
> However, if you have lost interest in the idea, I understand.
I haven't lost interest... I have thought about it considerably:
Contrary to popular belief :-)
I really have enjoyed utilizing Perl to resolve several issues and was
overly optimistic and enthusiastic in finding way to help out.
But, I am beginning to realize that what I know is really only useful to
me; so...
After considerable thought, I have decided to keep to myself, read this
news group, help when I can, and avoid people at all costs :-)
I did purchase two new magazines today - the latest Perl Journal and the
latest WebTechniques. Both promise to prove very interesting, everyone
here should flock out and get one quick :-)
:-)
Sneex
------------------------------
Date: Tue, 07 Apr 1998 15:50:12 -0600
From: ahayes@ingenia.com
Subject: CGI.pm passing variables into param?
Message-Id: <6ge3in$uim$1@nnrp2.dejanews.com>
Hi. I'm trying to get someone elses old script to make use of CGI.pm instead
of cgi-lib.pl and am running into a problem. From what I can tell, the "param"
method on the $query object does not accept a variable as an argument. Since
I'm quite certain that I'm wrong about that... could someone please tell me
how to get the following statements (my best guess) to retrieve and split
parameters with name=$qn?
$qn = 'query' . $zx; # e.g. "query0" through "query9"
($answer[$zx]->{qdex}, $answer[$zx]->{val}) = split(/:/, $query->param($qn));
Using cgi-lib.pl it worked with $in{$qn} in place of $query->param($qn). The
form uses POST to transmit the data.
Thanks for your time.
Amos Hayes
ahayes@ingenia.com
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Tue, 07 Apr 1998 18:07:57 -0500
From: Ernest Mueller <ernestm@towery.com>
Subject: Clever algorithms for generating robots.txt from list of allowed files?
Message-Id: <352AB1CD.A92EEEA5@towery.com>
OK, here's the deal. I have a list of files I specifically want to allow robots
to index on my Web site. Unfortunately the current robot exclusion principle
only supports Disallow: lines. I only want to allow access to about 100 of my
3000 files.
So, I wrote a quick Perl script that does a find and then takes regexps from a
robots.allow file that generates a robots.txt containing all my site files
except the ones matched by robots.allow.
This works fine, except it makes a bigger robots.txt than it needs to (and by
that I mean 600K) - it doesn't understand that if there are no files to be
included under /foo/bar than it should just say Disallow: /foo/bar and not
recursively list every subdirectory and file in /foo/bar.
So, anyone got any great ideas on how to do this in minimal time and with no
extraneous entries in robots.txt?
Thanks,
Ernest
--
Ernest C. Mueller ernestm@towery.com
Webmaster Phone: (901) 251-7000
Towery Publishing http://www.towery.com
------------------------------
Date: 7 Apr 1998 14:00:52 -0700
From: mcravit@shell3.ba.best.com (Matthew Cravit)
Subject: Re: Database sorting problem
Message-Id: <6ge464$amc$1@shell3.ba.best.com>
In article <alecler-0704981524490001@dialup-639.hip.cam.org>,
Andre L. <alecler@cam.org> wrote:
>In article <352A646B.3D1D2C21@hpl.hp.com>, Larry Rosler <lr@hpl.hp.com> wrote:
>
>I read your post with great interest, but for the life of me I can't see
>what could be wrong with the suggestion I made earlier in that thread.
>Here it is:
[Snip
>So, is there anything wrong with that code, speed-wise or otherwise? Why
The "Benchmark" module is your friend. The problem with your approach, as
compared with Larry's, is that it's about 15 times slower, even for a
fairly small data set. I defined your three line sample data, and created
two subs 'Sort_Andre' and 'Sort_Larry', and then did:
timethese(10000, {
Sort_Andre => sub { Sort_Andre(@stuff); },
Sort_Larry => sub { Sort_Larry(@stuff); },
});
(See the documentation for the Benchmark module for explanation of what this
does). The result I got was:
[ceilidh] mcravit:~ $ perl trial
Benchmark: timing 10000 iterations of Sort_Andre, Sort_Larry...
Sort_Andre: 13 secs (12.95 usr 0.00 sys = 12.95 cpu)
Sort_Larry: 1 secs ( 0.75 usr 0.00 sys = 0.75 cpu)
So, the Schwartzian Transform (named, apparently, for but not by Randall),
is significantly faster, especially when the data set being sorted is large.
/MC
--
Matthew Cravit, N9VWG | Experience is what allows you to
E-mail: mcravit@best.com (home) | recognize a mistake the second
mcravit@net.com (work) | time you make it.
------------------------------
Date: Tue, 07 Apr 1998 14:12:51 -0700
From: Larry Rosler <lr@hpl.hp.com>
To: "Andre L." <alecler@cam.org>
Subject: Re: Database sorting problem
Message-Id: <352A96D3.9DBC6C09@hpl.hp.com>
Andre L. wrote:
>
> In article <352A646B.3D1D2C21@hpl.hp.com>, Larry Rosler <lr@hpl.hp.com> wrote:
>
> > Undoubtedly correct, but would run much slower than necessary on large
> > data sets, because of all the computation occurring repeatedly in the
> > sort sub. The FAQ and other sources [snip] would recommend using something
> > like this:
> >
> > @result = map $_->[0], sort { $a->[1] <=> $b->[1] }
> > map { [ $_, (split /\|/)[3] ] } @rawData;
> >
> > To "sort" that out, read it right-to-left: create -- *once* per datum
> > -- an auxiliary element which is the sort key; sort by that key; then
> > recover the original datum. Note how much less computation occurs in
> > the sort sub (which is invoked approximately N log N times).
> >
> > This idiom should become part of every serious Perl programmer's
> > vocabulary.
>
> ===============
>
> Larry,
>
> I read your post with great interest, but for the life of me I can't see
> what could be wrong with the suggestion I made earlier in that thread.
> Here it is:
>
> #############
> @stuff = (
> '9|04-02-98|today|364604|today|NULL',
> '10|04-01-98|yesterday|364603|yesterday|NULL',
> '11|04-03-98|tomorrow|364605|tomorrow|NULL'
> );
>
> # Put the data in a LoL:
>
> for (0..$#stuff) {
> @fields = split(/\|/,$stuff[$_]);
>
> for $i (0..$#fields) {
> $data[$_][$i] = $fields[$i];
> }
> }
>
> @sorted = sort { $a->[3] <=> $b->[3] } @data;
> ##############
>
> Seems to me that this code extracts the sort field for each datum and
> sorts by this criterium, without the need for a Schwartzian construct, nor
> any splitting. (Of course this assumes that the data has already been
> stored in a LoL (or a LoH), which would usually be the case anyway,
> right?)
>
> One advantage I see is that the whole dataset doesn't get copied in memory
> in the sort, as only an array of references is returned. And the sort loop
> couldn't be simpler, no?
>
> So, is there anything wrong with that code, speed-wise or otherwise? Why
> should I use Schwartz's algorithm instead? I really would like to know,
> because this is the kind of code I use for real life projects, and I might
> as well change my way of doing things if proven wrong or unefficient. I
> consider myself but a learner at this point.
>
> Thank you in advance for any feedback.
>
> A.L.
#!/usr/local/bin/perl -w
use strict;
use diagnostics;
use Benchmark;
timethese (1 << 12, {
L1 => q{
@stuff = (
'9|04-02-98|today|364604|today|NULL',
'10|04-01-98|yesterday|364603|yesterday|NULL',
'11|04-03-98|tomorrow|364605|tomorrow|NULL'
);
# Put the data in a LoL:
for (0..$#stuff) {
@fields = split(/\|/,$stuff[$_]);
for $i (0..$#fields) {
$data[$_][$i] = $fields[$i];
}
}
@sorted = sort { $a->[3] <=> $b->[3] } @data;
},
L2 => q{
@stuff = (
'9|04-02-98|today|364604|today|NULL',
'10|04-01-98|yesterday|364603|yesterday|NULL',
'11|04-03-98|tomorrow|364605|tomorrow|NULL'
);
@sorted = map $_->[0], sort { $a->[1] <=> $b->[1] }
map { [ $_, (split /\|/)[3] ] } @stuff;
},
} );
__END__
Benchmark: timing 4096 iterations of L1, L2...
L1: 5 secs ( 5.05 usr 0.00 sys = 5.05 cpu)
L2: 2 secs ( 2.47 usr 0.00 sys = 2.47 cpu)
HTH,
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 7 Apr 1998 20:59:12 GMT
From: oheiabbd@zedat.fu-berlin.de (Oliver Heidelbach)
Subject: Explicit file handling: Cannot update file (Perl for OS/2)
Message-Id: <CmxVjOhTikQl-pn2-ZeW1qHONnM5l@oheiabbd.dialup.fu-berlin.de>
I always have used command line redirection
to update, i.e. search and replace, files.
However recently I needed the file handling to be
explicit, i.e. done within Perl and no matter what
I tried it wouldn't work.
What I want is to open a data file read/write
and than to update (replace) certain lines.
Here's a short example:
#!perl
$patchlog = "patchstatus.log";
open(LOG1, "+<$patchlog");
while (<LOG1>) {
s/diffs/diff/;
print LOG1; # no effect here!
}
print LOG1 "Print access works well outside the loop.\n";
close LOG1;
Printing to *update* the file does not work inside
the while loop. It does work outside the while loop.
I don't understand.
If I use just 'print' instead of 'print LOG1' the
correct output is written to the screen, but as
stated the output should be written to the file.
Can't I use Perl for that problem at all?
Why does 'print' work as expected, but not
'print LOG1'?
I already contcted Ilya Zakharevich to ask
whether this may be an port-specific problem.
He told me that my code is odd and he wouldn't
expect to work it at all this way, but all I want
to do is to update a file and not to use the
command line therefor.
May be some of you can come up with an answer
to it?
I am using Perl 5 for OS/2 version 5.004_55.
Regards,
Oliver
------------------------------
Date: Tue, 07 Apr 1998 05:46:40 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: File Bug in Perl of Sun-Solaris`
Message-Id: <35297c2f.6006103@news.btinternet.com>
On Tue, 07 Apr 1998 10:22:29 -0500, Ben Schmitz <ben@fastparts.com>
wrote:
>Does anyone know of a file bug for Perl 5.004_004 on Sun Solaris.
>Basically, when i run stat on a file, i get no information from certain
>files. None.
>
Possibly, but possibly mind, the files in question are symbolic
links. Check for this with an -l file test first and then use lstat
on the file instead of stat.
But of course it could be something else entirely different...
/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm
------------------------------
Date: Tue, 07 Apr 1998 18:50:29 -0400
From: mshavel@erols.com (Michael Shavel)
Subject: fork() and exec() example needed please...
Message-Id: <mshavel-0704981850290001@130.9.16.207>
HI
I posted a few days ago about a PID number being one off when I have a
perl script call an sqr statement in the background. The response was that
I
had to fork and exec the process myself. I cannot find an example of this
being done and have had little luck getting it done myself.
If someone has an example of doing this I would appreciate it very much,
or please direct me to some documentation that would have such an example.
As always thanks!
Mike Shavel
Ps. this is the code I am starting with, but all it seems to do is execute the
sqr statment twice without returning the PID into $pid.
$c="sqr trsdmp.sqt test/test -RT -F/export/transfer/trsdmp.lis 03/03/1998";
$pid = fork();
print "PID num id $pid \n";
exec($c);
------------------------------
Date: Tue, 07 Apr 1998 16:00:01 -0700
From: Ian Clark <ifcl@mssite01.ion.chevron.com>
Subject: Help! How do you use DBM Hashes in Win32?
Message-Id: <352AAFF1.2EFC@mssite01.ion.chevron.com>
How do you use DBM Hashes in Win32?
I have coded a reference as follows:
#
# hash
#
dbmopen(%DDA,"ddafile",0644);
$DDA{"ifcl"} = "Ian Clark";
dbmclose(%DDA);
and when I run it, I get:
"Can't locate AnyDBM_File.pm at has.pl line 4."
My reference is chapter 17 of "Learning Perl on Win32 Systems" - what am
I missing here?
Ian Clark.
------------------------------
Date: Tue, 07 Apr 1998 17:51:12 -0500
From: KHAI <khn@engr.uark.edu>
Subject: Help: Sending a command to another command...
Message-Id: <352AADDF.F22424F0@engr.uark.edu>
I'm having a problem sending a command within another command.
Like say, if I were to entered in the following command at the
Unix prompt:
telnet web.engr.uark.edu 80
I would get the following:
Trying 130.184.160.233...
Connected to engr.engr.uark.edu.
Escape character is '^]'.
<-------- It wait for an input from
the user here.
Now, you have to input the following line:
GET /~khn/public_html/index.html HTTP/1.0
Accept: text/plain
The system would return the HTML file "index.html" on the screen.
Now, how do you send the "Get...." part to the telnet command when
using perl's "system" function.
I've been dewelling on this matter for a long time already. If you can
help me out, I'll be very grateful.
Thank you. I've already sent off for the book,"Web Client Programming"
, upon a poster's suggestion.
-Khai
------------------------------
Date: Tue, 7 Apr 1998 14:58:38 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Chocolate <poohba@io.com>
Subject: Re: How do I sort without having a space before the record?
Message-Id: <Pine.GSO.3.96.980407145647.1034N-100000@user2.teleport.com>
On Tue, 7 Apr 1998, Chocolate wrote:
> print FILE "@newlines\n";
> When I run this it sorts but it puts a space in front of every record
> except the first one. How do I stop that?
Fix your print statement. :-)
As I told the students in my Perl class just this morning, when
interpolating an array, Perl puts spaces between elements (by default). If
you want to print them without the spaces, you probably didn't need or
want to interpolate, either. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 7 Apr 1998 16:49:36 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Frank Cortez <cortez@tfn.com>
Subject: Re: Is it just me? (error/bug? with "my")
Message-Id: <Pine.GSO.3.96.980407154835.1034P-100000@user2.teleport.com>
On Tue, 7 Apr 1998, Frank Cortez wrote:
> Any code that uses variables created using "my" will act as if these
> variables are undefined.
my() creates brand-spanking-new variables, so yes, they are undefined
scalars or empty arrays upon creation. Just as with any other variables.
Of course, you may set a my variable at the same time you create it, too.
> I've even tried resetting them myself within subroutines to what they're
> supposed to be, only to discover that my explicit declarations are
> *ignored*.
Naaah. You're just not looking in the right place. For example, are you
perhaps looking for a my() variable outside of its scope?
> #> $Loc and $SessId are set before this point (I checked
> #> at this line before calling the routine!)
>
> ShowLoc($SessId, $Loc);
>
> # (intermediate code omitted)
>
> #> routine definition
> sub ShowLoc {
>
> my ($ID, $URL) = @_;
Okay, $ID is set to the first parameter, $URL is the second.
> my %SessionValues, @matches;
Danger! That makes only one my() variable. Did you forget the parens?
> #> my $ID and $URL are undefined!
Maybe, if the caller didn't pass defined values. But, if you passed
defined values, they will have defined values. I promise! If you can make
a small program which disproves this, you may have found a bug in (your
copy of) perl. But that's so big of a bug, I'd be very surprised.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 07 Apr 1998 05:46:38 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Korn to Perl, Help!
Message-Id: <35296f8e.3874464@news.btinternet.com>
On 7 Apr 1998 15:02:30 GMT, kittu@Hawaii.Edu (Chakravarthy KM
Nalamotu) wrote:
<snip>
>
>The code down here has a << EOF which lets me connect
>to a database session and do a query on a table and
>output the information into $FILES. Is
>there something similar in perl that does this?
>
You want IPC::Open2 which comes with the distribution.
You might do something like this :
#!/usr/bin/perl
use IPC::Open2;
use Symbol;
# get typeglob refs
$QUERY = gensym();
$RESULT = gensym()
$pid = open2($RESULT,$QUERY,"sqlplus userid/passwd");
print $QUERY << "EOF";
select file_name FNAME
from sys.dba_data_files
order by file_name;
EOF
@outlines = <$RESULT>;
# The array @outlines should, all being well,
# contain the lines returned by you query
# for you to do what you want with.
__END_
Alternatively to this you might even be able to find a module that
will interface with your database more or less directly ...
Have fun
/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm
------------------------------
Date: Tue, 07 Apr 1998 13:53:45 -0700
From: Larry Rosler <lr@hpl.hp.com>
To: Patrick E Mcknight <pem@U.Arizona.EDU>
Subject: Re: Need help with simple for loop
Message-Id: <352A9259.F4E1B0B2@hpl.hp.com>
Patrick E Mcknight wrote:
>
> Greetings,
>
> I've tried to get this simple text output program to work but it seems to
> only get through the second iteration and then it stops. Could someone
> out there show me the errors in my code. Thanks in advance.
>
> Here is the code...very simple:
>
> #!/usr/bin/perl
>
> # PERL script to create bigsteps programs for golf data
>
> for ($i = 1, $i < 46, $i++) {
> for ($j = 1, $j < 5, $j++) {
Try semicolons instead of commas.
[Note to Perl language designers: Maybe 'for' == 'foreach'
wasn't such a good idea!]
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: Tue, 7 Apr 1998 19:37:08 -0400
From: "Bob Gwynne" <gwynne@utkux.utk.edu>
Subject: Re: Need Reg Expr to yield today's cron jobs
Message-Id: <6gedbd$80a$1@gaia.ns.utk.edu>
James Vasile wrote in message ...
I just want to print today's cron entries...
>should be easy, but it's not so for me.
>
That's fairly simple. Use system(). For example:
unless (system 'crontab', '-l') {
print "Cool \n";
}
This will print out your crontab file and tell you if the command was
successful. If it was successful, and you want to know the date, etc., use
localtime(). Looking at your crontab file will not tell you what time it
is, etc. However, you can receive an email message telling you what crontab
did.
Hope this helps,
Bob Gwynne
------------------------------
Date: Tue, 07 Apr 1998 22:58:15 GMT
From: Ken Kohl <ken.kohl@mci.com>
Subject: Open Read File of size GT 2 Gig
Message-Id: <352AAF90.D4CBF259@mci.com>
My call to open is failing in attempting to open a file of greater than
2 Gig. Any way around this other than using split?
------------------------------
Date: Tue, 7 Apr 1998 22:14:16 +0100
From: "bjf" <ben@wallroyds.demon.co.uk>
Subject: Re: Packing?
Message-Id: <891983666.17496.0.nnrp-08.c2de5b4a@news.demon.co.uk>
Thank you for your point.
Have a look at my response to Jeffrey (In the same thread)
Thanks again :-)
BJF
Rob Rainthorpe wrote in message ...
>"bjf" <ben@wallroyds.demon.co.uk> writes:
>
>> In order to create a file. (ie ... 132412414.xxx)
>
>I assume you don't care that 132.41.24.14 would lead to the same file name
as
>132.41.241.4 ?
>
>Rob.
>
>--
>Robert Rainthorpe - Central Systems Group, Computing Services
>the University of Greenwich
>16 - 32 Wellington Street, Tel. (+44) (0)181 331 8738
>Woolwich, Fax. (+44) (0)181 331 8385
>London SE18 6PF Email. (remove nospam- from above)
------------------------------
Date: Tue, 07 Apr 1998 05:46:44 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Packing?
Message-Id: <3529ab68.9358560@news.btinternet.com>
On Tue, 7 Apr 1998 16:02:31 +0100, "bjf" <ben@wallroyds.demon.co.uk>
wrote:
>>...but why on Earth would you want to do that?
>
>
>8o)
>
>In order to create a file. (ie ... 132412414.xxx)
>
Oh right in that case you might want:
$newip = sprintf("%03d%03d%03d%03d",$ip =~
m/(\d+)\.(\d+)\.(\d+)\.(\d+)/);
or :
$newip = join "",map sprintf ("%03d",$_), split '\.',$ip;
or any of their increasingly obfuscated brothers and sisters if you
want a unique twelve character filename for each IP number. ;-}
Have fun
/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm
------------------------------
Date: Tue, 7 Apr 1998 18:27:33 -0400
From: "Andrew F. Lee" <andrewf@cp.pathfinder.com>
Subject: Parsing the command line
Message-Id: <Pine.GSO.3.95.980407181730.28832D-100000@cp.pathfinder.com>
Hello:
I keep getting this wrong and I searched the Perl faq. Perhaps I missed
it. But, once and for all, what is a nifty way to parse options
passed to your program? Something about closures comes to mind, but if
someone has an example I'd be saved a reinvention of the wheel.
e.g. foo.pl -h gives:
usage: foo.pl [-aBcdehl] input-file [[-o output-file | command]]
User gives me "foo.pl -el bar.txt -o bar.html" and I go do something
clever.
Thanks in advance.
-------------------------------------------------------------
Andrew F. Lee | |
Software Engineer | parenttime.com |
email: andrewf@pathfinder.com | 1271 Avenue of the Americas |
Phone: (212) 522-2769 | New York, N.Y. 10020 |
-------------------------------------------------------------
When I say, "Ignore the man behind the curtain."
That is because there is no man behind the curtain.
------------------------------
Date: Tue, 7 Apr 1998 19:21:20 -0400
From: "Andrew F. Lee" <andrewf@cp.pathfinder.com>
Subject: Re: Password of the day
Message-Id: <Pine.GSO.3.95.980407183228.28832E-100000@cp.pathfinder.com>
On Tue, 7 Apr 1998, Tom Phoenix wrote:
> On Mon, 6 Apr 1998, Stacy Hunter wrote:
>
> > I would like to have a password protected document where the password
> > automatically changes to meet given criteria each day.
> >
> > Any recommendations?
>
> You should probably use cron, or its counterpart on your system. Hope this
> helps!
>
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
>
A quick and dirty changing password:
#!/usr/local/bin/perl -w
$password = "Foibles";
$len = length $password;
$seed = `date +%d`;
chomp $seed;
srand($seed);
$randval = int (rand()*127);
$mask = pack("c", $randval);
foreach (1..$len) {
$randval = int (rand()*127);
print $randval, "\n";
$mask .= pack("c", $randval);
}
$password &= $mask;
print "$password\n";
Yeah??
-------------------------------------------------------------
Andrew F. Lee | |
Software Engineer | parenttime.com |
email: andrewf@pathfinder.com | 1271 Avenue of the Americas |
Phone: (212) 522-2769 | New York, N.Y. 10020 |
-------------------------------------------------------------
When I say, "Ignore the man behind the curtain."
That is because there is no man behind the curtain.
------------------------------
Date: Tue, 07 Apr 1998 05:46:42 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Perl and ODBC
Message-Id: <35297e15.6491640@news.btinternet.com>
On Tue, 07 Apr 1998 14:15:16 -0700, "DANG-TRUNG K.N."
<dangtrkhng@mail.dotcom.fr> wrote:
>Hello,
>
>I wonder how I could link my web home page with an ODBC database like
>Access ? I heard that I would have to program a Perl module but I have
>no more informations about that ...
>
Whilst it is true that you can use the Win32::ODBC module to access
databases in perl, I would suggest that might be a little premature
if you have no knowledge of perl already. There are other
possibilities afforded by various software manufacturers server
offerings which you might consider.
If you wish to learn perl there are some good books available which
are discussed along with an abundance of other invaluable
documentation at www.perl.com.
Have fun
/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm
------------------------------
Date: Tue, 07 Apr 1998 15:17:36 -0700
From: ADR Webmaster <webmaster@mvrs.com>
Subject: Perl in Visual Studio
Message-Id: <352AA600.CAAF6ED4@mvrs.com>
I'm looking for a plug-in or macro for MS Visual Studio 97 to provide
syntax coloring for my Perl code.
I was recently kidnapped from my home in Linux and taken away to NT
Land. Now I use VC for my C++ programming, but I still want to prototype
in Perl. Staring at monochrome Perl code for hours on end is driving me
quite mad!
-/matt/-
------------------------------
Date: 7 Apr 1998 18:57:51 -0400
From: kcohen@julius.ling.ohio-state.edu (Kevin B Cohen)
Subject: Re: Perl in Visual Studio
Message-Id: <6geb1f$919@julius.ling.ohio-state.edu>
In article <352AA600.CAAF6ED4@mvrs.com>,
ADR Webmaster <webmaster@mvrs.com> wrote:
>I'm looking for a plug-in or macro for MS Visual Studio 97 to provide
>syntax coloring for my Perl code.
if you find one, please let the rest of us know... have you tried
creating perl scripts with the extension .cpp?
kevin
------------------------------
Date: 7 Apr 1998 15:53:54 -0700
From: wjones@tc.fluke.com (Warren Jones)
Subject: Re: Perl in Visual Studio
Message-Id: <6geaq2$ed3$1@purdy.tc.fluke.com>
ADR Webmaster <webmaster@mvrs.com> writes:
> I'm looking for a plug-in or macro for MS Visual Studio 97 to provide
> syntax coloring for my Perl code.
Take a look at Vim, a much-enhanced VI clone.
o Vim has been ported to a wide variety of platforms,
including Windows 95 and NT.
o Vim provides syntax coloring for Perl.
o Vim can be integrated with Visual Studio as your default editor.
For more information, see:
http://www.math.fu-berlin.de/~guckes/vim/ # Vim home page
http://www.pcisys.net/~kscott/vim/ # Vim for Win32
You can get Vim binaries for Windows 95/NT from:
ftp://ftp.ca.us.vim.org/pub/vim/pc/
For use with Visual Studio, you should get gvim51ole.zip. Enjoy!
--------------------------------------------------------------------
Warren Jones | To keep every cog and wheel is the first
Fluke Corporation | precaution of intelligent tinkering.
Everett, Washington, USA | -- Aldo Leopold
------------------------------
Date: Tue, 07 Apr 1998 18:21:48 -0400
From: Swathi Reddy <reddys2@uofs.edu>
Subject: Perl on VMS
Message-Id: <352AA6FB.D8CEE470@uofs.edu>
--------------2EE672078A5375B7F37511E4
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I have a Perl program that uses sendmail in Unix. I want to modify the
program, so that it can be used on VMS. The program reads email
addresses from another file and sends out messages.
I am currently using -
$SENDMAIL = "/usr/sbin/sendmail -t";
I would also like to know about any site that gives information on Perl
on VMS.
Thanks.
--------------2EE672078A5375B7F37511E4
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
I have a Perl program that uses <I>sendmail</I> in Unix. I want to modify
the program, so that it can be used on VMS. The program reads email addresses
from another file and sends out messages.<I></I>
<P>I am currently using -<I></I>
<P><I>$SENDMAIL = "/usr/sbin/sendmail -t";</I><I></I>
<P>I would also like to know about any site that gives information on Perl
on VMS.
<BR>Thanks.
<BR><I> </I></HTML>
--------------2EE672078A5375B7F37511E4--
------------------------------
Date: Tue, 7 Apr 1998 17:48:55 -0400
From: "Andrew F. Lee" <andrewf@cp.pathfinder.com>
Subject: Re: please help with script
Message-Id: <Pine.GSO.3.95.980407173058.28832A-100000@cp.pathfinder.com>
On Tue, 7 Apr 1998, John Q. Public wrote:
> I am new to perl. I could not perform a task using sed & awk so I read
> some perl books over the weekend...
Useful Perl lesson #1
open (FILE, "<filename"); # open filename for reading
while (<FILE>) { # a perl-ism that you will come to love
if($_ =~ /^Story\s+\d+\n/) { # is this the regex?
while ($_ !~ /^$/) { # is this a blank line?
do something fantastic # here's the 'brain' part
next; # get the next line
}
}
>
> The task is this: I downloaded a large (1.4M) text file that has 209
> Grimm's Fairy Tales (for history class) identified only by:
>
> Story 1
>
> Fairy Tale text
> blah blah blah...
>
> Story 209
>
> blah blah blah...
>
> The titles to the stories are indexed on a web page like this:
>
> <LI> <A HREF="001.txt">The Frog King, or Iron Henry</A>
> <LI> <A HREF="002.txt">Our Lady's Child</A>
> <LI> <A HREF="209.txt">The Golden Key</A>
>
> (In case you are interested) http://www.ul.cs.cmu.edu/books/GrimmFairy/
>
> sed stripped off all html tags and I have a text file with 209 titles.
>
> I think what I need to do is figure out how to stuff each line from
> titles file into an array and do a (s/^Story \d/$_/g) for each element.
>
> I'm sure it's a no-brainer but, I'm an EE student--not a programmer. So
> please don't flame me.
<FLAME OFF>
BTW, "Learning Perl" by Randal Schwartz is a must. Buy it and read it and
do every example in it then you should be ready to Perl to your heart's
desire. "Programming Pearl" by Larry Wall, Tom Christiansen and Randal
Schwartz is a jewel, but caveat to the newbie, it is compact and
informative, not necesarily didactic. I recently bought "Effective Perl
Programming" by Joseph Hall and Randal Schwartz. I recommend it highly,
but, it too, assumes some familiarity with Perl. I think it is the
perfect second book to read (after "Learning Perl").
>
> Thanks in advance,
> {ew993#po,cwru,edu}
>
>
-------------------------------------------------------------
Andrew F. Lee | |
Software Engineer | parenttime.com |
email: andrewf@pathfinder.com | 1271 Avenue of the Americas |
Phone: (212) 522-2769 | New York, N.Y. 10020 |
-------------------------------------------------------------
When I say, "Ignore the man behind the curtain."
That is because there is no man behind the curtain.
------------------------------
Date: Tue, 7 Apr 1998 16:20:19 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: please help with script
Message-Id: <ja5eg6.6d7.ln@localhost>
Andrew F. Lee (andrewf@cp.pathfinder.com) wrote:
: On Tue, 7 Apr 1998, John Q. Public wrote:
: > I am new to perl. I could not perform a task using sed & awk so I read
: > some perl books over the weekend...
: Useful Perl lesson #1
: open (FILE, "<filename"); # open filename for reading
Useful Perl lesson #0
Always, yes _always_, check the return value from open() calls:
open (FILE, filename) || die "could not open 'filename' $!";
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
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 2270
**************************************