[16212] in Perl-Users-Digest
Perl-Users Digest, Issue: 3624 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 11 18:10:45 2000
Date: Tue, 11 Jul 2000 15:10:33 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963353432-v9-i3624@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 11 Jul 2000 Volume: 9 Number: 3624
Today's topics:
Captuing the output of a system call. <jeffahill@lucent.com>
Re: Captuing the output of a system call. <care227@attglobal.net>
Re: Captuing the output of a system call. <jeffahill@lucent.com>
Re: Captuing the output of a system call. <care227@attglobal.net>
Re: Captuing the output of a system call. <jeffahill@lucent.com>
Re: Captuing the output of a system call. <tony_curtis32@yahoo.com>
Re: Captuing the output of a system call. newsposter@cthulhu.demon.nl
Re: CGI Query string and Netscape <jboes@eoexchange.com>
CGI-to-NT service communication..... <gtreece@vhbtech.com>
Re: CGI-to-NT service communication..... kbcafe@my-deja.com
Re: Comparing fields of two files (Abigail)
Re: Construct HTML page from a text file. (Craig Berry)
Re: Convert integers to strings (lenght) (Craig Berry)
Re: Cookie & redirect (Anthony DeLorenzo)
Re: Cookie & redirect (brian d foy)
DBI - DBD:Sybase installation problem vpanicker@my-deja.com
Drag and Drop files onto Perl Script mpressnall@my-deja.com
Re: Drag and Drop files onto Perl Script <care227@attglobal.net>
Re: Drag and Drop files onto Perl Script <bart.lateur@skynet.be>
Re: Drag and Drop files onto Perl Script <bhoran@gate.net>
easy one for xperienced users.. hard for me... <jasoniversen@my-deja.com>
Re: easy one for xperienced users.. hard for me... <bwalton@rochester.rr.com>
Re: easy one for xperienced users.. hard for me... <bart.lateur@skynet.be>
Embedding Logo (images) in Email generated by Perl Scri <t0873@my-deja.com>
Re: Experienced PERL / CGI programmers needed (Craig Berry)
Re: Experienced PERL / CGI programmers needed (David H. Adler)
Re: How can i know when a string == NULL (Craig Berry)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 11 Jul 2000 13:21:16 -0500
From: Jeff H <jeffahill@lucent.com>
Subject: Captuing the output of a system call.
Message-Id: <396B659C.BD62FB1@lucent.com>
I've looked on the perl.com website, and in O'Reilly's _Perl in a Nutshell_ and
can't find the answer to my questions.
I have some code for a CGI that goes something like this:
___________START CODE________________
#!/usr/bin/perl -w
use strict;
use CGI qw /:standard/;
print header, start_html("Labor Hours"), h1("Enter a code");
if (param()) {
my $code = param("code");
# put code here to generate the report
my $out = system ('bh $code') ;
print p($out);
} else { #This is the first time the page has been run.
print start_form();
print p("Which code (no wildcards at this point): ", textfield("code"));
print p(submit(), reset());
print end_form(), hr();
}
print end_html;
________________END CODE__________________
When this is run, the output is 256.
bh is a awk script that was written some time ago, and generates some
information in a semicolon delimited format. I'm in the testing phase right
now, and I can't get this to work. I did a test script that was as follows.
my $out = system ('bh mk005a');
print $out;
And it prints out the expected results. Is there something going on here that
I'm unaware of? I'm very new to CGI based Perl programming. Please help, and
keep flames to a minimum.
Thanks,
Jeff Hill
------------------------------
Date: Tue, 11 Jul 2000 14:34:08 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Captuing the output of a system call.
Message-Id: <396B68A0.77D1EF5F@attglobal.net>
Jeff H wrote:
>
> When this is run, the output is 256.
>
> bh is a awk script that was written some time ago, and generates some
> information in a semicolon delimited format. I'm in the testing phase right
> now, and I can't get this to work. I did a test script that was as follows.
>
> my $out = system ('bh mk005a');
> print $out;
>
> And it prints out the expected results. Is there something going on here that
> I'm unaware of?
Yes, obviously there is something you are unaware of. If you were
aware, I'd hope you'd not have posted. From the documentation of
the system() function:
(http://www.perl.com/pub/doc/manual/html/pod/perlfunc/system.html)
:The return value is the exit status of the program as returned by
:the wait() call. To get the actual exit value divide by 256. See
:also exec. This is NOT what you want to use to capture the output
:from a command, for that you should use merely backticks or qx//,
:as described in `STRING`.
------------------------------
Date: Tue, 11 Jul 2000 14:25:10 -0500
From: Jeff H <jeffahill@lucent.com>
Subject: Re: Captuing the output of a system call.
Message-Id: <396B7496.293507F0@lucent.com>
Drew Simonis wrote:
> (http://www.perl.com/pub/doc/manual/html/pod/perlfunc/system.html)
I've read that information, and I'm still confused. I've tried every possible
combination. When I write a program and run it from the command line, I get the
proper output. When I do EXACTLY the same thing and put it in the CGI program,
I now get 65280 (I changed a few things, as follows).
command line version that works:
#!/usr/bin/perl -w
my $code = "mk005a";
my $out = system("bh $code");
print $out;
CGI version, with qw/:standard/;
---
my $out = system ("bh $code");
print p($out);
---
They are very nearly identical. It still isn't working.
Jeff Hill
------------------------------
Date: Tue, 11 Jul 2000 15:54:16 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Captuing the output of a system call.
Message-Id: <396B7B68.1C7F44C5@attglobal.net>
Jeff H wrote:
>
>
> CGI version, with qw/:standard/;
> my $out = qx{bh $code};
> print p($out);
Does that work?
------------------------------
Date: Tue, 11 Jul 2000 15:37:01 -0500
From: Jeff H <jeffahill@lucent.com>
Subject: Re: Captuing the output of a system call.
Message-Id: <396B856D.1E2D6431@lucent.com>
This is what's there currently:
my $out = qx{bh $code};
print h1("Results for $code");
print p($out);
And this is the webpage that it generates:
Results for mk005a
html:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE>Labor Hours</TITLE>
</HEAD><BODY><H1>Results for mk005a</H1><P></P></BODY></HTML>
As you can see, the print p($out) is generating the <p></p> tags, but not any
information. I'm thinking there's some small, but not trivial, piece of the
puzzle that I'm missing.
Drew Simonis wrote:
>
> Jeff H wrote:
> >
> >
> > CGI version, with qw/:standard/;
>
> > my $out = qx{bh $code};
> > print p($out);
>
> Does that work?
------------------------------
Date: 11 Jul 2000 15:50:19 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Captuing the output of a system call.
Message-Id: <87og44bddg.fsf@limey.hpcc.uh.edu>
>> On Tue, 11 Jul 2000 15:37:01 -0500,
>> Jeff H <jeffahill@lucent.com> said:
> This is what's there currently: my $out = qx{bh $code};
> print h1("Results for $code"); print p($out);
> And this is the webpage that it generates:
> Results for mk005a
> html:
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
> <HTML><HEAD><TITLE>Labor Hours</TITLE>
> </HEAD><BODY><H1>Results for
> mk005a</H1><P></P></BODY></HTML>
> As you can see, the print p($out) is generating the
> <p></p> tags, but not any information. I'm thinking
> there's some small, but not trivial, piece of the puzzle
> that I'm missing.
It looks as if your program is not producing anything on
standard output. Note that with a literal,
use CGI ':standard';
print p('hello');
print "\n";
you get what you expect, so maybe your code should inspect
$out to see what's in it (if anything).
Running the code from the command line and redirecting
stdout would also be a good test. Maybe the output is
going to stderr?
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: 11 Jul 2000 21:06:26 GMT
From: newsposter@cthulhu.demon.nl
Subject: Re: Captuing the output of a system call.
Message-Id: <8kg28i$2mc$2@internal-news.uu.net>
Jeff H <jeffahill@lucent.com> wrote:
> This is what's there currently:
> my $out = qx{bh $code};
> print h1("Results for $code");
> print p($out);
[snip]
> As you can see, the print p($out) is generating the <p></p> tags, but not any
> information. I'm thinking there's some small, but not trivial, piece of the
> puzzle that I'm missing.
This suggests $out is empty. That is possible if the qx didn't have
any output to stdout. Eg, an error message could have been sent to stderr.
Erik
------------------------------
Date: Tue, 11 Jul 2000 15:56:58 -0400
From: Jeff Boes <jboes@eoexchange.com>
Subject: Re: CGI Query string and Netscape
Message-Id: <396b7cc1$0$1502$44a10c7e@news.net-link.net>
NagaPutih wrote:
> $buffer=$ENV{'QUERY_STRING'};
> $buffer=~s/\+/ /g;
> foreach $item (split(/&/,$buffer)) {
> ($key,$val)=split(/=/,$item);
> $val=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $form{$key}=$val;
> }
>
> then finally your date value could be accessed by $form{'DATE'}
Icky! Icky!
The above horrid code can be eliminated by using:
use CGI qw(:standard);
$q = new CGI;
and then you can refer to your form variables as param('DATE'). One big
disadvantage of the poster's approach is that it doesn't handle
multi-value form elements (e.g., checkboxes or a drop-down list that
allows multiple selections) very well.
But all this is covered well in
perldoc CGI
and doesn't really belong in here, anyway.
--
Jeff Boes |Computer science is no more about
|jboes@eoexchange.com
Sr. S/W Engineer |computers than astronomy is about |616-381-9889 ext
18
Change Technology|telescopes. --E. W. Dijkstra |616-381-4823 fax
EoExchange, Inc. |
|www.eoexchange.com
------------------------------
Date: Tue, 11 Jul 2000 14:12:37 -0500
From: Greg Treece <gtreece@vhbtech.com>
Subject: CGI-to-NT service communication.....
Message-Id: <56CEC26EFF90B73F.82AEAF49592F5301.5CCB9E915F9DB48F@lp.airnews.net>
I am trying to feed some information from a cgi program (Apache) to an
NT service via a socket and
my perl script cannot open its socket connection. This works when run
from the command
line. Are there interprocess security settings somewhere to make this
happen?
------------------------------
Date: Tue, 11 Jul 2000 20:56:16 GMT
From: kbcafe@my-deja.com
Subject: Re: CGI-to-NT service communication.....
Message-Id: <8kg1l7$6t4$1@nnrp1.deja.com>
If you are using TCP/IP or UDP/IP sockets, then there should not be any
interprocess security issues.
--
Randy Charles Morin [MVP] - http://www.kbcafe.com/
Author of "Programming Windows Services"
http://www.amazon.com/exec/obidos/ASIN/047138576X/kbcafe
In article
<56CEC26EFF90B73F.82AEAF49592F5301.5CCB9E915F9DB48F@lp.airnews.net>,
Greg Treece <gtreece@vhbtech.com> wrote:
> I am trying to feed some information from a cgi program (Apache) to an
> NT service via a socket and
> my perl script cannot open its socket connection. This works when run
> from the command
> line. Are there interprocess security settings somewhere to make this
> happen?
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 11 Jul 2000 14:09:10 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Comparing fields of two files
Message-Id: <slrn8mmpnl.am3.abigail@alexandra.delanet.com>
The WebDragon (nospam@nospam.com) wrote on MMDVI September MCMXCIII in
<URL:news:8kfjn2$tpv$1@216.155.32.201>:
`` In article <slrn8mfs49.t4j.abigail@alexandra.delanet.com>,
`` abigail@delanet.com wrote:
``
`` | Could you describe *how* exactly this is supposed to work? In your
`` | examples, fileA contains '703#612#KY#' and fileB contains '7036123456'.
`` | The output file has '7036123456 MA'.
`` |
`` | Where is the MA coming from, and what happened to KY?
`` |
`` | Please, people, if you have a problem and want a solution, give a proper
`` | specification of the problem and certainly do define a problem with
`` | vague or unclear examples. Often, people try to describe problems with
`` | examples that don't even match the problem.
`` |
`` |
`` | Your problem might be a variant of what's answered in the FAQ. However,
`` | the problem is poorly phrased so who can tell?
``
`` On the contrary, I thought it was quite simple to understand that File A
`` was a list of *state (as in one of the 50 States) codes* and their
`` associated area codes, and File B was a list of Telephone numbers, that
`` the user wanted combined to show the telephone number AND its associated
`` state code in File C.
Yes, you would think so, wouldn't you?
`` *shakes Abigail awake*
``
`` *hands Abigail a double-expresso, and sets up a caffeine IV drip*
*I* am awake, and you are dreaming.
Let me repeat it again.
File A, which supposedly contains state codes and area codes contains
"703#612#KY#". That is, Kentucky, with area/exchange code 703-612.
File B, which supposedly contains a list of telephone numbers, contains
the number 7036123456.
*You* claim the output should be "7036123456 KY", meaning that the phone
number 703-612-3456 is in Kentucky.
However, had you been awake, you had seen that the user doesn't want KY
in the output, but MA. The phone number is supposed to be in Massachusetts.
Now, if you can determine from that how this matching is supposed to work,
please do inform us. I certainly can't.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
Date: Tue, 11 Jul 2000 20:06:49 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Construct HTML page from a text file.
Message-Id: <smmvipb5nd657@corp.supernews.com>
Ken H. Lee (kenhlee@tm.net.my) wrote:
: Hi,
: I am tring to read from a text file and print the html page. The code is
: something like this:
: print "HTTP 1.0 200 OK/n";
: print "pragma: no-cache\n";
: print "Content-type: text/html\n";
: print "\n";
In general, the server will add the first line (if this is a CGI, that
is), and the others are more reliably and easily generated using the CGI
module.
: $file = "nlplus.tpl";
: open (IDFILE, $file);
Never ever ever ever ever...[117 repetitions omitted]...*ever* fail to
check the success of open. Any number of weird things (permission
problems and cwd not being what you think it is being the big two) can
cause the open to fail; without a check, you'll have no clue why other
stuff is then acting funny. At minimum,
open IDFILE, $file or die $!;
See CGI::Carp for nice things like fatalsToBrowser which will put any
die() messages onto the generated page rather than just the log file.
: print "<html>\n";
: print "<body>\n";
: print "<h1>test1 </h1>\n";
:
: while (<IDFILE>)
: {
: $rec = $_;
: print $rec;
: }
Why go to all that trouble? Either
print while <IDFILE>;
or
print <IDFILE>;
will work; the latter is inadvisable for large files, however.
: print "<h1>test1 </h1>\n";
: print "</body>";
: print "</html>";
:
: close (IDFILE);
:
: I can see the "test" line on my browser but not the contain inside the
: "while" loop.
I'll bet the open() is failing.
: When I try in DOS prompt : perl nlplus.pl, the correct html page can come
: out.
Especially with that further info.
: I am running NT 4.0 with IIS 3.0.
Sorry, that's a separate bug report. :)
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Beauty and strength, leaping laughter and delicious
| languor, force and fire, are of us." - Liber AL II:20
------------------------------
Date: Tue, 11 Jul 2000 18:36:59 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Convert integers to strings (lenght)
Message-Id: <smmqab25nd67@corp.supernews.com>
Mark Lardinois (lardinois@ose.nl) wrote:
: Because I want to use Length()
No such (built in) function. Do you mean length(), perhaps?
: I have to convert an integer to a string.
No you don't.
: How can I do that?
Just do it (tm):
$a = 12345;
print length $a;
This prints 5, the length of the string representation of $a.
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Beauty and strength, leaping laughter and delicious
| languor, force and fire, are of us." - Liber AL II:20
------------------------------
Date: 11 Jul 2000 19:31:26 GMT
From: gonzo@vex.net (Anthony DeLorenzo)
Subject: Re: Cookie & redirect
Message-Id: <8kfsme$2qmg$1@news.tht.net>
For what it's worth, the HTTP specification does not allow any other
headers (including cookies) to be sent when a re-direct is sent. You
could use code like this:
print header ( -cookie=>$cookie, -location=>$url );
This should NOT work according to the HTTP specification, however
in practice many common user agents will allow it.
Regards,
Tony
--
# Anthony DeLorenzo <drgonzo@canada.com>
# http://www.vex.net/~gonzo/
# mojo wire: 209-391-8932
------------------------------
Date: Tue, 11 Jul 2000 16:47:55 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Cookie & redirect
Message-Id: <brian-ya02408000R1107001647550001@news.panix.com>
In article <8kfsme$2qmg$1@news.tht.net>, drgonzo@canada.com posted:
> For what it's worth, the HTTP specification does not allow any other
> headers (including cookies) to be sent when a re-direct is sent.
perhaps you can cite chapter and verse? the way i read it the spec
doesn't say that you can't, and it does say that HTTP [ RFC 2616 ] is
extensible. it also explicity says that a Content-location header
can be sent with a Location header [14.30], and it implies that
a Content-type header should be sent with it as well [10.3.x]. it
says nothing about cookies, including what user-agents should do
with cookies during an HTTP redirection.
your claim seems to lack a basis in fact.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Tue, 11 Jul 2000 20:52:31 GMT
From: vpanicker@my-deja.com
Subject: DBI - DBD:Sybase installation problem
Message-Id: <8kg1e7$6pe$1@nnrp1.deja.com>
Hi All,
I have a situation in which i need to connect to and access an SQL
Server 7.0 (serv pack 2) thru a perl application residing on a
different server. I have tried installing DBD:sybase for this, which
led me to install CT Lib. which is a pre-requisit for DBD:Sybase. Now
CT Lib installation requires sybase server to be available on the
server which is running the perl application. This sounds a little
weired(not feasible too). Does anybody know any other option for
achiving this task?
ur inputs will be greatly appreciated.
thanx
vinod
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 11 Jul 2000 20:35:45 GMT
From: mpressnall@my-deja.com
Subject: Drag and Drop files onto Perl Script
Message-Id: <8kg0ev$5ua$1@nnrp1.deja.com>
Hey There --
Is there a way to drag a file onto a perl script (on Win32 platform),
have the perl script recognize the filename of the dropped file, and
then have the script do something to the dropped file?
What would the syntax be?
As it is, I can't even drop files onto a perl script -- it won't allow
me.
If someone has an example of what I am trying to do (via BAT file if
necessary), could they post it?
TIA,
Matt
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 11 Jul 2000 16:51:28 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Drag and Drop files onto Perl Script
Message-Id: <396B88D0.4FDE4F52@attglobal.net>
mpressnall@my-deja.com wrote:
>
> Hey There --
>
> Is there a way to drag a file onto a perl script (on Win32 platform),
> have the perl script recognize the filename of the dropped file, and
> then have the script do something to the dropped file?
>
Thats like asking to drag-drop a text file on a text file. Its not
the way Windows works.
------------------------------
Date: Tue, 11 Jul 2000 23:08:43 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Drag and Drop files onto Perl Script
Message-Id: <e23nmsg88bv7ndgjqi7s97uc6su9r9t6tq@4ax.com>
mpressnall@my-deja.com wrote:
>If someone has an example of what I am trying to do (via BAT file if
>necessary), could they post it?
Er... what Perl?
If ActiveState, check your perl/bin directory for a script called
"PL2BAT.BAT". It's a script on which your can drop a Perl script file,
and get it turned into a BAT file, i.e. a BAT wrapper around the Perl
script.
Too bad that file paths for any file you drop on it, is a short filename
path (i.e. 8.3 format), with no way of getting the nice, long filenames
back.
--
Bart.
------------------------------
Date: Tue, 11 Jul 2000 17:26:52 -0400
From: Brian Horan <bhoran@gate.net>
To: Drew Simonis <care227@attglobal.net>
Subject: Re: Drag and Drop files onto Perl Script
Message-Id: <Pine.A41.4.21.0007111724070.24520-100000@dakota.gate.net>
there is, a program called pl2exe which may help....it's homepage is at:
http://www.dynamicstate.com
~Brian Horan
Systems Analyst/Programmer
Miami Herald Publishing Company bhoran@herald.com
On Tue, 11 Jul 2000, Drew Simonis wrote:
> mpressnall@my-deja.com wrote:
> >
> > Hey There --
> >
> > Is there a way to drag a file onto a perl script (on Win32 platform),
> > have the perl script recognize the filename of the dropped file, and
> > then have the script do something to the dropped file?
> >
>
> Thats like asking to drag-drop a text file on a text file. Its not
> the way Windows works.
>
------------------------------
Date: Tue, 11 Jul 2000 18:49:02 GMT
From: jason iversen <jasoniversen@my-deja.com>
Subject: easy one for xperienced users.. hard for me...
Message-Id: <8kfq6n$tc$1@nnrp1.deja.com>
hi all,
i have two files, A & B. all i want to do is merge the B with the A.
they have the same structure, are text files and are laid out thusly:
...<bof>..
command {
help {
"airbubble: help info"
}
name "airbubble"
label "airbubble"
default "airbubble"
... many more little structures contained by {}
... so fundamentally, this structure is named "airbubble" from the name
clause..
}
.. more of these command{} structures ....
..<eof>.
i just want all the command{} structures in file A to replace (or add if
nonexistant) the same named command{} structures in file B.
any tips or similar code anyone knows about that can help me with this
task? i'd be eternally grateful...
thanks in advance,
--
jason iversen
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 11 Jul 2000 20:56:05 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: easy one for xperienced users.. hard for me...
Message-Id: <396B8A24.7FEE1136@rochester.rr.com>
jason iversen wrote:
>
> hi all,
>
> i have two files, A & B. all i want to do is merge the B with the A.
>
> they have the same structure, are text files and are laid out thusly:
>
> ...<bof>..
>
> command {
> help {
> "airbubble: help info"
> }
> name "airbubble"
> label "airbubble"
> default "airbubble"
>
> ... many more little structures contained by {}
> ... so fundamentally, this structure is named "airbubble" from the name
> clause..
>
> }
>
> .. more of these command{} structures ....
>
> ..<eof>.
>
> i just want all the command{} structures in file A to replace (or add if
> nonexistant) the same named command{} structures in file B.
>
> any tips or similar code anyone knows about that can help me with this
> task? i'd be eternally grateful...
...
> jason iversen
...
Jason, you have not included lots of information that is really
necessary in order to recommend a solution to your problem. Here is a
short list:
1. Are your data files small enough that they can be loaded into
memory? If not, the techniques will differ markedly from the techniques
available if they can comfortably be loaded into memory.
2. Are the data files already sorted by structure name? If so, a merge
technique could be used.
3. What is the maximum nesting depth of braces in your structures?
4. What is your final goal? File C in the same format with the
contents of file B updated by file A?
5. What is syntactically significant in your data? The indentation?
The quotes? The brackets? The whitespace? Lines? Are there blank
lines between "command"'s as hinted at by the blank first line of the
file?
If your files will fit into memory, then put the data from file B into a
hash using the name as the key and the command structure as the value.
Then, using that same hash, run through the same thing with the data in
file A. Any duplicate keys will be replaced with data from file A, and
any new ones will be added. Then run through the hash keys and print
the values to generate an output file. This does not require the files
to be sorted by name. This could be as simple as:
$/=''; #assumes "command"'s separated by null lines
while(<>){
unless(/\n\s*name\s*"([^"]+)"/){next}
$h{$1}=$_;
}
print "\n"; #maintain initial null line
for(keys %h){
print $h{$_};
}
called with:
perl progname.pl fileB fileA >fileC
--
Bob Walton
------------------------------
Date: Tue, 11 Jul 2000 23:35:44 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: easy one for xperienced users.. hard for me...
Message-Id: <4j4nmsguulddtm684ujed29q0r4r4hls4a@4ax.com>
jason iversen wrote:
>i have two files, A & B. all i want to do is merge the B with the A.
>
>they have the same structure, are text files and are laid out thusly:
>
>...<bof>..
>
>command {
> help {
> "airbubble: help info"
> }
> name "airbubble"
> label "airbubble"
> default "airbubble"
>.. more of these command{} structures ....
>i just want all the command{} structures in file A to replace (or add if
>nonexistant) the same named command{} structures in file B.
I can't make a thing out of your explanation, but anyway: using the ".."
operator may probably help you in parsing these files. Something like:
while(<>) {
if(/^(\w+)\s*\{/ .. /^\s*\}/) {
# you're inside such a "structure" definition now
} else {
# bare phrase
}
}
HTH,
Bart.
------------------------------
Date: Tue, 11 Jul 2000 18:11:21 GMT
From: t0873 <t0873@my-deja.com>
Subject: Embedding Logo (images) in Email generated by Perl Script
Message-Id: <8kfnvp$v0q$1@nnrp1.deja.com>
Hello all,
I have email system written in Perl which generates text messages using
Text Template and sends out email. If I want to embed a logo or any gif
in these message , how do I do that. I do not want to attach the GIF
file.
When the user/customer recieves email, it should have logo/gif images
in the body of the email message.
Please help!!!!
Thank a lot in advance!!!
- T
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 11 Jul 2000 18:38:06 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Experienced PERL / CGI programmers needed
Message-Id: <smmqceq6nd679@corp.supernews.com>
Wise TV (admin@wisecommunity.com) wrote:
: Wise Television Limited
It certainly is! I might even say 'Nonexistent'.
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Beauty and strength, leaping laughter and delicious
| languor, force and fire, are of us." - Liber AL II:20
------------------------------
Date: 11 Jul 2000 20:30:09 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Experienced PERL / CGI programmers needed
Message-Id: <slrn8mn0uh.3id.dha@panix2.panix.com>
On Mon, 10 Jul 2000 10:48:52 +0100, Wise TV <admin@wisecommunity.com> wrote:
>Wise Television Limited requires experienced PERL / CGI programmers for
>a variety of contract worl.
You have posted a job posting or a resume in a technical group.
Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.
Had you read and understood the Usenet user manual posted frequently
to "news.announce.newusers", you might have already known this. :)
Please do not explain your posting by saying "but I saw other job
postings here". Just because one person jumps off a bridge, doesn't
mean everyone does. Those postings are also in error, and I've
probably already notified them as well.
If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.
There is a Perl Jobs Announce list that may be more helpful to you. See
<http://www.pm.org/mailing_lists.shtml> for details.
You also have a typo.
Yours for a better usenet,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"...for all you know we're a bunch of malcontents who couldn't get
sci.corned-beef, and are going to reject all the submitted articles
that aren't about corned beef." - Mark-Jason Dominus
------------------------------
Date: Tue, 11 Jul 2000 18:33:54 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How can i know when a string == NULL
Message-Id: <smmq4i39nd636@corp.supernews.com>
Abel Almazan (abel@inlander.es) wrote:
: I want to know when a given string is == null
:
: how can i do it in perl???
Perl has nothing exactly equivalent to 'null' (a pointer to nowhere). You
can use defined() to test whether the string has a defined value, which is
probably the closest analog.
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Beauty and strength, leaping laughter and delicious
| languor, force and fire, are of us." - Liber AL II:20
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 3624
**************************************