[18809] in Perl-Users-Digest
Perl-Users Digest, Issue: 977 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 24 14:10:59 2001
Date: Thu, 24 May 2001 11:10:22 -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: <990727821-v10-i977@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 24 May 2001 Volume: 10 Number: 977
Today's topics:
read jpg newsgroup file <N@b.COM>
Re: read jpg newsgroup file <gerard@NOSPAMlanois.com>
Re: realpath(), abs_path() nobull@mail.com
Search and replace text in a file based on a specific l <drobert@caissepop.mb.ca>
Re: Search and replace text in a file based on a specif <michael@heiming.de>
Re: Search and replace text in a file based on a specif <drobert@caissepop.mb.ca>
Re: Search and replace text in a file based on a specif <drobert@caissepop.mb.ca>
Re: Sorting data file on numerical field <vmurphy@Cisco.Com>
sounder <todd@designsouth.net>
Re: sounder <tinamue@zedat.fu-berlin.de>
Re: sounder <todd@designsouth.net>
Re: sounder <tinamue@zedat.fu-berlin.de>
Re: sounder <thunderbear@bigfoot.com>
Re: sounder <buggs@geekmail.de>
Win32::OLE -> How to query a Microsoft Catalog (Jean-Paul Cozzatti)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 24 May 2001 13:50:57 GMT
From: "mk" <N@b.COM>
Subject: read jpg newsgroup file
Message-Id: <5l8P6.4658$%X5.1442600@typhoon1.ba-dsg.net>
I am trying to use perl to download jpgs from usenet. I've been using
Net::NNTP on a W32 machine and have hit a snag. most of these messages seem
to be in the format:
BEGIN picturename.jpg
...many lines of junk that Outlook automatically translates into image...
END
Any help would be greatly appreciated. Thanks in advance. I assure you
that I am using this for good.
-Mike
------------------------------
Date: 24 May 2001 09:47:34 -0700
From: Gerard Lanois <gerard@NOSPAMlanois.com>
Subject: Re: read jpg newsgroup file
Message-Id: <u66eqy9qx.fsf@NOSPAMlanois.com>
"mk" <N@b.COM> writes:
> I am trying to use perl to download jpgs from usenet. I've been using
> Net::NNTP on a W32 machine and have hit a snag. most of these messages seem
> to be in the format:
>
> BEGIN picturename.jpg
> ...many lines of junk that Outlook automatically translates into image...
> END
>
> Any help would be greatly appreciated. Thanks in advance. I assure you
> that I am using this for good.
>
> -Mike
Been there, done that.
http://ubh.sourceforge.net/
-Gerard
http://www.lanois.com/perl/
------------------------------
Date: 24 May 2001 17:55:46 +0100
From: nobull@mail.com
Subject: Re: realpath(), abs_path()
Message-Id: <u9itiq660d.fsf@wcl-l.bham.ac.uk>
/dev/null <postmaster@god.edu> writes:
> Last year I wrote a realpath() function in Perl. Recently I discovered
> Cwd::abs_path(). When I tried to use it, I discovered that abs_path()
> barfs if its argument is not a directory. This is more than mildly
> annoying.
Indeed it is, much more. It is also a big clue that what you are
attempting to do is probably something you would probably be better
off not doing.
> Did the author(s) of abs_path() not see value in being able to feed
> the function something like "/var/mail/extasia" and get back
> "/var/spool/mail/extasia"?
Those look like Unix paths to me.
> Am I missing something?
In Unix unique absolute path as a concept only actually applies to
directories.
Anyhow, you say "Did the authors not see value?". What do _you_ see
as the value? Think carefully. I have in the past found myself
instictively wanting (and even inplementing) your realpath() function
(not just in Perl) and then realised, on refelction, that my instinct
is wrong.
> Does there exist in Perl a function to do an absolute (or "real")
> path on a given path representing *any* type of file?
The nearest I know is rel2abs() in File::Spec but it doesn't do exactly
what you want.
> If not, should I submit my realpath() function?
I think you should show it here first.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 24 May 2001 10:08:12 -0500
From: "Daniel Robert" <drobert@caissepop.mb.ca>
Subject: Search and replace text in a file based on a specific line
Message-Id: <xx9P6.3673$gg2.38665@news1.mts.net>
I want to create a sh script to do the following:
1) find in the file the specified search string
2) replace from the specified text (allowing for the "?" wirdcard) and
replacing it with the sullied text. Note that only the "?" will be assumed
a wildcard and the assumtion is also made that no "?" as a regular
character, ie the "?" is always a wildcard in this parameter.
The command would have the following sytax:
replinfile filename search replacefrom replaceto
For example if I started with the following file called "testfile":
-------------------------------------
This is test #21****line 5
Another test #ab****line 6
Second last test #xyz****line 7
Last test #&&****line 8
-------------------------------------
After running the following commands:
replinfile testfile "line 6" "test #??" "test #www"
replinfile testfile "line 8" "test #???" test #xx"
replinfile testfile "line 5" "test #??" "test #yy"
replinfile testfile "line 7" "test #???" "test #zz"
The "testfile" file should look like this:
-------------------------------------
This is test #yy****line 5
Another test #www****line 6
Second last test #zz****line 7
Last test #xx***line 8
-------------------------------------
I tried looking at sed to do this but was not able to find a way to take
advantage of wildcard caracters. What would be the most effecient and less
complicated (if there is such an animal which complies to both)? Would it
be awk, sed, ed, perl, etc?
------------------------------
Date: Thu, 24 May 2001 19:10:11 +0200
From: Michael Heiming <michael@heiming.de>
Subject: Re: Search and replace text in a file based on a specific line
Message-Id: <3B0D4073.DBD8A3F2@heiming.de>
Daniel Robert wrote:
>
> I want to create a sh script to do the following:
> 1) find in the file the specified search string
> 2) replace from the specified text (allowing for the "?" wirdcard) and
> replacing it with the sullied text. Note that only the "?" will be assumed
> a wildcard and the assumtion is also made that no "?" as a regular
> character, ie the "?" is always a wildcard in this parameter.
>
> The command would have the following sytax:
> replinfile filename search replacefrom replaceto
>
> For example if I started with the following file called "testfile":
> -------------------------------------
> This is test #21****line 5
> Another test #ab****line 6
> Second last test #xyz****line 7
> Last test #&&****line 8
> -------------------------------------
> After running the following commands:
> replinfile testfile "line 6" "test #??" "test #www"
> replinfile testfile "line 8" "test #???" test #xx"
> replinfile testfile "line 5" "test #??" "test #yy"
> replinfile testfile "line 7" "test #???" "test #zz"
> The "testfile" file should look like this:
> -------------------------------------
> This is test #yy****line 5
> Another test #www****line 6
> Second last test #zz****line 7
> Last test #xx***line 8
> -------------------------------------
>
> I tried looking at sed to do this but was not able to find a way to take
> advantage of wildcard caracters. What would be the most effecient and less
> complicated (if there is such an animal which complies to both)? Would it
> be awk, sed, ed, perl, etc?
Hello,
there is no awk/perl needed, sed can do that.
grep "line 6" testfile | sed 's/test\ \#../test\ \#www/g'
Another test #www****line 6
I'm sure you can figure out, how to put some variables in a script
around this. There is no animal, it's called regular expressions.
Good luck
Michael Heiming
------------------------------
Date: Thu, 24 May 2001 12:29:52 -0500
From: "Daniel Robert" <drobert@caissepop.mb.ca>
Subject: Re: Search and replace text in a file based on a specific line
Message-Id: <lCbP6.3687$gg2.38855@news1.mts.net>
I will try that out.
PS: The "animal" I was refering to was the "less complicated".
"Michael Heiming" <michael@heiming.de> wrote in message
news:3B0D4073.DBD8A3F2@heiming.de...
> Daniel Robert wrote:
> >
> > I want to create a sh script to do the following:
> > 1) find in the file the specified search string
> > 2) replace from the specified text (allowing for the "?" wirdcard) and
> > replacing it with the sullied text. Note that only the "?" will be
assumed
> > a wildcard and the assumtion is also made that no "?" as a regular
> > character, ie the "?" is always a wildcard in this parameter.
> >
> > The command would have the following sytax:
> > replinfile filename search replacefrom replaceto
> >
> > For example if I started with the following file called "testfile":
> > -------------------------------------
> > This is test #21****line 5
> > Another test #ab****line 6
> > Second last test #xyz****line 7
> > Last test #&&****line 8
> > -------------------------------------
> > After running the following commands:
> > replinfile testfile "line 6" "test #??" "test #www"
> > replinfile testfile "line 8" "test #???" test #xx"
> > replinfile testfile "line 5" "test #??" "test #yy"
> > replinfile testfile "line 7" "test #???" "test #zz"
> > The "testfile" file should look like this:
> > -------------------------------------
> > This is test #yy****line 5
> > Another test #www****line 6
> > Second last test #zz****line 7
> > Last test #xx***line 8
> > -------------------------------------
> >
> > I tried looking at sed to do this but was not able to find a way to take
> > advantage of wildcard caracters. What would be the most effecient and
less
> > complicated (if there is such an animal which complies to both)? Would
it
> > be awk, sed, ed, perl, etc?
>
> Hello,
>
> there is no awk/perl needed, sed can do that.
>
> grep "line 6" testfile | sed 's/test\ \#../test\ \#www/g'
> Another test #www****line 6
>
> I'm sure you can figure out, how to put some variables in a script
> around this. There is no animal, it's called regular expressions.
>
> Good luck
>
> Michael Heiming
------------------------------
Date: Thu, 24 May 2001 12:44:28 -0500
From: "Daniel Robert" <drobert@caissepop.mb.ca>
Subject: Re: Search and replace text in a file based on a specific line
Message-Id: <0QbP6.3689$gg2.39027@news1.mts.net>
Upon looking at it carefully, I noticed that the file does not get modified.
The original file must containt the original lines but with the changes we
specified. This is where I had difficulty to start with.
"Michael Heiming" <michael@heiming.de> wrote in message
news:3B0D4073.DBD8A3F2@heiming.de...
> Daniel Robert wrote:
> >
> > I want to create a sh script to do the following:
> > 1) find in the file the specified search string
> > 2) replace from the specified text (allowing for the "?" wirdcard) and
> > replacing it with the sullied text. Note that only the "?" will be
assumed
> > a wildcard and the assumtion is also made that no "?" as a regular
> > character, ie the "?" is always a wildcard in this parameter.
> >
> > The command would have the following sytax:
> > replinfile filename search replacefrom replaceto
> >
> > For example if I started with the following file called "testfile":
> > -------------------------------------
> > This is test #21****line 5
> > Another test #ab****line 6
> > Second last test #xyz****line 7
> > Last test #&&****line 8
> > -------------------------------------
> > After running the following commands:
> > replinfile testfile "line 6" "test #??" "test #www"
> > replinfile testfile "line 8" "test #???" test #xx"
> > replinfile testfile "line 5" "test #??" "test #yy"
> > replinfile testfile "line 7" "test #???" "test #zz"
> > The "testfile" file should look like this:
> > -------------------------------------
> > This is test #yy****line 5
> > Another test #www****line 6
> > Second last test #zz****line 7
> > Last test #xx***line 8
> > -------------------------------------
> >
> > I tried looking at sed to do this but was not able to find a way to take
> > advantage of wildcard caracters. What would be the most effecient and
less
> > complicated (if there is such an animal which complies to both)? Would
it
> > be awk, sed, ed, perl, etc?
>
> Hello,
>
> there is no awk/perl needed, sed can do that.
>
> grep "line 6" testfile | sed 's/test\ \#../test\ \#www/g'
> Another test #www****line 6
>
> I'm sure you can figure out, how to put some variables in a script
> around this. There is no animal, it's called regular expressions.
>
> Good luck
>
> Michael Heiming
------------------------------
Date: 24 May 2001 09:08:13 -0400
From: Vinny Murphy <vmurphy@Cisco.Com>
Subject: Re: Sorting data file on numerical field
Message-Id: <m3snhu28ua.fsf@vpnrel.cisco.com>
usenet@cox99.screaming.net (Graham Cox) writes:
> Tony Curtis <tony_curtis32@yahoo.com> wrote in message news:<87heycki6k.fsf@limey.hpcc.uh.edu>...
>
> > Well, it's rather difficult without seeing any code (hint)
>
> Sorry - My mistake. The code I've got so far is at the end of this
> post. I've also tried the code Vinny posted, but i I couldn't get that
> to work either :(
> The datafile "test.txt" contains exactly what I posted last time.
>
>
> #!/usr/bin/perl
> print "Content-type:text/html\n\n";
> print "<html>";
> print "<body>";
>
> open (FILE, "< test.txt") or die("File not Found");
> {
> local $/="\|";
> @spare=<FILE>;
> }
>
<... snip ...>
> my @teamdetails;
> foreach $sortres(@sorted)my @r = ();
You should be looking at it as a reference to an array.
push(@r,[ split '\|' ]) while <DATA>;
print "<th>Name</th><th>c1</th><th>c2</th><th>c3</th><th>c3</th><th>c5</th>\n";
# walk thru each reference to array...
foreach my $ra ( sort { $a->[5] <=> $b->[5] } @r ) {
chomp @$ra;
print " <tr>\n";
print map " <td>$_</td>\n" => @$ra;
print " </tr>\n";
}
HTH.
--
Vinny
------------------------------
Date: Thu, 24 May 2001 14:26:13 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: sounder
Message-Id: <9S8P6.64803$I5.13997346@news1.rdc1.tn.home.com>
I always thought that it would be cool, once I come up with my brilliant
internet idea, to have something on my computer beep every time a user signs
up. So that would involve my browser being on a certain page, and every time
a script on the server is run, somehow the page I'm on is asked to beep for
me.
Is there a way to do that?
------------------------------
Date: 24 May 2001 15:00:10 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: sounder
Message-Id: <9ej7lq$37cl9$3@fu-berlin.de>
Todd Smith <todd@designsouth.net> wrote:
> I always thought that it would be cool, once I come up with my brilliant
> internet idea, to have something on my computer beep every time a user signs
> up. So that would involve my browser being on a certain page, and every time
> a script on the server is run, somehow the page I'm on is asked to beep for
> me.
> Is there a way to do that?
what's your perl question? how to let the computer beep?
try
print chr 7;
hth,tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: Thu, 24 May 2001 15:14:49 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: sounder
Message-Id: <Jz9P6.65121$I5.14020323@news1.rdc1.tn.home.com>
"Tina Mueller" <tinamue@zedat.fu-berlin.de> wrote in message
news:9ej7lq$37cl9$3@fu-berlin.de...
> Todd Smith <todd@designsouth.net> wrote:
> > I always thought that it would be cool, once I come up with my brilliant
> > internet idea, to have something on my computer beep every time a user
signs
> > up. So that would involve my browser being on a certain page, and every
time
> > a script on the server is run, somehow the page I'm on is asked to beep
for
> > me.
>
> > Is there a way to do that?
>
> what's your perl question? how to let the computer beep?
> try
> print chr 7;
>
Well, since Perl is the only cgi language I know, I'd like to see the Perl
implementation of the complete solution.
-todd
------------------------------
Date: 24 May 2001 15:24:57 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: sounder
Message-Id: <9ej949$37cl9$5@fu-berlin.de>
Todd Smith <todd@designsouth.net> wrote:
> "Tina Mueller" <tinamue@zedat.fu-berlin.de> wrote in message
> news:9ej7lq$37cl9$3@fu-berlin.de...
>> Todd Smith <todd@designsouth.net> wrote:
>> > I always thought that it would be cool, once I come up with my brilliant
>> > internet idea, to have something on my computer beep every time a user
> signs
>> > up. So that would involve my browser being on a certain page, and every
> time
>> > a script on the server is run, somehow the page I'm on is asked to beep
> for
>> > me.
>>
>> > Is there a way to do that?
>>
>> what's your perl question? how to let the computer beep?
>> try
>> print chr 7;
> Well, since Perl is the only cgi language I know, I'd like to see the Perl
> implementation of the complete solution.
well, although i didn't really understand, what you want to achieve,
i wish you good luck.
if you want help, explain what you mean by
"user signs up", "the page is asked to beep". and you might want to
do that in the appropriate newsgroup for cgi. for certain
perl questions, you are welcome to ask here.
regards,
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: Thu, 24 May 2001 17:44:00 +0100
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: sounder
Message-Id: <3B0D3A50.3B067706@bigfoot.com>
Todd Smith wrote:
> Well, since Perl is the only cgi language I know, I'd like to see the Perl
> implementation of the complete solution.
Hack the "user sign up" script to send you an email.
--
Thorbjørn Ravn Andersen "...plus...Tubular Bells!"
http://bigfoot.com/~thunderbear
------------------------------
Date: Thu, 24 May 2001 19:18:24 +0200
From: buggs <buggs@geekmail.de>
Subject: Re: sounder
Message-Id: <9ejfov$kdb$00$1@news.t-online.com>
Todd Smith wrote:
>
> "Tina Mueller" <tinamue@zedat.fu-berlin.de> wrote in message
> news:9ej7lq$37cl9$3@fu-berlin.de...
>> Todd Smith <todd@designsouth.net> wrote:
>> > I always thought that it would be cool, once I come up with my
>> > brilliant internet idea, to have something on my computer beep every
>> > time a user
> signs
>> > up. So that would involve my browser being on a certain page, and every
> time
>> > a script on the server is run, somehow the page I'm on is asked to beep
> for
>> > me.
>>
>> > Is there a way to do that?
That's fairly easy.
You just implement the Server-Push thingies of HTTP/1.1
for your webserver and your browser.
Mail me if you try.
>
> Well, since Perl is the only cgi language I know, I'd like to see the Perl
> implementation of the complete solution.
>
> -todd
You can use nearly any computer language for CGI's.
Buggs
------------------------------
Date: 24 May 2001 10:47:30 -0700
From: jcozzatti@cozzatti.com (Jean-Paul Cozzatti)
Subject: Win32::OLE -> How to query a Microsoft Catalog
Message-Id: <31f3f729.0105240947.23c9e5b3@posting.google.com>
Hi PerlPeople:
I'm using activestate perl v5.6.1 build 626 on windows 2k to query a
microsoft catalog (i.e. a catalog created by the microsoft indexing
service)
I would like to get some perl hooks into it so I can play with the
index.
Right now I'm getting the error I've included.
My questions are:
1)What's causing the error...it looks related to the here-document
like coding.
2)Is there a better way to do this using DBI::ADO...or another perl
module.
Here is my code. It's mostly kludged together from the sources that
follow:
>>-------------<<
>> THE CODE: <<
>>-------------<<
#!/usr/local/bin/perl
use strict;
use Win32::OLE;
use Win32::OLE::Const ;
my $Conn = Win32::OLE->new('ADODB.Connection'); # creates a connection
object
my $RS = Win32::OLE->new('ADODB.Recordset'); # creates a recordset
object
$Conn->Open('provider=msidxs'); # opens the database
connection
if (Win32::OLE->LastError) {
$RS->Open(>>"SQL",$Conn, adOpenDynamic);
select Filename from SCOPE(milcker)
SQL
print "This didn't go well: ", Win32::OLE->LastError(), "\n" if
(Win32::OLE->LastError());
$RS->Close;
$Conn->Close;
Here is the error I'm getting:
>>-------------<<
>> THE ERROR: <<
>>-------------<<
C:\perl_try>dbconnect.pl
Bareword found where operator expected at C:\perl_try\dbconnect.pl
line
")
SQL"
(Missing operator before SQL?)
syntax error at C:\perl_try\dbconnect.pl line 11, near "(>>"
syntax error at C:\perl_try\dbconnect.pl line 16, near ")
SQL
"
Execution of C:\perl_try\dbconnect.pl aborted due to compilation error
>>-------------<<
>> REFERENCES: <<
>>-------------<<
http://aspn.activestate.com/ASPN/Reference/Products/ActivePerl/faq/Windows/ActivePerl-Winfaq12.html#use_ado
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';
my $Connection = Win32::OLE->new('ADODB.Connection');
my $Recordset = Win32::OLE->new('ADODB.Recordset');
$Connection->Open('T-Bonds');
# Open a record set for the table of this contract
{
local $Win32::OLE::Warn = 0;
$Recordset->Open($Contract, $Connection, adOpenKeyset,
adLockOptimistic, adCmdTable);
}
# Create table and index if it doesn't exist yet
if (Win32::OLE->LastError) {
$Connection->Execute(>>"SQL");
CREATE TABLE $Contract
(
Day DATETIME,
Open DOUBLE, High DOUBLE, Low DOUBLE, Close DOUBLE
)
SQL
$Connection->Execute(>>"SQL");
CREATE INDEX $Contract
ON $Contract (Day) WITH PRIMARY
SQL
$Recordset->Open($Contract, $Connection, adOpenKeyset,
adLockOptimistic, adCmdTable);
}
$Win32::
This is the ASP way to do things:
http://msdn.microsoft.com/library/default.asp?URL=/library/partbook/asp20/howindexserverworks.htm
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 977
**************************************