[17929] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 89 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 18 11:05:39 2001

Date: Thu, 18 Jan 2001 08:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979833909-v10-i89@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 18 Jan 2001     Volume: 10 Number: 89

Today's topics:
    Re: bidirectional communication using sockets mmustafa@my-deja.com
    Re: change unlink() to delete() (was Re: rename functio (Rand Simberg)
        Command line switch (-s) <ccx138@coventry.ac.uk>
    Re: Command line switch (-s) (Anno Siegel)
    Re: Command line switch (-s) (Rafael Garcia-Suarez)
    Re: Command line switch (-s) <ccx138@coventry.ac.uk>
    Re: Command line switch (-s) (Tad McClellan)
    Re: Command line switch (-s) (Tad McClellan)
    Re: Command line switch (-s) <ccx138@coventry.ac.uk>
        Converting single quoted string to double quoted string <pricesteve@yahoo.com>
        Event Loops and Sockets kgenus@earthlink.net
    Re: excel to csv tools (John McNamara)
    Re: FAQ 9.10:   How do I redirect to another page? <flavell@mail.cern.ch>
        How can I extract strings from a Perl program? <shimon@photonet.com>
        isInNet() function snval0@my-deja.com
    Re: need help with (?...) (Mike Stok)
    Re: novice perl programmer w/ errors <ccx138@coventry.ac.uk>
    Re: novice perl programmer w/ errors piequals3@my-deja.com
    Re: passing parameters from command line? <ccx138@coventry.ac.uk>
        Pattern Matching Problem <cmon_209@hotmail.com>
    Re: Problem modifying binary file twolfmaier@acm.org
    Re: Pulling KEy out of hash (Garry Williams)
        Redirect question <jons1@lineone.net>
        Remove entire line from text file <jed@linuxbuilt./*no_spam*/.com>
    Re: Remove entire line from text file <ccx138@coventry.ac.uk>
    Re: Remove entire line from text file <jed@linuxbuilt./*no_spam*/.com>
    Re: Saving .htm file to disk from CGI script dtbaker_dejanews@my-deja.com
    Re: Win32 distr. missing files: <randy@theoryx5.uwinnipeg.ca>
        Win32::LookupAccountSID documentation? nobull@mail.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 18 Jan 2001 14:10:39 GMT
From: mmustafa@my-deja.com
Subject: Re: bidirectional communication using sockets
Message-Id: <946tgm$492$1@nnrp1.deja.com>

Thanks for your inputs guys. Not to be ungreatfull, but this doesn't
help much :)

Farooq



In article <zBd96.66611$xW4.520418@news-server.bigpond.net.au>,
  "John Boy Walton" <johngros.NOSPAM@bigpond.net.au> wrote:
>
> "Bart Lateur" <bart.lateur@skynet.be> wrote in message
> news:ois96tcmqhvk1feg02bp6usenh2j353rl6@4ax.com...
> > John Boy Walton wrote:
> >
> > >>    I am trying to write a PERL program using sockets. One side (
which
> > >> we call client ) is communicating with the listener ( which we
call
> > >> server)
> > >The server serves and the client 'listens', you have them around
the
> wrong
> > >way.
> >
> > Really? Hmmm... the client is the one that initiates communication,
a
> > server is the one that responds to it.
> Gunned down by Bad Bart again!
> I guess I find a new way to be wrong every day.
> Hopefully some day I will run out of ways ;-)
>
>


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Thu, 18 Jan 2001 14:18:13 GMT
From: simberg.interglobal@trash.org (Rand Simberg)
Subject: Re: change unlink() to delete() (was Re: rename function in CGI script?)
Message-Id: <3a69faa8.70600448@nntp.ix.netcom.com>

On Thu, 18 Jan 2001 14:01:16 GMT, in a place far, far away,
tadmc@augustmail.com (Tad McClellan) made the phosphor on my monitor
glow in such a way as to indicate that:

>Your cutsie attribution string is too long.

Sorry.

>>Is
>>there some reason they couldn't have a mention of delete when it came
>>to "file" in the index of the book?  ;-)
>                           ^^^^^^^^
>
>There are hundreds of Perl books. Care to narrow it down to
>a particular book?

In my initial post in the thread, I said the 1992 edition of the Camel
book.

>I think the docs can be improved by either:
>
>   a FAQ: "How do I delete a file"
>
>   (including a brief description of what a "link" is)
>
>or adding to
>
>   perldoc -f delete
>
>   "If you are looking for a function to delete I<files> then
>    see L</unlink>."
>
>
>I think the question comes up enough that the docs should be
>updated. I'll submit a patch for the second one when I get 
>some tuits.

Thanks...

************************************************************************
simberg.interglobal.org  * 310 372-7963 (CA) 307 739-1296 (Jackson Hole)  
interglobal space lines  * 307 733-1715 (Fax) http://www.interglobal.org 

"Extraordinary launch vehicles require extraordinary markets..."
Replace first . with @ and throw out the "@trash." to email me.  
Here's my email address for autospammers: postmaster@fbi.gov


------------------------------

Date: Thu, 18 Jan 2001 14:29:57 +0000
From: John Tutchings <ccx138@coventry.ac.uk>
Subject: Command line switch (-s)
Message-Id: <3A66FDE5.EF608CC2@coventry.ac.uk>

Does anyone know of problems passing in command line switches and using
"use strict".

myscript -camel

This one works
    #!/usr/bin/perl -s

    if ($camel){print "How many humps\n";}

This one does not
    #!/usr/bin/perl -s
    use strict;

    my($camel);
    if ($camel){print "How many humps\n";}

Any ideas, the camel books just say that it works.



------------------------------

Date: 18 Jan 2001 15:12:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Command line switch (-s)
Message-Id: <94714l$28c$1@mamenchi.zrz.TU-Berlin.DE>

John Tutchings  <ccx138@coventry.ac.uk> wrote in comp.lang.perl.misc:
>Does anyone know of problems passing in command line switches and using
>"use strict".
>
>myscript -camel
>
>This one works
>    #!/usr/bin/perl -s
>
>    if ($camel){print "How many humps\n";}
>
>This one does not
>    #!/usr/bin/perl -s
>    use strict;
>
>    my($camel);
>    if ($camel){print "How many humps\n";}
>
>Any ideas, the camel books just say that it works.

Well, obviously the -s switch deposits a 1 in the package variable
$main::camel, if the script is called with "-camel".  This is
distinct from the lexical you declare with "my $camel".  If there
is a lexical variable and a package variable with the same name,
Perl prefers the lexical one, so that is the one you talk about
in the "if".  Of course, it is undefined.

To get the expected behavior under strict, you must declare the
package variable, (with "use vars $camel" in older Perls, alternatively
"our $camel" in newer ones), or use the fully qualified "$main::camel".

In any case, the Getopt:: modules do a far better job of switch
processing, so -s is probably obsolescent.  There's not much need
to worry about its behavior.

Anno


------------------------------

Date: Thu, 18 Jan 2001 15:39:39 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Command line switch (-s)
Message-Id: <slrn96e3ig.m6b.rgarciasuarez@rafael.kazibao.net>

Anno Siegel wrote in comp.lang.perl.misc:
> 
> In any case, the Getopt:: modules do a far better job of switch
> processing, so -s is probably obsolescent.  There's not much need
> to worry about its behavior.

Cool! I wasn't aware of this switch. An obsolescent and seldom used
feature. Ideal for japhs.

perl -sleprint -- -_='Just another Perl hacker,'

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


------------------------------

Date: Thu, 18 Jan 2001 15:30:20 +0000
From: John Tutchings <ccx138@coventry.ac.uk>
Subject: Re: Command line switch (-s)
Message-Id: <3A670C0C.DC59D4A2@coventry.ac.uk>

 .
The use vars $camel and the our $camel did not work, I'm off to have a look
at the getopts.Cheers.

Anno Siegel wrote:

> John Tutchings  <ccx138@coventry.ac.uk> wrote in comp.lang.perl.misc:
> >Does anyone know of problems passing in command line switches and using
> >"use strict".
> >
> >myscript -camel
> >
> >This one works
> >    #!/usr/bin/perl -s
> >
> >    if ($camel){print "How many humps\n";}
> >
> >This one does not
> >    #!/usr/bin/perl -s
> >    use strict;
> >
> >    my($camel);
> >    if ($camel){print "How many humps\n";}
> >
> >Any ideas, the camel books just say that it works.
>
> Well, obviously the -s switch deposits a 1 in the package variable
> $main::camel, if the script is called with "-camel".  This is
> distinct from the lexical you declare with "my $camel".  If there
> is a lexical variable and a package variable with the same name,
> Perl prefers the lexical one, so that is the one you talk about
> in the "if".  Of course, it is undefined.
>
> To get the expected behavior under strict, you must declare the
> package variable, (with "use vars $camel" in older Perls, alternatively
> "our $camel" in newer ones), or use the fully qualified "$main::camel".
>
> In any case, the Getopt:: modules do a far better job of switch
> processing, so -s is probably obsolescent.  There's not much need
> to worry about its behavior.
>
> Anno



------------------------------

Date: Thu, 18 Jan 2001 15:44:49 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Command line switch (-s)
Message-Id: <slrn96dss7.50s.tadmc@tadmc26.august.net>

John Tutchings <ccx138@coventry.ac.uk> wrote:

>Does anyone know of problems passing in command line switches and using
>"use strict".


No. I know of problems related to not understanding the answer
to the Perl FAQ below though  :-)

   "What's the difference between dynamic and lexical (static) scoping?  
    Between local() and my()?"


>myscript -camel
>
>This one works
>    #!/usr/bin/perl -s
>
>    if ($camel){print "How many humps\n";}


$camel is a dynamic variable there.


>This one does not
>    #!/usr/bin/perl -s
>    use strict;
>
>    my($camel);
>    if ($camel){print "How many humps\n";}


$camel is a lexical variable there.


>Any ideas, the camel books just say that it works.

The -s switch uses a dynamic variable. You must do one of the
things that will satisfy "use strict":

   our $camel;   # requires 5.6

or

   use vars qw/$camel/;

or

   if ($main::camel){print "How many humps\n";}

or

   if ($::camel){print "How many humps\n";}


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Thu, 18 Jan 2001 15:54:05 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Command line switch (-s)
Message-Id: <slrn96dtjh.529.tadmc@tadmc26.august.net>

John Tutchings <ccx138@coventry.ac.uk> wrote:
>.
>The use vars $camel and the our $camel did not work, 


Then you have a broken perl installation!

(or you have used them incorrectly)

Show us your "use vars" code that does not work (after reading
the output from typing:   perldoc vars   ).


>Anno Siegel wrote:
>
>> John Tutchings  <ccx138@coventry.ac.uk> wrote in comp.lang.perl.misc:
>> >Does anyone know of problems passing in command line switches and using
>> >"use strict".

>> >    #!/usr/bin/perl -s

>> >    my($camel);
>> >    if ($camel){print "How many humps\n";}

[snip]

>> To get the expected behavior under strict, you must declare the
>> package variable, (with "use vars $camel" in older Perls, alternatively
>> "our $camel" in newer ones), or use the fully qualified "$main::camel".


Those must _all_ (except our() in pre-5.6 perls) work.

If they are not working, then you have found a bug in perl (not
too likely). Show us your code and we will help you fix it.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Thu, 18 Jan 2001 15:52:52 +0000
From: John Tutchings <ccx138@coventry.ac.uk>
Subject: Re: Command line switch (-s)
Message-Id: <3A671154.E52AD164@coventry.ac.uk>

use vars qw/$camel/; works a treat. Cheers.

Tad McClellan wrote:

> John Tutchings <ccx138@coventry.ac.uk> wrote:
>
> >Does anyone know of problems passing in command line switches and using
> >"use strict".
>
> No. I know of problems related to not understanding the answer
> to the Perl FAQ below though  :-)
>
>    "What's the difference between dynamic and lexical (static) scoping?
>     Between local() and my()?"
>
> >myscript -camel
> >
> >This one works
> >    #!/usr/bin/perl -s
> >
> >    if ($camel){print "How many humps\n";}
>
> $camel is a dynamic variable there.
>
> >This one does not
> >    #!/usr/bin/perl -s
> >    use strict;
> >
> >    my($camel);
> >    if ($camel){print "How many humps\n";}
>
> $camel is a lexical variable there.
>
> >Any ideas, the camel books just say that it works.
>
> The -s switch uses a dynamic variable. You must do one of the
> things that will satisfy "use strict":
>
>    our $camel;   # requires 5.6
>
> or
>
>    use vars qw/$camel/;
>
> or
>
>    if ($main::camel){print "How many humps\n";}
>
> or
>
>    if ($::camel){print "How many humps\n";}
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas



------------------------------

Date: Thu, 18 Jan 2001 15:53:51 -0000
From: "pricesteve" <pricesteve@yahoo.com>
Subject: Converting single quoted string to double quoted string
Message-Id: <mpE96.1394$jr.10928@news2-hme0>

I have a variable
$fred = 'Two lines\nof text';
returned from a T-SQL query using DBI::ODBC
I need to print this as if it was double quoted
ie $fred="two lines\nof text";
print $fred; #prints without expanding the \n
print "$fred"; #prints without expanding the \n

any suggestions as to how to convert this single quoted string as returned
by my
SELECT statement into a double quoted string that will allow \n and
$varnames to be interpolated??

Regards




------------------------------

Date: Thu, 18 Jan 2001 15:46:44 GMT
From: kgenus@earthlink.net
Subject: Event Loops and Sockets
Message-Id: <947351$9mg$1@nnrp1.deja.com>

I need to write an engine to listen to a port and
respond to events that I send it from a client.  I
am wondering what additional ways I can do this
instead of using the IO::Socket API (which I need
to know more about).  I have all of my engine
completed, but the code is piece mill and there
just has to be a better way to write it ... or
some EventLoop based modules already written. Any
help would be great.

Kevin


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Thu, 18 Jan 2001 15:22:13 GMT
From: jmcnamara@cpan.org (John McNamara)
Subject: Re: excel to csv tools
Message-Id: <3a670936.7657661@News.CIS.DFN.DE>

Ar Wed, 17 Jan 2001 19:49:44 GMT, do schriobh rbfitzpa@my-deja.com:
>I've seen some perl tools in the past which convert excel spreadsheets
>to csv delimited text files, does anyone know where I can find them and
>or any documentation?

I don't think that there is any tool that does this directly. Have a
look at Win32::OLE, Spreadsheet::ParseExcel or DBI with DBD::ADO or
DBD::ODBC.

John McNamara
-- 
"Something tells me we aren't programming in Pascal anymore, Toto."




------------------------------

Date: Thu, 18 Jan 2001 16:12:46 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: FAQ 9.10:   How do I redirect to another page?
Message-Id: <Pine.LNX.4.30.0101181609580.3033-100000@lxplus003.cern.ch>

On 18 Jan 2001, Anno Siegel wrote:

> >writing some new text based on some very helpful discussions here with
> >the regulars, it seemed to fly like a lead balloon when I tried to
> >raise it with the Perlbugs folks, so I got dispirited.
>
> Don't be.  In my experience doc patches are silently incorporated
> in one release or another (not necessarily the earliest possible).

Thanks, that was a helpful response.  I'm afraid I blasted off in a
rather negative frame of mind yesterday.

Maybe I _will_ try opening a doc bug on the other issues, and see how
it goes.

cheers



------------------------------

Date: Thu, 18 Jan 2001 16:56:01 +0200
From: "Shimon Bollinger" <shimon@photonet.com>
Subject: How can I extract strings from a Perl program?
Message-Id: <3a670418@news.bezeqint.net>

I would like to extract all the strings from a Perl program.  I need to take
into account all the various ways of quoting strings (' " qw q qq << etc.)
as well as embedded quotes.

Does anyone know of a module that can do this?

Thanks,
Shimon




------------------------------

Date: Thu, 18 Jan 2001 15:14:10 GMT
From: snval0@my-deja.com
Subject: isInNet() function
Message-Id: <94717q$7oh$1@nnrp1.deja.com>

Hi,

I would like to know if there is a function in Perl what can detect if
an IP address belongs to a certain IP address range?
In JavaScript it looks like this:

if (isInNet(myIpAddress(), "123.123.123.0", "255.255.252.0"))
{
<do something>
}

Thanks,
Fred.


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Thu, 18 Jan 2001 15:38:11 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: need help with (?...)
Message-Id: <D5E96.5466$Le2.204253@typhoon.austin.rr.com>

In article <3A669B5B.B33A565@cadence.com>,
Amit K Mathur  <amitk@cadence.com> wrote:
>I am trying to parse a design exchange text file.

[...]

>$hierdel = "\\$1"; # $hierdel contains a backslash followed by 
>                   # actual HIER_DELIMITER character.
> ...
> ...
>
>$component_name =~ s/$hierdel/|/g;
>
>
>Now my actual problem:
>the HIER_DELIMITER character may be a metacharcter 
>of regexp( \ | ( ) [ { ^ $ * + ? .) or it may not be. if it is one
>of metachars, it needs to be escaped in $hierdel. if it is not, it
>*should* not
>be. because a non-metacharacter, if escaped, may acquire a special 
>meaning (eg. a, A, b, B, n and numerous others). i can use a "switch"
>statement
>and selectively escape the HIER_DELIMITER, but it will be 
>kind of less incorrect than present solution but still incorrect --
>if another metacharacter is later added to the dirty 
>dozen (set of metacharacters), the switch code will break.
>
>so what is the solution??
>is there a metasymbol of (?...) family which does what i want. i.e.
>takes 
>what ever is inside the bracket in place of "..." *literally*.
>or is there any other *elegent* solution ....?

Are you aware of quotemeta?

bash$ perldoc -tf quotemeta
    quotemeta EXPR
    quotemeta
            Returns the value of EXPR with all non-alphanumeric characters
            backslashed. (That is, all characters not matching `/[A-Za-z_0-
            9]/' will be preceded by a backslash in the returned string,
            regardless of any locale settings.) This is the internal
            function implementing the `\Q' escape in double-quoted strings.

            If EXPR is omitted, uses `$_'.

\Q is described in the Quote and Quote-like Operators part of the 
perlop man page.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |
GPG PGP Key 1024D/059913DA         | Fingerprint      0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work)      |                  75D2 9EC4 C1C0 0599 13DA


------------------------------

Date: Thu, 18 Jan 2001 14:33:24 +0000
From: John Tutchings <ccx138@coventry.ac.uk>
Subject: Re: novice perl programmer w/ errors
Message-Id: <3A66FEB4.C3396EDA@coventry.ac.uk>

if client_num is a number do you need to put the quotas on it?

Tad McClellan wrote:

> kenneth hopkins <khopkins3@home.com> wrote:
>
> >And I am recieving "201: A syntax error has occurred."
>
> All of the messages that perl might issue are documented in
> the perldiag.pod standard doc.
>
>    perldoc perldiag
>
> The message above is not there, so it is not a Perl message.
>
> There is no syntax error in the Perl code below. You do
> not have a Perl problem, so you are asking in the wrong place.
>
> >#!/usr/bin/perl -w
> >use strict;
>
> Clever of you to use those. It keeps your posted code from being ignored :-)
>
> >    UNLOAD TO \"/home/support/khopkins/isql.out\"
> >    SELECT client_type, client_id, client_num, name, title,
> >           first_name, middle_name, last_name, address1, address2,
> >           city, state, zip, country, home_phone, business_phone
> >    FROM client_ids
> >    WHERE client_num = '$num' ";
>
> Perhaps you have an SQL syntax error, in which case you should
> ask in a newsgroup where SQL is discussed.
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas



------------------------------

Date: Thu, 18 Jan 2001 15:21:49 GMT
From: piequals3@my-deja.com
Subject: Re: novice perl programmer w/ errors
Message-Id: <9471m2$89m$1@nnrp1.deja.com>

Under what circumstances is this error recieved?  Specifically, what
version of Perl are you using; what Operating System are you using..
etc.

I wonder if this message is coming from somewhere other than the Perl
interpreter.  A Perl error message usually includes a line number and
is generally a lot more helpful than simply telling you that something
went wrong.

Maybe your SQL is broken?  (Wild guess -- I know little about SQL.)

==
-Jon
"Can an atheist be insured against acts of God?"
==


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Thu, 18 Jan 2001 14:45:08 +0000
From: John Tutchings <ccx138@coventry.ac.uk>
Subject: Re: passing parameters from command line?
Message-Id: <3A670173.AD712BF0@coventry.ac.uk>

If you use the -s switch you can do
-ip=10.10.10.10 -hostname=localhost
How ever if you see my last posting there seems to be a bit of trouble if you
"use strict".
Also as soon as you pass a parameter that is not a switched one everything
after that is treated as normal arguments.
See page 499 Camel book ed 3.


paul wrote:

> ------------CUT-----------
>
> > You can also use the shift function;
> >
> > ie:
> > ================================
> >
> > #! /usr/local/bin/perl - w
> >
> > use strict;        # Not necessary for this example, but I use it anyways
> ;)
> >
> > $Foo = shift;    # Will get ARGV[0]
> > $Bar = shift;    # Will get ARGV[1]
> >
> this raises the following question for me ..
> can you assign for example -h <HOSTNAME> -p <PORT>
> to ARGV array
> or is the -h ARGV[0] <HOSTNAME> ARGV[1] etc etc ??
>
> > # Insert rest of code here.
> >
> > ================================
> > As long as you call it at the beginning of the program, outside of a
> > function, and don't change the $_ variable, it should work.
> >
> > D Fortin
> grx paul



------------------------------

Date: Thu, 18 Jan 2001 15:37:11 GMT
From: CM <cmon_209@hotmail.com>
Subject: Pattern Matching Problem
Message-Id: <9472j7$93p$1@nnrp1.deja.com>

Hi.
I have a Pattern Matching problem.I have been sitting on this for quite
some time but I feel I havent used the best algorithm.

My data file appears like this...

<!--2-->
<data goes here>
<!--2-->
<!--5-->
<data goes here>
<!--5-->
<!--7-->
<data goes here>
<--7-->

|
|
|

<!--23-->
<data goes here>
<--23-->


Now a record is the data that appears between <!--n--> and <!--n-->.


I try to get 4 records at a time based on a index...ie if index=0 I get
the first 4 records and if index=4, the second four records.


My algorithm is like this.

$buffer=Entire file contents
==========================================================
1.loop start from index to (index+4)

2.Match first occurence of /<!--(\d+)-->(.*?)<!--(\d)-->/ in $buffer

3.If it is the nth match( where index<= n <(index + 4) )..GET RECORD
else ignore

4.Remove this record (the current match) from $buffer.[$buffer = $' ]

4. End Loop
==========================================================


The problem with this algorithm is that it goes thru the entire data
whereas I need just 4 records .

Is there a better method to accomplish this?


I hope I have made myself clear


regards and Thanks
CM






Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Thu, 18 Jan 2001 15:19:20 GMT
From: twolfmaier@acm.org
Subject: Re: Problem modifying binary file
Message-Id: <9471hd$7up$1@nnrp1.deja.com>


> I have a script that reads a value from a binary file, increments the
> value and writes it back to the same file...
>
> If I use network format, when the value hits 26, the value read from
the
> file is suddenly undefined.


I did not receive any responses. I finally managed to solve this
mystery. Well, sort of.

The problem only occurs under Windows. To be exact, I am using Perl
5.005_3 ActiveState binary build 522 on Windows 95. The sample script
worked fine on a UNIX machine.

The problem occurs when the last byte is 01011000 = 26 = ^Z = EOF on
Windows. Somewhere between writing the byte to the file and closing the
file this byte gets dropped. Interestingly, they byte does not get lost
when the file is not closed between writing the byte and reading it.

My solution was to write a second EOF byte before closing the file:

    print($fh pack('C', 26)) or die("Cannot write to file: $!");

Of course, this solution is not portable unless I check whether the
script is running under Windows.

I would consider this a bug in the ActiveState port. This is a Windows
specific behavior I should not have to worry about as a developer. I
submitted a bug report to ActiveState. I haven't received any reply yet.

Thomas

-----------------------------------------------------
Thomas Wolfmaier
Human-Computer Interaction Resource Network (HCIRN)
25 Bucks Green Road, Thornhill, ON, Canada, L3T 4G1
Tel: +1-905-881-7095
Email: twolfmaier@acm.org
Web: www.hcirn.com
-----------------------------------------------------


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Thu, 18 Jan 2001 15:54:03 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Pulling KEy out of hash
Message-Id: <vkE96.314$032.10945@eagle.america.net>

On Thu, 18 Jan 2001 14:01:14 GMT, Tad McClellan <tadmc@augustmail.com> wrote:
>Garry Williams <garry@zvolve.com> wrote:
>>On Thu, 18 Jan 2001 00:24:26 -0600, John Michael <johnm@acadiacom.net>
>>wrote:
>
>
>>>         $value =~ s/<!--(.|\n)*-->//g;
>>
>>          $value =~ s/<!--.*-->//gs;
>
>
>>Is this a CGI program?  I rarely write CGI programs, but when I do, I
>>use the CGI module.  That way, I don't have to worry about making
>                                                            ^^^^^^
>>mistakes converting entities and parsing keywords from a query.
> ^^^^^^^^
>
>
>Like the mistakes in both of the above  :-)

My point was that `(.|\n)*' was equivalent to `.*' and /s.  I guess I
should have said what my point was.  :-(  

[snip advice to use modules]

-- 
Garry Williams


------------------------------

Date: Thu, 18 Jan 2001 14:35:34 -0000
From: "Jon" <jons1@lineone.net>
Subject: Redirect question
Message-Id: <t6dvmmrs1iq08d@corp.supernews.co.uk>

Hi,
Running Windows 2000/ActivestatePerl/SQL Server 7
This is probably a really simple question - I have a form which posts data
to a Perl script the Perl script pulls messages from a POP3 mailbox and
stores them in SQL Server, after the script has run i want to redirect to
another page. I've tried the code below to redirect
use CGI qw(:standard);
print redirect('http://www.perl.com');
and also
$url = "http://www.perl.com/CPAN/";
print "Location: $url\n\n";
exit;
neither works, the Perl script runs, messages stored in the database but the
redirect doesnt happen, no error messages.

Any clues? Thanks, Jon







------------------------------

Date: Thu, 18 Jan 2001 14:42:57 GMT
From: "jedstr" <jed@linuxbuilt./*no_spam*/.com>
Subject: Remove entire line from text file
Message-Id: <RhD96.146176$h%2.10318920@news3.aus1.giganews.com>

I am trying to cleanup a number of mailing lists which are in the form of:
>some_user@email.com    John L Smith (some company name or comment)

I can regex the email out like: s/some_user\@email\.com//g, but I am left
with the users name and any comments...
How can I remove the entire line? s/^.*some_user\@email\.com.*$//g doesn't
work of course...

???

jedstr






------------------------------

Date: Thu, 18 Jan 2001 14:49:38 +0000
From: John Tutchings <ccx138@coventry.ac.uk>
Subject: Re: Remove entire line from text file
Message-Id: <3A670282.2E499F6B@coventry.ac.uk>

while(<OLDFILE>){
    print NEWFILE unless (/some_user\@email\.com/);
}

or perl -ni.bak
    print unless (/some_user\@email\.com/);

jedstr wrote:

> I am trying to cleanup a number of mailing lists which are in the form of:
> >some_user@email.com    John L Smith (some company name or comment)
>
> I can regex the email out like: s/some_user\@email\.com//g, but I am left
> with the users name and any comments...
> How can I remove the entire line? s/^.*some_user\@email\.com.*$//g doesn't
> work of course...
>
> ???
>
> jedstr



------------------------------

Date: Thu, 18 Jan 2001 15:12:20 GMT
From: "jedstr" <jed@linuxbuilt./*no_spam*/.com>
Subject: Re: Remove entire line from text file
Message-Id: <oJD96.101068$m63.7880189@news5.aus1.giganews.com>

uhh...  this calls for a   'DOH!
I feel like Homer. =)
Thanks John!


"John Tutchings" <ccx138@coventry.ac.uk> wrote in message
news:3A670282.2E499F6B@coventry.ac.uk...
> while(<OLDFILE>){
>     print NEWFILE unless (/some_user\@email\.com/);
> }
>
> or perl -ni.bak
>     print unless (/some_user\@email\.com/);
>
> jedstr wrote:
>
> > I am trying to cleanup a number of mailing lists which are in the form
of:
> > >some_user@email.com    John L Smith (some company name or comment)
> >
> > I can regex the email out like: s/some_user\@email\.com//g, but I am
left
> > with the users name and any comments...
> > How can I remove the entire line? s/^.*some_user\@email\.com.*$//g
doesn't
> > work of course...
> >
> > ???
> >
> > jedstr
>




------------------------------

Date: Thu, 18 Jan 2001 15:53:02 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: Saving .htm file to disk from CGI script
Message-Id: <9473go$a43$1@nnrp1.deja.com>

In article <abw96.271$032.9472@eagle.america.net>,
  garry@zvolve.com (Garry Williams) wrote:

> >> open (HTMLFILE, "> cgi-bin/savehtmtolocal.htm") or die "Could not
open
> >> file.";
>
> >You also have a space between the > and the rest of the filename when
> >opening the filehandle...
>
> This is a red herring, according to the manual (perldoc -f open):
>
-------------

not meant to be a red herring.... I seem to recall I've had it fail on
win32 before with a space, so I'd recommend NO space as a general habit.

Dan


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: 18 Jan 2001 14:23:53 GMT
From: Randy Kobes <randy@theoryx5.uwinnipeg.ca>
Subject: Re: Win32 distr. missing files:
Message-Id: <946u9p$2b4$1@canopus.cc.umanitoba.ca>

In comp.lang.perl.misc, Rob <a565a87@my-deja.com> wrote:

> At the top of http://perl.apache.org/dist/ it warns:
>      Please note!
>      mod_perl-1.24_01.tar.gz or later is required for Apache >= 1.3.14.
> As I happen to have downloaded the binary Win32 installer version of
> 1.3.14 (which seems pretty new) I thought I'd head the advice above.
> To that end, I've downloaded mod_perl-1.24_01 and would like to build
> it from source on MSVC 6.0, but my compiler stops dead in its tracks
> because it cannot locate the following files:
>      apache.c
>      connection.c
>      constants.c
>      file.c
>      log.c
>      mod_perl_version.h
>      perlxsi.c
>      server.c
>      table.c
>      URI.c
[ ... ]
Hi,
    Those files are either part of the mod_perl distribution,
or will be generated when you build it. Take a look at the
mod_perl INSTALL.win32 file - the build procedure for Win32
mod_perl is different than that for Unix. You may also want
to try the cvs mod_perl - http://perl.apache.org/from-cvs/modperl/ -
in which there's a different option available for building
on Win32 (but note that in the cvs version the convention for
naming the dll has changed to coincide with the upcoming
change in apache-1.3.15). In either case, you'll need to also 
get the apache sources to build mod_perl against.

best regards,
randy kobes


------------------------------

Date: 18 Jan 2001 13:49:55 +0000
From: nobull@mail.com
Subject: Win32::LookupAccountSID documentation?
Message-Id: <u9hf2xezr0.fsf@wcl-l.bham.ac.uk>

Does anyone have any documentation/examples on the use of this
function.

In particular what format is the SID argument?  Is it the string like
'S-1-5-21-1184913412-117836071-4547331-2127' or is it a packed binary
format?  What is the return value?


-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

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 V10 Issue 89
*************************************


home help back first fref pref prev next nref lref last post