[9529] in Perl-Users-Digest
Perl-Users Digest, Issue: 3123 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 10 19:07:49 1998
Date: Fri, 10 Jul 98 16:00:22 -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, 10 Jul 1998 Volume: 8 Number: 3123
Today's topics:
Re: Bug? shift( split(' ',$_)); won't compile. <"postmaster"@[127.0.0.1]>
Re: Bug? shift( split(' ',$_)); won't compile. <tchrist@mox.perl.com>
Can I do it with ioctl() with Perl ? <philippe.vivarelli@rss.rockwell.com>
Re: Chmod (cgi-unix) (Craig Berry)
Re: Choosing DBMS: friendly to Linux, Apache, Perl, Jav <jgitomer@ictgroup.com>
File comparison and update <nospam@xx.com>
Re: Get IP Address for Server Name <"postmaster"@[127.0.0.1]>
Re: Help, OLE is giving me a hard time. (Jan Dubois)
Re: How can you encrypt a CGI script on a server so it (-)
Re: I am an "antispam spammer"? (Al Iverson)
Looking for the NET:telnet nowen@acm.org
Re: MacPerl: Reading rsrc fork (Paul J. Schinder)
More Serial Port Problems scott@jtsmith.com
Openin files <ggarces@arrakis.es>
Re: simple file grepping/searching question (Tad McClellan)
Site creation scripts? win95mag@my-dejanews.com
Re: Taking info from tags (not ness. HTML) (Tad McClellan)
Trinary operator vs =~ : sometimes it doesn't pay to be (Peter Scott)
Re: Weirdness in trying to extract year from localtime (Craig Berry)
Re: Weirdness in trying to extract year from localtime (Craig Berry)
Re: Weirdness in trying to extract year from localtime (Albert W. Dorrington)
Re: Weirdness in trying to extract year from localtime (Craig Berry)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 10 Jul 1998 15:50:51 -0500
From: postmaster <"postmaster"@[127.0.0.1]>
Subject: Re: Bug? shift( split(' ',$_)); won't compile.
Message-Id: <6o5ute$sgn$1@farstar.frb.gov>
Okay, I now get the difference between a function that returns an ARRAY and a
function that returns a LIST (== anonymous array?). (Must be why they
capitalize it in the doc.
Frankly, I still don't understand why the list output by split couldn't
hang-around long enough for split to remove and return the first elment, then
disappear, but at least I know how to avoid this in the future. Thanx.
Andre L. wrote:
>
>
> shift(split()) is not licit syntax, is all.
>
> Use correct syntax and you won't get the error.
>
> foreach (@junk) {
> print shift(@{[split ' ']}),"\n";
> }
>
> But, if you think about it, there's no practical reason to use shift() on
> an anonymous array, so:
>
> foreach (@junk) {
> print +(split ' ')[0],"\n";
> }
>
> A.L.
------------------------------
Date: 10 Jul 1998 22:13:42 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Bug? shift( split(' ',$_)); won't compile.
Message-Id: <6o63mm$sm4$1@csnews.cs.colorado.edu>
In comp.lang.perl.misc, "abuse"@[127.0.0.1] writes:
:Okay, I now get the difference between a function that returns an ARRAY and a
:function that returns a LIST (== anonymous array?).
No you don't, or you would have said it that way. All functions
return lists.
You don't get a better answer until you fix your newsreader.
--tom
--
"New versions happen." --Larry Wall
------------------------------
Date: Fri, 10 Jul 1998 14:34:34 +0200
From: Philippe Vivarelli <philippe.vivarelli@rss.rockwell.com>
Subject: Can I do it with ioctl() with Perl ?
Message-Id: <35A60A5A.6636499B@rss.rockwell.com>
Hi,
I currently design a driver for a PRI ISDN pci board on linux.
I wrote a little utility to be able to read the pci configuration of
the board (IRQ, Latency timer, etc..)
Well this utility is written in C code and it run from a shell window.
I would like to write an equivalent utility in perl to be ablle to read
the board pci configuration from a browser.
In my C code I use the ioctl() function do to that (you will find below
a part of my utility).
I think I could to something equivalent with the perl ioctl() function
but it is not obvious for a perl beginner. The documentation I found on
the web doesn't help a lot.
Doesn't someone has a concrete example of using the ioctl function ?
Regards
Thank you
Philippe Vivarelli
######################
Here is my C code
######################
#ifndef SBCS_QUANTUM
#define SBCS_QUANTUM 4000
#endif
#ifndef SBCS_QSET
#define SBCS_QSET 1000
#endif
int SBCS_quantum = SBCS_QUANTUM;
int SBCS_qset = SBCS_QSET;
int i;
/* Use 'k' as magic number */
#define SBCS_IOC_MAGIC 'k'
#define SBCS_IO_READ_PCI _IOR(SBCS_IOC_MAGIC, 3,SBCS_quantum)
void main(void)
{
int quantum=5;
int fd, n;
char c,d;
unsigned long * temp ,*tempo;
fd=open("/dev/sbcs" ,O_RDONLY);
if (fd==-1)
{
printf("Exit\n");
exit(3);
}
printf("\n\n\n\n-----------------------\n| Driver
|\n-----------------------\n\n");
do{
printf("\n\n(G)et parameters or (Q)uit ? \n");
c=getc(stdin);
switch(c)
switch(c)
{
case 'g':
case 'G':
getc(stdin);
do
{
printf(" ---------------------------------------\n");
printf(" | (P)ci Infos |\n");
printf(" | (B)ack to previous menu |\n");
printf(" ---------------------------------------\n\n");
d=getc(stdin);
switch(d)
{
case 'p':
tempo=(unsigned long *)malloc(30*sizeof(unsigned long));
//system call itself ,see sbcs_ioctl
ioctl(fd,SBCS_IO_READ_PCI,tempo);
printf("---PCI space informations --- \n\n");
temp=tempo;
printf(" ----Function ---------- \n",i);
printf(" | Command 0x%x \n",*temp);
temp++;
printf(" | Status 0x%x \n",*temp);
temp++;
printf(" | RevisionId 0x%x \n",*temp);
temp++;
printf(" | ClassCode 0x%x \n",*temp);
temp++;
printf(" | HeaderType 0x%x \n",*temp);
temp++;
printf(" | BaseAddress 0x%08x \n",*temp);
temp++;
printf(" | InterruptLine %d \n",*temp);
temp++;
printf(" | InterruptPin %d \n",*temp);
printf(" ------------------------- \n");
temp++;
printf(" LatencyTimer %d \n",*temp);
temp++;
printf(" MinGrant %d \n",*temp);
temp++;
printf(" MaxLatency %d \n",*temp);
getchar();
free(tempo);
break;
default:
}
------------------------------
Date: 10 Jul 1998 21:10:38 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Chmod (cgi-unix)
Message-Id: <6o600e$1uo$3@marina.cinenet.net>
Guillermo Garcis (ggarces@arrakis.es) wrote:
: How i can do a chmod from a cgi
perldoc -f chmod
Of course, whether the user under which the CGI app is running has
*permission* to do the chmod is a separate issue.
---------------------------------------------------------------------
| 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: Fri, 10 Jul 1998 17:36:32 -0400
From: Jerry Gitomer <jgitomer@ictgroup.com>
Subject: Re: Choosing DBMS: friendly to Linux, Apache, Perl, Java
Message-Id: <35A68960.67D8@ictgroup.com>
Hi Gordo,
I used Interbase in the past and found it to be a very solid product. I
used to use my Oracle manuals (since I preferred them to the Interbase
manuals) so I can assure you that it is very compatible with Oracle (at
least at the SQL level).
OLTP performance is competitive with Oracle, Informix, and Sybase.
>From what I remember the company was founded and developed an RDBMS
product. They were acquired by Ashton-Tate which, in turn, was acquired
by Borland. Since, at the time, Interbase was a Unix product and
Borland was a PC company Borland tried to sell Interbase (which upset
the user community). Fortunately Borland finally realized that they had
a first class product and instead decided to make it the basis for their
high end database products.
Regards
Jerry
gordo@pclink.com wrote:
>
> Thanks. Do you know anything of INterbase's history and product development
> trajectory?
>
> gordon
>
> In article <6o3lhs$g7l@bgtnsc02.worldnet.att.net>,
> m.hewitt@worldnet.att.net (Milton) wrote:
> > At precisely, Thu, 09 Jul 1998 12:24:07 -0700
> > ID: <35A518D7.1B43@Non-HP-USA-om42.om.hp.com>
> > Newsgroup: news:comp.databases
> >
> > Matt Houseman proclaimed:
> >
> > >Your best bet to create a robust app is to choose InterBase given
> > >the choices available right now for Linux. Have a look at:
> > >http://www.interbase.com (Lots of downloadable software for Linux)
> > >I think that you'll find that it meets all of your criteria:
> > > - RedHat
> > > - IBPerl
> > > - InterClient JDBC driver
> > >Matt Houseman
> >
> > I agree, BUT Interbase 4 will only run on RedHat 4.2.
> > Interbase 5, coming in 3qtr98 will run on RedHat 5.x
> >
> > --
> > +++++++++++++++++++++++++;;;;;;;;;;;;;;;;;;;;;;;;;;
> > Milton B. Hewitt
> > CAUCE member - http://www.cauce.org
> > Proud supporter of the Microsoft Boycott Campaign
> > http://www.abctec.com/~msbc/
> > +++++++++++++++++++++++++;;;;;;;;;;;;;;;;;;;;;;;;;;
> >
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
--
Jerry Gitomer ICT Group
jgitomer@ictgroup.com Langhorne PA
jgitomer@yahoo.com Opinions are mine not those of ICT Group
------------------------------
Date: Fri, 10 Jul 1998 15:28:20 -0700
From: Eric Hilding <nospam@xx.com>
Subject: File comparison and update
Message-Id: <35A69584.1736@xx.com>
I'm stuck at the File Comparison/Update crossroads (code attempts thus
far below) ...
The need is to compare two separate multi-field type .csv files and
update a field in the first file based upon matching a record field in
the second file. Once I get the hang of what to do, I can then modify
things as needed for similar tasks...or identify and delete duplicate
records between databases, etc.
File A will be: "fieldA1","fieldA2","fieldA3"
File B will be: "fieldB1","fieldB2","fieldB3"
One task is to compare File B to File A, and:
1. If fieldB1 in any File B record *does* match any fieldA1 record in
File A, then replace or update the data (or if blank insert it) in
the fieldA3 record of File A with the data in fieldB3 of the File B
record...but do nothing if the fieldA3 and fieldB3 data are already
the same.
2. If fieldB1 in any File B record does NOT match any fieldA1 record in
File A, then add that entire record from File B to File A.
Most files will be 2,000 or less records, but once in a while I may have
to deal with a couple of about 25,000 records and possibly 10 fields of
data...so I don't know if this poses a major problem with overhead. I'm
using WinPerl 5.003 on a P166 with 32MB RAM.
Thanks. Please do NOT e-mail.
Eric
#!c:\perl -w
# a1b2.pl 7/10/98 working
print "Enter File A Name: "; #instructions for entering File A name
$fileA = <STDIN>;
print "Enter File B Name: "; #instructions for entering File B
name
$fileB = <STDIN>;
open (INFILEA, $fileA) ||
die "could not open '$filename' $!"; #open file or die
open (INFILEB, $fileB) ||
die "could not open '$filename' $!"; #open file or die
$totalrecsA = 0; #initialize total record count File A
$totalrecsB = 0; #initialize total record count File B
while ($line = <INFILEA>) #loop for File A
{
$textA = $line;
### Read ascii .csv data into a list, array or ???
### From FAQ (modified @new and $text)
### Due to the restriction of the quotes, this is a fairly complex
problem. Thankfully,
### we have Jeffrey Friedl, author of a highly recommended book on
regular expressions,
### to handle these for us. He suggests (assuming your string is
contained in $text):
@newA = ();
push(@newA, $+) while $textA =~ m{
"([^\"\\]*(?:\\.[^\"\\]*)*)",? # groups the phrase inside the
quotes
| ([^,]+),?
| ,
}gx; ### What the heck is "gx" ???
push(@newA, undef) if substr($text,-1,1) eq ',';
}
close (INFILEA); #close input File A
while ($line = <INFILEB>) #loop for File B
{
$textB = $line;
### Read ascii .csv data into a list, array or ???
@newB = ();
push(@newB, $+) while $textB =~ m{
"([^\"\\]*(?:\\.[^\"\\]*)*)",? # groups the phrase inside the
quotes
| ([^,]+),?
| ,
}gx;
push(@newB, undef) if substr($text,-1,1) eq ',';
}
close (INFILEB); #close input File B
### Compare FileA $fieldA1 & Replace/Update $fieldA3 Code??
### From FAQ
###How do I compute the difference of two arrays? How do I compute the
intersection of two
###arrays? Use a hash. Here's code to do both and more. It assumes that
each element is
###unique in a given array:
###Modify @array1 to @newA and @array2 to @newB ????
@union = @intersection = @difference = ();
%count = ();
foreach $element (@array1, @array2) { $count{$element}++ }
foreach $element (keys %count) {
push @union, $element;
push @{ $count{$element} > 1 ? \@intersection : \@difference },
$element;
}
### How to pull it all together here has me baffled!!!
$totalrecsA2 = 0; #initialize total record count File A2
open (FILE,">>$fileA2"); #open output file for append
##OLD attempt: print FILE "\"$fieldA1\",\"$fieldA2\",\"$fieldA3\"\n";
#write updated
#File A data to FileA2 using $fieldnames
###How to print the updated File A data into File A2 as asci .csv???
close (FILE); #close updated output file
print "File A Records: $totalrecsA\n"; #print total File A records
print "File A Records: $totalrecsB\n"; #print total File B records
print "File A2 Records: $totalrecsA2\n";#print total File A2 records
# END OF PERL SCRIPT
------------------------------
Date: Fri, 10 Jul 1998 16:00:28 -0500
From: postmaster <"postmaster"@[127.0.0.1]>
Subject: Re: Get IP Address for Server Name
Message-Id: <6o5vfd$sgn$2@farstar.frb.gov>
Eli the Bearded wrote:
> In comp.lang.perl.misc, "bobn at interaccess dot com" wrote:
> > #!/usr/local/bin/perl -w
> >
> > use diagnostics;
> >
> > $ip_addr = `nslookup $ARGV[0]`;
> > print "`nslookup $ip_addr\n";
> >
> > # works on Solaris 2.5.1, perl 5.00403; s/b OK on NT too.
>
> If you think that works, you did not test it enough under enough
> situations.
I tested it under the situation I have.
> nslookup must be on the PATH, must be executable, and
> then will only give names found via DNS,
which sounds pretty common to me, except that nslookup may well not be in the
average user's path.
> ignoring those from /etc/hosts
> or NIS.
True. I Probably should have qualified with the DNS/nslookup bit. Still, I
*did* test it - more than lots of folks in usenet-land do.
>
>
> :r! perl -e '@a=unpack"C4",gethostbyname(shift);$\="\n";$,=".";print@a' qz.to
> 204.141.4.65
>
> Elijah
> ------
> just created an alias doing roughly this task this morning
------------------------------
Date: Fri, 10 Jul 1998 23:49:29 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: Help, OLE is giving me a hard time.
Message-Id: <35ad8a12.16227353@news2.ibm.net>
[MAILED & POSTED]
mad_ahmad@my-dejanews.com wrote:
>i tried your suggestion, and i still get just the first element of the array,
>(or the first cell of the range)
>I think the problem is in this line: the assignment:
>
>$ourcolumn = $comparesheet->Range("$cella:$cellb")->{Value};
>
>I don't know what it is though for some reason the array that gets assigned
>only contains one element, and yet it's still an array.
>(ie, the memory addrss says ARRAY(blah), but when i print, one value appears)
>
>any ideas??
You still didn't specify which versions of Perl and OLE/Win32::OLE you
were using, so I really have no idea. Here is a test program to show you
how it works:
###############################################################
use strict;
use Win32::OLE;
my $Excel = Win32::OLE->new('Excel.Application', 'Quit');
my $Book = $Excel->Workbooks->Add;
my $Sheet = $Book->Worksheets(1);
$Sheet->Range('A1:A3')->{Value} = [['XYZZY'], [42], ['Plugh']];
my $Column = $Sheet->Range('A1:A3')->{Value};
print join("\n",@$Column), "\n";
foreach (@$Column) { $_ = @$_[0]; }
print join("\n",@$Column), "\n";
###############################################################
This prints (with Perl 5.004_69 and Win32::OLE 0.0810, but probably also
with 5.004_02 and Win32::OLE from libwin32-0.12):
ARRAY(0x301394)
ARRAY(0x3066c4)
ARRAY(0x306634)
XYZZY
42
Plugh
-Jan
------------------------------
Date: Fri, 10 Jul 1998 22:55:36 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: How can you encrypt a CGI script on a server so it will not get "stolen"?
Message-Id: <35a699cc.92138774@nntp.idsonline.com>
Mike West <westmj@esvax.dnet.dupont.com> Said this:
>In article <35A58C49.23BEE40F@lanl.gov> John Layne, jpl@lanl.gov writes:
>
>>What would be the best way to protect my assets?
>
>Well, John, as a US taxpayer, I worry about people abusing their
>trust. Using ".gov" machines to post personal buiness to USENET,
>instead of doing their job.
wah wah wah. Get real. American people are so misquided and direct
their anger at such ridiculous places. How much money do you think
John wasted by using a ".gov" machine to post that message?
Like you do not, ever, use your company's computers for personal
business, or do anything "non-business" while at work?? I mean,
everybody is entitled to having at least some "down time" at work, and
to use that time however they see fit. I mean, are you one of those
"better for everyone else, but not for me" types who thinks if someone
works for the government, on "your tax dollar" that they should be
doing work related tasks every single second of every 7 hour work
day??
I live 10 miles outside DC, so I'm pretty aware of how government
workers are. Sure, places like the state department tend to have more
people who read the Washington Post from 10 am until noon, go to lunch
from noon to 1, talk on the phone from 1 to 3 and then do some actual
work from 3 to 4:55, and are on the elevator and out the door by 5pm
exactly, but at the same time most government workers actually work
harder (and take more abuse for it) than most people in "the private
sector".
If you are really concerned about how your tax dollars are spent,
write your congressman, investigate, do a little research and find out
exactly where misspending is occuring, rather than just making shit up
like the majority of the unwashed masses in america.
------------------------------
Date: Fri, 10 Jul 1998 17:49:53 -0500
From: sporgduffle@radparker.com (Al Iverson)
Subject: Re: I am an "antispam spammer"?
Message-Id: <sporgduffle-ya023180001007981749530001@news.radparker.com>
wbaseley@mindspring.com (WD Baseley) wrote:
: A generous offer. Could you point me to the RFC that allows you to
: attempt to publicly humiliate anyone who objects to jumping through
: your reply hoops?
Turnabout is fair play. It may not be an RFC, it may not even be mature,
but if someone is a jerk, don't be stupid and assume the person won't be a
jerk in return.
--
Al Iverson -- munged address in use, please go to my web site
at http://al.radparker.com if you want to send me email
Don't send us UCE unless you want us to send it back to you.
------------------------------
Date: Fri, 10 Jul 1998 22:05:45 GMT
From: nowen@acm.org
Subject: Looking for the NET:telnet
Message-Id: <6o637p$j69$1@nnrp1.dejanews.com>
Dear everybody,
I have PERL 5.004_02 in my system and seems like the NET::telnet module is
missing (the NET::ftp is here though).
Could you please tell me where I can obtain this telnet module.
Thank you.
- Noel -
nowen@acm.org
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 10 Jul 1998 22:09:50 GMT
From: schinder@leprss.gsfc.nasa.gov (Paul J. Schinder)
Subject: Re: MacPerl: Reading rsrc fork
Message-Id: <6o63fe$p4q$1@clarknet.clark.net>
In <6o5una$6v2$1@news1.bu.edu> macintsh@cs.bu.edu (John Siracusa) writes:
>Using MacPerl, I'm trying to read the contents of a file's resource
>fork in the same manner that you'd read the data fork: as a stream of
>bytes. The MacPerl docs list at least one useful function:
If you want to do that, you don't use Mac::Resources. You use POSIX::{open,
read,write}:
use POSIX;
use Fcntl;
$fd = POSIX::open($outname,&Fcntl::O_RSRC | &POSIX::O_RDONLY ,0755);
POSIX::read{$fd,$data,$length);
etc.
The key thing is to use the Fcntl::O_RSRC, which tells MacPerl to open
the resource fork instead of the data fork as a byte stream. Look at
my Mac::Conversions module, which you can find at
<http://pobox.com/~schinder/MacPerl.html> for a real life example,
converting MacBinary <=> native Mac files.
>-----------------+----------------------------------------
> John Siracusa | If you only have a hammer, you tend to
> macintsh@bu.edu | see every problem as a nail. -- Maslow
------------------------------
Date: Fri, 10 Jul 1998 22:38:55 GMT
From: scott@jtsmith.com
Subject: More Serial Port Problems
Message-Id: <6o655v$lgo$1@nnrp1.dejanews.com>
Just to explain the problem I'm having, I have two machines hooked together
with a null modem cable. One is a DOS based system, with a program watching
the serial port for any incoming data. The second is our linux server.
I was having problems with the i/o between the machiens before, but with a
post on here I quickly figured out to just set the DOS program I was working
with to 9600 baud, then I was able to get data to transmit back and forth
between the two programs.
However, I'm still having a few obvious basic problems.
Here's a copy of the script:
#!/usr/bin/perl
use Fcntl;
$user = "username";
$pw = "password";
sysopen(DEV, "/dev/ttyS1", O_RDWR|O_NOCTTY);
print DEV "$user|$pw\r\n";
while (<DEV>) {
print "$_";
}
close(DEV);
---
Now, this script sends the user and password information (which is just
dummied up right now) to the DOS-based machine, which returns a default page
screen. The screen comes back to the linux machine, and is printed out to
STDOUT, but it is also being printed BACK to the DOS program, which prints
hte page AGAIN to the linux server, and so on. It causes an endless loop of
data to be sent back and forth between the two machines.
Now, if I had the mode O_NDELAY up there in hte sysopen() command, I don't
get _any_ data sent back and forth. I can send the print DEV line, but after
that, nothing comes back to me.
What am I doing wrong here? I've read the Perl FAQ on serial devices, and
they have a section talking about "autoflushing", but I don't really
understand what that is about. I was told by someone else who works with me
that autoflushing a filehandle clears the buffer before you print to that
filehandle. Is that true? If so, do I need to autoflush the filehandle DEV?
It seems to print to DEV fine, and has the looping problem later.
Any explanation would be greatly appreciated.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 10 Jul 1998 23:30:10 +0200
From: "Guillermo Garcis" <ggarces@arrakis.es>
Subject: Openin files
Message-Id: <35a688a1.0@news.arrakis.es>
Can i open a file that is in other server?
------------------------------
Date: Fri, 10 Jul 1998 17:05:59 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: simple file grepping/searching question
Message-Id: <7836o6.n4b.ln@localhost>
Andrew Perrin (aperrin@mcmahon.qal.berkeley.edu) wrote:
: ....and what's wrong with grep() for this task?
It won't work for the requirements specification that was given.
: Scott Saddison wrote:
: > Hi, I know someone out there must have an easy way of doing this:
: >
: > I have a list of ids (@ids), and a list of files (@Files)
: >
: > I want to sort the list of files for the list of ids, if a files
: > contains any of the ids in the id list to print it.
: >
: > I was looking for a file grep command in perl to search the files for an
: > id without having to open it parse thru it.
^^^^^^^^^^^^^^^^^^^^^^^^^
That will be hard with perl's builtin grep()...
And BTW Scott, _something_ has to open it, might as well be your
script as any other program...
As for matching a bunch of ids from an array, you might have a
look at this Perl FAQ (part 6):
"How do I efficiently match many regular expressions at once?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 10 Jul 1998 21:51:54 GMT
From: win95mag@my-dejanews.com
Subject: Site creation scripts?
Message-Id: <6o62dq$hph$1@nnrp1.dejanews.com>
Does anyone know of a Perl script that can be used by multiple websites for
online website creation? We're looking for something similar to ViaWeb. Is
there anything out there?
Thanks!
Austin Williams
Win95 Magazine
http://www.win95mag.com
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 10 Jul 1998 16:32:41 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Taking info from tags (not ness. HTML)
Message-Id: <p916o6.ova.ln@localhost>
James Dobson (JDobson@rnib.org.uk) wrote:
: I've created a mail markup lang that I wish to use with perl. Is it
: possable and !!simple!! to get perl to read attributes and what is
^^^^^^^^ ^^^^^^
It is possible and simple because they are not nested...
: between tags.
: I would like to the VALUE, CONDITION, FROM and SUBJECT into varibles to
: display. There can be many emails in a file so the varibles will need to
: be used more than once.
: I've tried substitution but it is way to finicky as the message can be
: on more than one line. I'm not sure if there is a simple answer I'd just
: thought I'd ask to challenge people out there! (I'm finding it hard!!!
^^^^
So which is it then?
Hard or Simple? ;-)
---------------------------------
#!/usr/bin/perl -w
$_ = <<END_MESSAGES;
<MAIL VALUE="1" CONDITION="A"><TO>Mr to1</TO><FROM>Mr
from1</FROM><SUBJECT>Subject 1</SUBJECT><MESSAGE>Don't Y1
me!</MESSAGE></MAIL>
<MAIL VALUE="2" CONDITION="B"><TO>Mr to2</TO><FROM>Mr
from2</FROM><SUBJECT>Subject 2</SUBJECT><MESSAGE>Don't Y2
me!</MESSAGE></MAIL>
<MAIL VALUE="3" CONDITION="C"><TO>Mr to3</TO><FROM>Mr
from3</FROM><SUBJECT>Subject 3</SUBJECT><MESSAGE>Don't Y3
me!</MESSAGE></MAIL>
END_MESSAGES
while ( m#(<MAIL[^>]*>.*?</MAIL>)#gs ) {
$msg = $1;
($value, $condition, $to, $from) = $msg =~
m#
VALUE="([^"]*)"
.*
CONDITION="([^"]*)"
.*
<TO>(.*)</TO><FROM>(.*)</FROM>
#sx;
$from =~ tr/\n//d; # delete newlines
print <<END_MAIL;
Value: $value
Condition: $condition
From: $from
To: $to
-----
END_MAIL
}
---------------------------------
outputs:
Value: 1
Condition: A
From: Mr from1
To: Mr to1
-----
Value: 2
Condition: B
From: Mr from2
To: Mr to2
-----
Value: 3
Condition: C
From: Mr from3
To: Mr to3
-----
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 10 Jul 1998 22:22:13 GMT
From: psi@euclid.jpl.nasa.gov (Peter Scott)
Subject: Trinary operator vs =~ : sometimes it doesn't pay to be too cute
Message-Id: <6o646l$njv@netline.jpl.nasa.gov>
Friend had code which needed to do a different translation depending
on the value of some option, had written:
$opt_t =~ /unix/i ? $doc =~ tr/\r/\n/ : $doc =~ tr/\r/\r\n/;
"That's good," said I, then stuck my foot in my mouth by saying, "of course,
you could save a bit of typing by writing it instead as"
$doc =~ ($opt_t =~ /unix/i) ? tr/\r/\n/ : tr/\r/\r\n/;
Wrong! Should have tried it first, no matter how obvious it looked.
She came back wondering why it was complaining about an uninitialized
variable at that line. Since I then found in perlop:
If the right argument is an expression
rather than a search pattern, substitution, or translation,
it is interpreted as a search pattern at run time.
I guess that little piece of cuteness won't fly. And the uninitialized
variable was $_.
I am starting to think I made fewer errors back when I was programming
what the Camel calls "baby talk"...
--
This is news. This is your | Peter Scott, NASA/JPL/Caltech
brain on news. Any questions? | (psi@euclid.jpl.nasa.gov)
Disclaimer: These comments are the personal opinions of the author, and
have not been adopted, authorized, ratified, or approved by JPL.
------------------------------
Date: 10 Jul 1998 20:51:11 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Weirdness in trying to extract year from localtime
Message-Id: <6o5urv$1uo$1@marina.cinenet.net>
Allen Choy (achoy@us.oracle.com) wrote:
: I'm having this weird occurence with extracting the year from localtime.
:
: Here's the code:
:
: 1. $z = (split / /, localtime)[4];
Yuck. Why not just use (localtime)[5] + 1900 ?
: However, there were times where
:
: 2. $z = (split / /, localtime)[5];
:
: would get me the year, and 1) wouldn't, and visa-versa.
:
: Anyone has a clue what's going on?
Yep. Consider that today's date/time rendered by scalar localtime is
Fri Jul 10 13:44:14 1998
while yesterday's is
Thu Jul 9 13:45:12 1998
Note that the latter has two spaces between the month name and the date,
since the date is less than 10. Your split splits on *each space*, so you
end up with an empty string at index 3 in this case, shifting all the
other fields one list position up. Splitting on ' ' would fix this, but
I'd really recommend the subscripting form I showed above instead.
---------------------------------------------------------------------
| 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: 10 Jul 1998 20:53:11 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Weirdness in trying to extract year from localtime
Message-Id: <6o5uvn$1uo$2@marina.cinenet.net>
Craig Berry (cberry@cinenet.net) wrote:
[snip]
: end up with an empty string at index 3 in this case, shifting all the
[snip]
Make that index 2. I was having a Fortran flashback. :-)
---------------------------------------------------------------------
| 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: 10 Jul 1998 16:30:20 -0500
From: awdorrin@mail.delcoelect.com (Albert W. Dorrington)
To: Allen Choy <achoy@us.oracle.com>
Subject: Re: Weirdness in trying to extract year from localtime
Message-Id: <6o615d$lem@ws051eng.ictest.delcoelect.com>
In article <35A675F9.29324E54@us.oracle.com>, Allen Choy <achoy@us.oracle.com> writes:
:> I'm having this weird occurence with extracting the year from localtime.
:>
:> Here's the code:
:>
:> 1. $z = (split / /, localtime)[4];
:>
:> However, there were times where
:>
:> 2. $z = (split / /, localtime)[5];
:>
:> would get me the year, and 1) wouldn't, and visa-versa.
:>
:> Anyone has a clue what's going on?
:>
:> Thanks in advance,
:>
:> Allen
:>
If you want the year, just do:
$year = localtime[5] + 1900;
There is no need for splits, or anything else.
The reason you are getting the strange results is
that the way your paranthesis are positioned, localtime
is being evaluated as a scalar and is returning a date
in the format of:
"Fri Jul 10 16:23:54 1998"
However, when the day portion is only a single
digit, the string is returned as:
"Fri Jul 3 12:00:00 1998"
Note the additional space in front of the 3.
Using the code:
$year = localtime[5] + 1900;
localtime returns an array of values, the
cell with index 5 contains the year, with 1900
subtracted from it.
- Al
--
Al Dorrington
FIRMS & Web Admin, Oracle DBA Phone: 765-451-9655
IC-DELCO CIM, Delphi Delco Electronics Systems Fax: 765-451-8230
------------------------------
Date: 10 Jul 1998 21:50:39 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Weirdness in trying to extract year from localtime
Message-Id: <6o62bf$1uo$4@marina.cinenet.net>
Albert W. Dorrington (awdorrin@mail.delcoelect.com) wrote:
: Using the code:
:
: $year = localtime[5] + 1900;
That actually needs to be (localtime)[5] .
---------------------------------------------------------------------
| 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: 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 3123
**************************************