[18110] in Perl-Users-Digest
Perl-Users Digest, Issue: 270 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 11 21:06:11 2001
Date: Sun, 11 Feb 2001 18:05:11 -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: <981943511-v10-i270@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 11 Feb 2001 Volume: 10 Number: 270
Today's topics:
Re: Archive::Zip - any user comments? Oops (BUCK NAKED1)
Re: Archive::Zip - any user comments? (BUCK NAKED1)
Re: chown not allowed (Martien Verbruggen)
Re: Cron task [more] <sstefa1@gl.umbc.edu>
Re: Flash SWF Files: How to find width and height <bjoern@hoehrmann.de>
Getopts? jdb@ga.prestige.net
Re: Help Newbie stuck loads of question..hope this is t <bwalton@rochester.rr.com>
Re: Help with form code <jdthelen@worldnet.att.net>
Re: How to retrieve local machine ip address (BUCK NAKED1)
Re: How to run Perl on Windows 2000? (Damian James)
Re: Make it stop... bakor@my-deja.com
Re: MS Access Databses <bwalton@rochester.rr.com>
Re: NDBM_File and ndbm.h <tanase_costin@my-deja.com>
Re: Newbie here please help! Permission errors while cr <tanase_costin@my-deja.com>
Re: ODBC PERFORMANCE PROBLEM <bwalton@rochester.rr.com>
Perl CGI script & sendmail - timeout? john_harman@my-deja.com
printing raw data (non-ASCII) to a socket <john_simpson@us.ibm.com>
Re: printing raw data (non-ASCII) to a socket <bjoern@hoehrmann.de>
Re: printing raw data (non-ASCII) to a socket <jbritain@home.com>
Question on porcessing format of /proc/sys/net/tcp jdb@ga.prestige.net
Re: Question on porcessing format of /proc/sys/net/tcp <joe+usenet@sunstarsys.com>
Re: Question on porcessing format of /proc/sys/net/tcp (Martien Verbruggen)
Removing leading/trailing spaces zac_thomas@my-deja.com
Re: Removing leading/trailing spaces <joe+usenet@sunstarsys.com>
subroutine woes <anarch1st@yahoo.com>
Re: subroutine woes <godzilla@stomp.stomp.tokyo>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 11 Feb 2001 17:09:53 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Archive::Zip - any user comments? Oops
Message-Id: <28751-3A871BC1-11@storefull-247.iap.bryant.webtv.net>
On Thu, 11 Jan 2001 15:27:04 -0000, "Geoff Winkless"
geoff-at-farmline-dot-com@127.0.0.1> wrote:
> Has anyone any idea how good Archive::Zip is
[Oops! Sorry, let me rephrase for Archive::Zip. I've used it too.]
I've had no problems using Archive::Zip on an BSDi Apache server. Of
course, I haven't tried any files larger than 1 meg. If you have access
to "unzip", it's easier to use than Archive::Zip. If Info-Zip is not on
your sytem, you may have to be root to install it. Try typing "locate
unzip" in the shell to see if you can find a path to it. If you don't
find it (or the permissions are set so that you can't use it), and are
still having problems with Archive::Zip, try Compress::Zlib.
--Dennis
------------------------------
Date: Sun, 11 Feb 2001 13:06:31 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Archive::Zip - any user comments?
Message-Id: <16370-3A86E2B7-56@storefull-246.iap.bryant.webtv.net>
On Thu, 11 Jan 2001 15:27:04 -0000, "Geoff Winkless"
geoff-at-farmline-dot-com@127.0.0.1> wrote:
> Has anyone any idea how good Archive::Zip is
I've had no problems using Archive::Tar on an BSDi Apache server. Of
course, I haven't tried any files larger than 1 meg. If you have access
to GNU tar, it's easier to use than Archive::Tar. If "tar" is not on
your webhost already, you may have to be root to install it. Try typing
"locate tar" in the shell to see if you can find a path to it. If you
don't find it, then use Archive::Tar.
You may also want to look at Compress::Zlib.
--Dennis
------------------------------
Date: Mon, 12 Feb 2001 01:16:26 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: chown not allowed
Message-Id: <slrn98ee99.cm5.mgjv@verbruggen.comdyn.com.au>
On Sun, 11 Feb 2001 10:21:19 GMT,
Bart Lateur <bart.lateur@skynet.be> wrote:
> Chris Fedde wrote:
>
>>Readers should also get a shared lock on 'visible' while they are
>>reading it to prevent writers from gaining the exclusive lock till they
>>are all done reading it.
>
> That is precisely the situation I was trying to avoid. If I need to do
> this, then I might just as well sick to one single file for reading and
> writing? Or not?
Well, if the data you're writing allows it, you could consider locking
just the parts of the file you're updating with fcntl. Besides that, a
rename, even of several links, would hopefully be faster than a
content update of a file.
I don't think there's been enough information yet to determine what
the best strategy is...
> I'm beginning to think it's not worth the bother. So the new version of
> the file has another owner. So what? It *is* annoying at times, for
> example, replacing an updated file with a backup from tar, that will
> complain that it cannot change permissions.
>
>>If you are running under apache it might be worth while looking at the
>>suEXEC configuration so that your CGI programs can run as someone other
>>than the www user. But that is a topic for a different news group.
>
> That's another approach I thought about: a simple SUID program in C that
> does nothing but create a file under the right user, with the right file
> permissions. I could even pipe the data to write into it, but I don't
> think it's really necessary.
Maybe the best approach is to use a RDBMS, or the DB_File stuff with
some more advanced options.
Of course, that would only work if your data maps into a relational
database model. If it doesn't, maybe a small server program that does
all the updating and stuff internally, and the clients just contact
that. It would make the logic beter, but would make access slower
(although not necessarily by much).
If writes are necessary at high speeds, from several processes, then
maybe that is something you need to investigate. Of course, if each
single uodate changes half of the file's contents, then rewriting the
file is probably faster. Hard to tell.
Martien
--
Martien Verbruggen |
Interactive Media Division | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd. | cynical. It's perfectly easy to be
NSW, Australia | cynical.
------------------------------
Date: Sun, 11 Feb 2001 18:38:53 -0500
From: Scott Stefanoski <sstefa1@gl.umbc.edu>
Subject: Re: Cron task [more]
Message-Id: <3A87228D.D5DF71C5@gl.umbc.edu>
I would write a wrapping script that calls the first script and then
sequentially calls the second one after it is done.
jean@ematic.com wrote:
> First, thanks to all who helped me, that's okay now.
>
> Something more in a cron task: I want run 2 scripts, but the second one
> right after the first has been completed.
> The first script never runs the same time, as it is some checks, and
> duration is never the same.
>
> So how can I do to run the second JUST after the first ends ? Of course I
> could make it to run for example 3 hours after the first, as I am sure the
> the 1st will have been completed. But it's not a nice job :-)
>
> Thanks a lot,
>
> Jean
jean@ematic.com wrote:
> First, thanks to all who helped me, that's okay now.
>
> Something more in a cron task: I want run 2 scripts, but the second one
> right after the first has been completed.
> The first script never runs the same time, as it is some checks, and
> duration is never the same.
>
> So how can I do to run the second JUST after the first ends ? Of course I
> could make it to run for example 3 hours after the first, as I am sure the
> the 1st will have been completed. But it's not a nice job :-)
>
> Thanks a lot,
>
> Jean
------------------------------
Date: Sun, 11 Feb 2001 20:49:18 +0100
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: Flash SWF Files: How to find width and height
Message-Id: <3aa4ecba.25961100@news.bjoern.hoehrmann.de>
* Mösl Roland wrote in comp.lang.perl.misc:
>How to find in Perl the SFW parameters
http://www.twoshortplanks.com/simon/flash/index.html
--
Björn Höhrmann ^ mailto:bjoern@hoehrmann.de ^ http://www.bjoernsworld.de
am Badedeich 7 ° Telefon: +49(0)4667/981028 ° http://bjoern.hoehrmann.de
25899 Dagebüll # PGP Pub. KeyID: 0xA4357E78 # http://learn.to/quote [!]e
~~ post in peace ~~
------------------------------
Date: Sun, 11 Feb 2001 19:29:09 GMT
From: jdb@ga.prestige.net
Subject: Getopts?
Message-Id: <3A86047D.73B4C945@ga.prestige.net>
--------------0C5F1ACC55C022D59517832B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I am in need of a example or a url to a good example of getopts usage.
So say if the user does not run the program with Name -flags -more
flag's.. USAGE: blah -t -v.. etc.. Thanks ahead
--
Never put off till tomorrow what you can avoid all together.
--------------0C5F1ACC55C022D59517832B
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
I am in need of a example or a url to a good example of getopts usage.
So say if the user does not run the program with Name -flags -more flag's..
USAGE: blah -t -v.. etc.. Thanks ahead
<pre>--
Never put off till tomorrow what you can avoid all together.</pre>
</html>
--------------0C5F1ACC55C022D59517832B--
------------------------------
Date: Mon, 12 Feb 2001 01:32:52 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Help Newbie stuck loads of question..hope this is the right forum
Message-Id: <3A873DD7.D8A4DD02@rochester.rr.com>
rab24@my-deja.com wrote:
>
> Thanks for looking at this, Im on a perl crash course. Id really
> appreciate it if you could help me understand this script. Im trying to
> modify it but I dont understand most of it.
>
> what does $1 mean is it just a scalar varible
You need to learn to use the documentation that is already on your hard
drive. At an operating system command line prompt, type:
perldoc perlvar
perldoc perlop
perldoc perlre
and read up. Also check out the FAQ's. They can be accessed like:
perldoc -q regular expression
It would also be helpful to read the look "Learning Perl".
>
> what does these lines do
>
...
--
Bob Walton
------------------------------
Date: Sun, 11 Feb 2001 19:14:55 GMT
From: "jmd" <jdthelen@worldnet.att.net>
Subject: Re: Help with form code
Message-Id: <PwBh6.4821$t52.293636@bgtnsc05-news.ops.worldnet.att.net>
Thanks but I think that your instructions are over my head (not into
programming). I've d/l'd the module and looked over the instructions but I
am sure I will f**k it up totally if I try to do this. Is there a cgi script
that you know of that is already available somewhere? Thanks.
<egwong@netcom.com> wrote in message
news:c0Bh6.5488$y03.351174@news.flash.net...
> James Thelen <jdthelen@worldnet.att.net> wrote:
> > Looking for code or script that will return sequentially numbered
invoices
> > or other numbers when used in a hidden field within an html form. It
must
> > allow setting of the start number. Please help me. TIA
>
> #!/usr/bin/perl -Tw
> use strict;
> use CGI qw/ :standard /;
>
> print header,
> ul( map { li($_) } sort { $a <=> $b } param('numbers') );
>
> This uses the CGI.pm module (available at CPAN) and assumes your
> hidden parameter is named "numbers". Note how, in list context,
> param will return an array. The spaceship operator ('<=>') does
> the comparison numerically, so 10 comes after 9, not before it
> (as would happen with the default sort). map applies an operation
> (in this case, putting the list inside of "<li></li>") to every
> element of a list.
>
> See CGI (:standard, header, ul, li, param), perlop (starship), perldata
> (discussion of scalar/list context) and perlfunc (map, sort).
>
> (When you mentioned invoices, my internal alarm bells go off :)
>
> By the way, I don't know whether or not you're actually doing this,
> but if you're relying on a "hidden" form field being secure, don't.
> It's easy enough for anyone to spoof so they can send any arbitrary list
> of invoices. If you need to pass around secure data, use a hashing
> algorithm like MD5 (see Digest::MD5) so you can check your data's
> integrity. Ideally, you won't ever have to pass around secure data.
>
> HTH, ERic
------------------------------
Date: Sun, 11 Feb 2001 12:51:01 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: How to retrieve local machine ip address
Message-Id: <16370-3A86DF15-53@storefull-246.iap.bryant.webtv.net>
just wanted to let your know that not all internet surfers have static
IP addresses. For example, on WebTV, our IP number changes every time we
log on.
Regards,
Dennis
------------------------------
Date: 11 Feb 2001 23:32:54 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: How to run Perl on Windows 2000?
Message-Id: <slrn98e88s.kv9.damian@puma.qimr.edu.au>
Thus spake Sean on Fri, 09 Feb 2001 15:53:18 GMT:
>Thanks for your reply. But our needs are more than met with Windows 2000
>server. All I really wanted to know is how to run Perl on Windows
>2000.....thanks again.
>
Err, yes they may be, but the last time I looked, no version of Windows
shipped with a pre-installed Perl interpreter. You need to install one.
Since you mentioned CGI, I suggested a version of Perl that includes web
server software. You need this too -- whether you use Apache or IIS is your
business. If you are running CGI programs written in Perl, however, you will
find that Apache and Perl work better together.
Also note that Windows 2000 Server != web server software. Whatever web server
software you are running, this is what you have to deal with when developing
CGI.
So try either Indigo Perl, or as has also been suggested, Active Perl.
HTH
Cheers,
Damian
--
$;=ord$%,$:=$;-ord q,.,,$_=q 13346:3366:3276:3326:3386:546:566:966:3396:3376:1.
q 73386:546:;96:3326:3336:3386:3266:3236:3366:546::26:3236:3366:32:6:546:32667.
q,:;96:;;6:3296:3236:3366:326:56,,s,.,;ord($&)-$:-$;;;;;,eg,s,$;,;chr$&-$:;,eg,
eval eval; #requires 5.6.0 ## my first attempt at one of these...
------------------------------
Date: Sun, 11 Feb 2001 19:41:27 GMT
From: bakor@my-deja.com
Subject: Re: Make it stop...
Message-Id: <966pt6$f55$1@nnrp1.deja.com>
> You should be able to do something like:
>
> NAME: for($d=0;$d<=2;$d++)
> .
> .
> .
> $descr=<>;
> if ( $descr =~ /your "last line" pattern/ ) {
> last NAME; # This gets you out of loop NAME, or:
> }
>
> See 'last' and 'next' in 'man perlfunc' and check out the Loop Control
> section of 'man perlsyn'.
>
> --J
>
>
That was what I was looking for!!
I had tried playing with the "last" statement but was not using regular
expressions correctly. FYI here is my result....
#!/usr/bin/perl -w
#This program takes a file title as an input, creates a file 'title.txt'
#and writes a description as text into the file.
use strict;
my $formtitle;
my $d;
my $descr;
print "Enter the form title: ";
$formtitle=<>;
chomp $formtitle;
print "Enter a brief description: (3 lines max or press enter on a
blank line to
exit.)\n";
NAME:for($d=0;$d<=2;$d++)
{
open(DESC,">>$formtitle.txt") or die "Can't write to $formtitle.txt:
$!";
$descr=<>;
if($descr=~m/\n/ && length $descr <=1)
{
last NAME;
}
print DESC $descr;
close DESC;
}
Thanx!
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 12 Feb 2001 01:09:46 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: MS Access Databses
Message-Id: <3A873867.D3D9AA5B@rochester.rr.com>
GBs wrote:
>
> Does any1 here know of a PERL script that will enable me to manipulate a
> Microsoft Access Database online?
> If u do, could you please give me some info on it
...
Check out the DBI or Win32::ODBC modules. There are examples in their
docs.
--
Bob Walton
------------------------------
Date: Sun, 11 Feb 2001 23:08:00 GMT
From: Costin <tanase_costin@my-deja.com>
Subject: Re: NDBM_File and ndbm.h
Message-Id: <96760b$op5$1@nnrp1.deja.com>
In article <i6nh6.2380$OO2.16985@eagle.america.net>,
garry@zvolve.com (Garry Williams) wrote:
> On Sat, 10 Feb 2001 21:26:10 GMT, Costin <tanase_costin@my-deja.com>
wrote:
> > I create a data base with perl 5.005_03 using NDBM_File. When I try
to
> >read it with a C program using ndbm.h I obtain garbage.
> ^^^^^^^^^^^^^^^
> I wonder what that means?
Sorry, I didn't want to post a long question, but if I have to, I do. I
know that only half of my problem is Perl related, I hope nobody
consider it totaly out of the topic.
First: I create a database with this perl script
----------
#!/usr/bin/perl -w
use NDBM_File;
my $dbf = 'mydb';
my %dbhsh;
dbmopen(%dbhsh, $dbf, 0700) || die " can ' t open db \n ";
$dbhsh{'a'} = 10;
$dbhsh{'b'} = 20;
$dbhsh{'c'} = 30;
dbmclose %dbhsh;
----------
If read it back in Perl (no surprise) everything is OK.
SECOND:
I try to read it with the following C program
-----------
#include <stdio.h>
#include <ndbm.h>
#include <fcntl.h>
main()
{
DBM* db;
datum ldat, key;
db = dbm_open("mydb", O_RDWR, 0660);
for(key = dbm_firstkey(db); key.dptr != NULL; key = dbm_nextkey(db))
{
ldat = dbm_fetch(db, key);
printf(" name = %s \n val = %s \n", key.dptr, ldat.dptr);
};
dbm_close(db);
};
-------
the program produces:
name = c20b10a˙˙˙˙
val = 30c20b10a˙˙˙˙
name = b10a˙˙˙˙
val = 20b10a˙˙˙˙
name = a˙˙˙˙
val = 10a˙˙˙˙
which is the kind of garbage I was talking about, I would expect an
output as
name = c
val = 30
name = b
val = 20
name = a
val = 10
The question is: is the format of ndbm files in Perl not compatible
with the format of ndbm files produced with the C ndbm.h, or I have
something wrong in my installation?
It would be very convenient to share those files between C and Perl
programs
Thanks,
Costin
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sun, 11 Feb 2001 23:45:21 GMT
From: Costin <tanase_costin@my-deja.com>
Subject: Re: Newbie here please help! Permission errors while creating directories
Message-Id: <96786g$qk0$1@nnrp1.deja.com>
In article <95shpr$9e0$1@nnrp1.deja.com>,
hilljroberts@my-deja.com wrote:
> In article <95sfit$7co$1@nnrp1.deja.com>,
> tanase_costin@my-deja.com wrote:
> as to answer one more question for me: Why does that work? I mean,
how
> do you get to the 16893 from 755?
Hi,
Sorry for taking me so long to answer... the problem is: I don't know
how I came with this number!!!! The octal part is easy, each digit is
obtained as a sum of permissions:
read - 4
execute - 1
write - 2
so: user rwx -> 4 + 2 + 1 = 7
group r-x -> 4 + 1 = 5
others r-x -> 4 + 1 = 5
and fromn here the octal 0755
How to convert in decimal, I really do not know! I guess I wrote at a
certain moment o script to show the mode of my files and i simplly took
the output produced by perl for this kind of permission ( as this is the
only one I use).
Costin
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 12 Feb 2001 01:19:41 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: ODBC PERFORMANCE PROBLEM
Message-Id: <3A873AC0.57548F20@rochester.rr.com>
Me wrote:
...
> Does anyone have experience with odbc database engine and perl.
> I run a 2.5MB database, having 15 tables.
> The table most used is containing 21 fields. No big deal, I would say.
> Still, to gather info for my website, it takes about 1 to 2 seconds to
> simply get to the data.
> So, I was wondering.... is there a better performing method of using
> databases?
> plz advise, if you can!!
...
Well, there isn't a lot of info above, but I'll bet you're not running
the Apache web server with modperl and mysql (using DBI, of course)? It
is highly likely that all the time is being spent connecting to and
disconnecting from your database every time a request is made, and that
the actual operation of retrieving/storing your data is trivial
timewise. Apache with modperl and mysql should permit the database
connection to be held open between hits, and response time should go
down to milliseconds. Of course, you will probably need an OS to go
along with it :-).
You could also speed things up a good bit with an all-Perl solution,
using dbm-type tied hashes in place of the database.
--
Bob Walton
------------------------------
Date: Sun, 11 Feb 2001 21:30:32 GMT
From: john_harman@my-deja.com
Subject: Perl CGI script & sendmail - timeout?
Message-Id: <96709p$k79$1@nnrp1.deja.com>
I am using a Perl CGI script (Newspro) which has a mailing list function
attached. The problem is that not all messages are getting through to all
recipients each day (currently 810). The script calls sendmail but I think it
is inefficient in the way it does so.
Currently the script sends messages in batches of 50 Bcc: (blind copied)
messages (approx 40 KB per message) so it actually should only call sendmail
17 times (for 810 addresses)? Presumably these batches are implimented in the
script to reduce load on sendmail but it doesn't appear to be working
consistently as often only half of them get through.
I have also tried calling sendmail with "-odq": sendmail -t -odq so that
messages are queued for sending. This is more successful in terms of messages
getting through - though not 100%. Additionally the last messages take as
long as 5 hours to reach the last recipients - which is too slow for my
purposes.
Can anyone suggest some solutions which will be reliable and reasonably quick
while avoiding overloading sendmail? (I don't have access to an SMTP server).
Hopefully not too complex either as I am a relative novice.
Another possible mechanism I've seen used in another script (mailmachine.cgi
- www.mikesworld.net) forks processes - though I'm not familiar enough with
this to know whether this will cause it's own problems with too many
processes etc? (I've included a snippet of that code below).
I'd be most grateful if anyone could offer some help on this. How do the
bigger newsletter mailing list scripts work?
Thanks
John
sub send
{
$pid = fork();
$pid;
if ($pid) {
&sendcomplete;
&archive;
exit(0);
}
else {
close (STDOUT);
open(LIST,"$file");
if ($lock){
flock(LIST, $lock);
}
@addresses=<LIST>;
close(LIST);
foreach $member(@addresses)
{
chomp($member);
open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
if ($html eq "1") {
print MAIL "Content-type:text/html\n";
}
print MAIL "From: $admin_email\n";
print MAIL "To: $member\n";
print MAIL "Subject: $in{'subject'}\n\n";
print MAIL "$in{'message'}\n\n";
..........
...........
}
else {
print MAIL <<to_the_end;
---------------------------------------------------------------------
Click on the link below to be removed from the
$list_name.
http://$url$script_url?$member
(Or copy and paste the link into your browser)
---------------------------------------------------------------------
to_the_end
}
}
close (MAIL);
}
&confirmation;
exit;
}
}
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sun, 11 Feb 2001 15:22:46 -0500
From: John Simpson <john_simpson@us.ibm.com>
Subject: printing raw data (non-ASCII) to a socket
Message-Id: <3A86F496.F2D61797@us.ibm.com>
Could anyone help me understand how to print raw data. I am attempting
to write to a socket and the information that I want to write needs to
be raw hex bytes and not the ASCII version of the hex information.
I have a hash with this entry
%command = (
remote => [02,01,00,00,00,00,27],
Decimal for readablility with the documentation for the commands I am
trying to send.
I would like to convert the values from decimal to hex and print them so
that the
output would be the following format, but not as an ASCII string:
0201000000001b
I have scoured the newsgroup and FAQs and cannot find out how to do
this.
Thanks for any help!
John
--
John Simpson
Unix System Services Development
Poughkeepsie UNIX Development Lab
IBM Server Group
2455 South Road
Poughkeepsie, NY 12601-5400
email: john_simpson@us.ibm.com
Phone Ext: 845-433-7917 Tie: 8-293-7917 Fax: 845-433-8363
------------------------------
Date: Sun, 11 Feb 2001 22:29:43 +0100
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: printing raw data (non-ASCII) to a socket
Message-Id: <3ab10439.31976169@news.bjoern.hoehrmann.de>
* John Simpson wrote in comp.lang.perl.misc:
>Could anyone help me understand how to print raw data. I am attempting
>to write to a socket and the information that I want to write needs to
>be raw hex bytes and not the ASCII version of the hex information.
perldoc -f pack
--
Björn Höhrmann ^ mailto:bjoern@hoehrmann.de ^ http://www.bjoernsworld.de
am Badedeich 7 ° Telefon: +49(0)4667/981028 ° http://bjoern.hoehrmann.de
25899 Dagebüll # PGP Pub. KeyID: 0xA4357E78 # http://learn.to/quote [!]e
~~ Try To Live Your Illusions ~~
------------------------------
Date: Sun, 11 Feb 2001 22:33:32 GMT
From: Jim Britain <jbritain@home.com>
Subject: Re: printing raw data (non-ASCII) to a socket
Message-Id: <jRKHOpOvRxUtgiZJImrFbirHDOeM@4ax.com>
[posted and mailed]
On Sun, 11 Feb 2001 15:22:46 -0500, John Simpson
<john_simpson@us.ibm.com> wrote:
>Could anyone help me understand how to print raw data. I am attempting
>to write to a socket and the information that I want to write needs to
>be raw hex bytes and not the ASCII version of the hex information.
>
>I have a hash with this entry
>%command = (
> remote => [02,01,00,00,00,00,27],
>
You're looking for the pack function.
(more than you wanted to know):
perldoc -f pack
This function is the key to formatting data for socket communications.
------------------------------
Date: Mon, 12 Feb 2001 00:29:45 GMT
From: jdb@ga.prestige.net
Subject: Question on porcessing format of /proc/sys/net/tcp
Message-Id: <3A864AF1.EF664832@ga.prestige.net>
--------------AE7C30CF71589F0A29909CB3
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Could anybody give me some pointers or an example of processing the
format of parts of the /proc file system.. Thanks...
--
A little experience often upsets a lot of theory.
--------------AE7C30CF71589F0A29909CB3
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Could anybody give me some pointers or an example of processing the format
of parts of the /proc file system.. Thanks...
<pre>--
A little experience often upsets a lot of theory.</pre>
</html>
--------------AE7C30CF71589F0A29909CB3--
------------------------------
Date: 11 Feb 2001 20:44:00 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Question on porcessing format of /proc/sys/net/tcp
Message-Id: <m366ign09r.fsf@mumonkan.sunstarsys.com>
jdb@ga.prestige.net writes:
> Could anybody give me some pointers or an example of processing the format of
> parts of the /proc file system.. Thanks...
Perl is not an operating system, yet.
I use linux 2.2, and I don't even have a /proc/sys/net/tcp.
Maybe you need to look at your OS's documentation and
ask in a linux-related newsgroup.
--
Joe Schaefer Did I ever tell you that Mrs. McCave had twenty-three sons and
she named them all Dave? Well she did, and that wasn't a smart
thing to do.
-- Dr. Seuss
------------------------------
Date: Mon, 12 Feb 2001 01:53:58 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Question on porcessing format of /proc/sys/net/tcp
Message-Id: <slrn98egfk.cm5.mgjv@verbruggen.comdyn.com.au>
On Mon, 12 Feb 2001 00:29:45 GMT,
jdb@ga.prestige.net <jdb@ga.prestige.net> wrote:
>
> --------------AE7C30CF71589F0A29909CB3
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
Please, don't so this. Usenet is a plain text medium.
> Could anybody give me some pointers or an example of processing the
> format of parts of the /proc file system.. Thanks...
This has nothing at all to do with Perl. Various Unices have a /proc
file system. The two I've looked at have a seriously different
structure, and seriously different information in the nodes there.
Ask in a newsgroup specific to your OS, or even better, read the
manual pages of your OS. It should be specified there. Try
$ man proc
It may be in section 4 or 5 of your system's manual.
Martien
--
Martien Verbruggen |
Interactive Media Division | Never hire a poor lawyer. Never buy
Commercial Dynamics Pty. Ltd. | from a rich salesperson.
NSW, Australia |
------------------------------
Date: Sun, 11 Feb 2001 21:55:58 GMT
From: zac_thomas@my-deja.com
Subject: Removing leading/trailing spaces
Message-Id: <9671pb$l9u$1@nnrp1.deja.com>
I have gotten a job of reformatting a fixed-length field database record into
a csv format and I am a bit stumped how to globally check for empty fields
and change them to null values when I find them. I also have the same problem
with removing leading/trailing spaces globally. The following snippet shows
how I would do it the hard way (there are over 300 fields)!
#!/usr/bin/perl -w
.......some stuff....
$P1 = substr $Line,0,10; # Serial no
$P2 = substr $Line,10,8; # date
# check for zero as first digit in date field and convert to null string
if (substr ($P2,0,1) eq " ") { $P8 = "";);
$P3 = substr $Line,18,35; # Location 1
$P4 = substr $Line,35,35; # Location 2
....more stuff
Remove leading/trailing spaces
$P1 = &trim_spaces($P1);
$P3 = &trim_spaces($P3);
$P4 = &trim_spaces($P4);
....and so on......
I would be grateful for any tips.
Zac Thomas
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 11 Feb 2001 19:41:58 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Removing leading/trailing spaces
Message-Id: <m3ae7sn355.fsf@mumonkan.sunstarsys.com>
zac_thomas@my-deja.com writes:
> I have gotten a job of reformatting a fixed-length field database record into
> a csv format and I am a bit stumped how to globally check for empty fields
> and change them to null values when I find them.
Not quite sure what sort of "checking" an "conversion" you're
asking about. If you want to convert blank strings to empty
strings, you can use a regex substitution:
my $var = " ";
$var =~ s/^\s+$//; # emtpies all "blank" strings
For details, see
% man perlop
Also, (un)pack is good for handling records with fixed-width
fields; so can split() with an appropriate regexp. See
% perldoc -f pack
% perldoc -f split
% man perlre
A deja search of this newsgroup should pull up lots of relevant threads.
> ... same problem with removing leading/trailing spaces globally.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
There's a faq you should read for this in perlfaq4:
% perldoc -q "strip blank space"
[...]
> I would be grateful for any tips.
There is also a module on CPAN for handling CSV files called Text::CSV.
You might be better off just trying that instead.
HTH
Joe Schaefer
--
#include <stdio.h> /* requires gcc and *nix
use strict; system("cc -x c $0") and die $?; open C, "|a.out" or die $! . q*/
main(){char s[32]; remove("a.out"); printf("%s/C hacker\n",fgets(s,32,stdin));
return 0;}/*; print C "Just another Perl"; close C or die$?; #*/
------------------------------
Date: Sun, 11 Feb 2001 19:15:49 -0000
From: "Richard Brown" <anarch1st@yahoo.com>
Subject: subroutine woes
Message-Id: <966o6h$89p$1@uranium.btinternet.com>
i have a problem getting a simple subrotine to run, the code goes like this:
sub Upload_Pic {
use CGI qw/:standard/;
my $length;
if (!$_[0]) {
print "No file uploaded.";
return;
}
print h2('File name'),@_;
open (TEST,"<$_[0]");
print h2('File MIME type'), uploadInfo($_[0])->{'Content-Type'};
push(@test,<TEST>);
while (<TEST>) {
#$length += length($_);
}
print h2('File length'),$length;
open(FILE,">c:/microweb/docs/new.gif");
binmode FILE;
foreach $item(@test){
print FILE $item;
}
close(FILE);
print end_html;
}
the routine on it's own worked fine and uploaded files with no fuss, but
when i try to integrate it into another program, it' crashes.....
i have descovered that the problem lies with the command
"uploadInfo($_[0])->{'Content-Type'}" but i am not sure why, and whenever i
remove that command the file doesn't upload properly.......
could somebody PLEASE help, i will be eternally thankfull :)
------------------------------
Date: Sun, 11 Feb 2001 13:02:52 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: subroutine woes
Message-Id: <3A86FDFC.217B6B28@stomp.stomp.tokyo>
Richard Brown wrote:
(various snippage)
> the code...
> sub Upload_Pic {
> print h2('File MIME type'), uploadInfo($_[0])->{'Content-Type'};
> the routine on it's own worked fine and uploaded files with no
> fuss, but when i try to integrate it into another program,
> it' crashes..... i have descovered that the problem lies with
> the command "uploadInfo($_[0])->{'Content-Type'}"
Chances are good you have a Content Type conflict.
You have provided no background information on this
other script into which you are trying to incorporate
this script posted. If your other script is printing
a Content Type, this print will override your upload
Content Type. You can only print one Content Type per
script. With multiple Content Type prints, the first
printed prevails.
It is usually better to have upload scripts as independent
stand-alone scripts to avoid Content Type conflicts when
included in other scripts.
Godzilla!
------------------------------
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 270
**************************************