[6587] in Perl-Users-Digest
Perl-Users Digest, Issue: 212 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 1 01:09:05 1997
Date: Mon, 31 Mar 97 22:00:29 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 31 Mar 1997 Volume: 8 Number: 212
Today's topics:
Re: Adding REFRESH button to frameset.cgi (Geoffrey Hebert)
ANNOUNCE: Freeware Perl Framed Chat Script - QuikChat (aj304)
Can you figure this out? Split, Array, Literal, within (Paul Antinori)
Re: Can you figure this out? Split, Array, Literal, wi <no_nick@ix.netcom.com>
Re: current directory <wwenger@wt.net>
Re: current directory <merlyn@stonehenge.com>
db_file, hash and segv (Peter Lees)
Re: Email forger Works for MindSpring <kevlar@ns.net>
Re: File Locking <rootbeer@teleport.com>
Re: Functions and operators (Mark)
Re: Help: date and time <eric@nettown.com>
Re: How Do I Use Perl To... (Geoffrey Hebert)
Re: How to get from one array to another <wwenger@wt.net>
Installing Perl Scripts - Security Question/Concern (Brian Scott Ashcraft)
Re: Installing Perl Scripts - Security Question/Concern (Mike Dopheide)
Re: Installing Perl Scripts - Security Question/Concern (Jon Bell)
NT-opendir+grep problem <blazer@mail.nevalink.ru>
Re: Parsing file problem <dmitri@compass-da.com>
Question: Using perl to execute shell commands <jlevit@ou.edu>
Re: Question: Using perl to execute shell commands (Marshall G. Flax)
Re: Replaceing Text (Mike Stok)
Re: seeking easier pack/unpack from integer to 4-byte h <dalewis@cs.buffalo.edu>
Re: seeking easier pack/unpack from integer to 4-byte h (Michael Constant)
Sorting a List on multiple fields <neiled@enteract.com>
Re: Type glob/ max # of files (Dan)
Re: Type glob/ max # of files <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 01 Apr 1997 03:00:43 GMT
From: soccer@microserve.net (Geoffrey Hebert)
Subject: Re: Adding REFRESH button to frameset.cgi
Message-Id: <5hpsq8$bmv$1@news3.microserve.net>
No problem - just rebuild all frames.
That is what I had to do.
I wanted Content_type MutiPart to allow me to redraw but no luck
If every link goes to a cgi that rebuilds the whole set.
It works, but you need an intranet. Many of the internet ISP's time
out.
John M Chambers <jc@hendel.mko.dec.com> wrote:
>Digging around in the CGI module's docs, and in various books on
>web authoring didn't turn up an answer, so maybe the experts here
>will have some ideas ...
>After using the sample/frameset.cgi program successfully to put up a
>page with a few frames, the problem came up: After the user pushed
>a button in one of the frames, the result was an action which made
>one of the other frames's contents obsolete. So, how can we handle
>this?
>One thought, of course, was to have the form do something that causes
>one of the other frames to be updated. This was a brick wall; as near
>as we can tell, it ain't possible. (But if someone knows how to make
>the print_response routine update both frames, I'd like to hear about
>it. Calling &print_query didn't work; that put a copy of the query
>form in the response frame.!)
>The other idea was to include a REFRESH button in the request frame,
>next to the SUBMIT button. This was easy enough, and it did redraw
>the query form -- in the response frame. Gack! It seems that the
>output from the query always goes to the response frame, no matter
>where you want it.
>Does anyone know how to do this right? Is it even doable? The idea
>is to, in this example, make the SUBMIT button fill the response frame,
>and also have the query frame redrawn. Automatically would be nice,
>but a REFRESH button in the query frame would also be nice.
>(Yes, I know that in frameset.cgi this would be pointless. In my
>page, the query frame includes a <select> list of names. I'd like
>the response frame to add the user's name to the list of names in
>that list. And in real life, I'm interested in having N frames,
>with operations in any of them possibly triggering updates in various
>subsets of the frames.)
>--
>Geek Code (V3.0):
>GCC/CM/CS/E/IT/MU/O/PA/S d+ s+ a++ C++ P+++ L+++ E--- W++ N++ K+++ w O-
>M V- PS++ PE- Y+ PGP+ t- 5 X- R tv-- b++ DI++++ D- G- e+++ h--- r+++
>y++++
------------------------------
Date: 1 Apr 1997 04:25:55 GMT
From: aj304@detroit.freenet.org (aj304)
Subject: ANNOUNCE: Freeware Perl Framed Chat Script - QuikChat
Message-Id: <5hq2oj$pp2@news.cs.hope.edu>
If anybody is interested, I have put together a framed Perl chat room CGI
script that is available at:
http://www.cs.hope.edu/~hahnfld/quikchat/
It is being distributed as freeware but please DO NOT re-distribute it (I would
like to keep track of its users). I figured it was about time SOMEBODY built a
good simple framed chat script, but I couldn't find any on the net that I
liked, so I built this one from scratch...
-Matt
------------------------------
Date: 1 Apr 1997 03:51:56 GMT
From: pa19@tiac.net (Paul Antinori)
Subject: Can you figure this out? Split, Array, Literal, within string
Message-Id: <pa19-3103972300410001@p11.ts1.metro.ma.tiac.com>
Hi:
I was wondering if anyone can help me figure out how to not recognize the
"@" symbol as an indicator for an array in the following?
Thanks much.
Paul
pa19@tiac.net
$string = "John|Smith|John@world.net||||"
($fname, $lname, $email) = split (/\|/,$string,3);
print "$fname\t$lname\t$email\n";
error messages are:
# Literal @world now requires backslash, within string
File 'Macintosh HD:Desktop Folder:Untitled'; Line 1
# syntax error, near "("
File 'Macintosh HD:Desktop Folder:Untitled'; Line 3
# Macintosh HD:Desktop Folder:Untitled had compilation errors.
------------------------------
Date: Mon, 31 Mar 1997 23:23:40 -0500
From: Douglas Lewis <no_nick@ix.netcom.com>
To: Paul Antinori <pa19@tiac.net>
Subject: Re: Can you figure this out? Split, Array, Literal, within string
Message-Id: <33408DCC.421D1408@ix.netcom.com>
Paul Antinori wrote:
> I was wondering if anyone can help me figure out how to not recognize the
> "@" symbol as an indicator for an array in the following?
> $string = "John|Smith|John@world.net||||"
I would suggest enclosing the string in single quotes or quoteing
the @ character (i.e. "Join|Smith|John\@world.net||||")
hope it helps
dough
no_nick@ix.netcom.com
------------------------------
Date: Mon, 31 Mar 1997 20:44:35 -0600
From: Bill Wenger <wwenger@wt.net>
To: Dave Price <dave.price@gecapital.com>
Subject: Re: current directory
Message-Id: <33407693.79D@wt.net>
Dave Price wrote:
>
> Is there a special variable or perl function that will return the
> current directory. I know that $0 is the directory in which the
> script is located, chdir() will change directorys, and mkdir() will
> make a directory, but is there an equivalet to 'pwd'?
> Thanks in advance for any help.
> __________________________________
> Dave Price
> dave.price@gecapital.com
Look for the Cwd module.
use Cwd;
$dir = cwd;
------------------------------
Date: 31 Mar 1997 19:51:24 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: dave.price@gecapital.com (Dave Price)
Subject: Re: current directory
Message-Id: <8cohbztpzn.fsf@gadget.cscaper.com>
>>>>> "Dave" == Dave Price <dave.price@gecapital.com> writes:
Dave> Is there a special variable or perl function that will return the
Dave> current directory.
chop($current = `pwd`);
Dave> I know that $0 is the directory in which the
Dave> script is located,
No. $0 is the 0'th argument passed to the script when it started.
For most normal shells, this will be a relative or absolute path to
the script, but it could just as easily be "your mother doesn't work
here, please clean up after yourself!", so you *cannot* count on
anything in particular here.
Dave> chdir() will change directorys, and mkdir() will
Dave> make a directory, but is there an equivalet to 'pwd'?
See above.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 518 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 1 Apr 1997 03:44:18 GMT
From: peter@junior.next.com.au (Peter Lees)
Subject: db_file, hash and segv
Message-Id: <5hq0ai$j01@inferno.mpx.com.au>
Keywords: db_file, memory, database
g'day - i'm having a problem with a hash table generated from
a db_file database. here is one of the programs:
#!/usr/local/bin/perl5 -w
use FileHandle;
use DB_File;
use Fcntl;
$db1 = tie(%DB1,DB_File,"mydb1",O_RDONLY,$DBACCESS_MODE,$DB_HASH) || die($!);
$db2 = tie(%NEWDB,DB_File,"newdb",(O_RDWR|O_CREAT),$DBACCESS_MODE,$DB_HASH) || die($!);
STDERR->autoflush(1);
$count = 0;
while (($key,$val) = each %DB1)
{
$count++;
if (! defined($key) || !defined($val))
{
print STDERR '!' ;
next;
}
$NEWDB{$key} = $val;
print STDERR '.';
if ($count > 100)
{ $count = 0; $db2->sync ; }
}
$db2->sync;
untie(%DBNEW);
untie(%DB1);
after about 11000 records, the program aborts with a message: Out of memory!
this appears to happen on the READ of the database, since commenting out
the $NEWDB{$key} = $val; had no effect.
similarly, in another program adding a new key/value to the existing
database (DB1) caused a segmentation violation (core was dumped).
i wasn't sure how to examine the corefile, so i have left that for now.
the system is IRIX 5.3 and IRIX 6.3, db file is 1.85, perl is 5.003.
the mydb1 file is 8368128 bytes - quite large, but the system has 64MB RAM
and 238MB swap...
can anyone suggest what the problem could be?
cheers
p
--
Peter Lees (peter@next.com.au) - Technical Manager, Next Online
tel: +61 2 9310 1433 * fax: +61 2 9310 1315 * http://www.next.com.au
"You can have a day off when you're dead, Baldrick, and not before..."
------------------------------
Date: Mon, 31 Mar 1997 18:09:04 -0800
From: "K. Healy" <kevlar@ns.net>
To: the one and only real true kibo <kibo@dhp.com>
Subject: Re: Email forger Works for MindSpring
Message-Id: <33406E40.167E@ns.net>
the one and only real true kibo wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
>
> > On Thu, 27 Mar 1997 20:42:31 -0500 in article
> > > <333B2207.1FDB@chrysler.com> posted to news.admin.censorship,
> > > Kevin Darcy <kcd@chrysler.com> wrote:
> > > :the one and only real true kibo wrote:
> > > : HUMANS. Deceiving programs is not illegal -- if it were, I know
> > > : a helluva lot of sysadmins who would be in the slammer right now
> > > : :-)
> > >
> > > Big fucking deal - lots of people know Randall Schwartz.
> >
> > Care to address my point?
>
> Yes - Randall Schwartz, a former sysadmincontractor at Intel, served
> time in a slammer for the kind of shit you're talking about.
If you are going to smear Randal's name while misspelling it with your
gutter dialect, at least get the f**king facts straight. Randal did
*not* spend *any* time in the slammer. Goto:
http://www.lightlink.com/fors
for the _facts_.
Kevin
<kevlar@ns.net>
------------------------------
Date: Mon, 31 Mar 1997 20:15:34 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Rex Fowler <rmfowler@raptor.mtc.ti.com>
Subject: Re: File Locking
Message-Id: <Pine.GSO.3.96.970331201243.16684E-100000@kelly.teleport.com>
On 31 Mar 1997, Rex Fowler wrote:
> How do I flock() a file I don't have a handle for? ie a dbm file that
> wasn't explicitly open()'d.
Are you using DB_File? Its documentation includes a section called
"Locking Databases". Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Tue, 01 Apr 1997 05:30:30 GMT
From: (Mark)
Subject: Re: Functions and operators
Message-Id: <33409c61.5071740@news.ntr.net>
On Mon, 31 Mar 1997 22:41:14 GMT, abigail@ny.fnx.com (Abigail) wrote:
>On Mon, 31 Mar 1997 06:11:16 GMT, Mark wrote in comp.lang.perl.misc:
>++
>++ The comma is a syntactic element, the same way a paren or a dollar
>++ sign is syntactic in certain contexts. Comma is part of the syntax of
>++ a function/sub/etc
>Did you report it as an entry for the Camel errata list? The Camel
>thinks it's an operator. It even has a section about it.
*GULP* Did you report *ME*?
They probably have a section for it...
--
Mark <mark@ntr.net>
Please don't sue my boss because you don't
understand the concept of free speech.
*Pain is something funny that happens to YOU*
------------------------------
Date: Mon, 31 Mar 1997 22:37:19 +0000
From: Eric Poindexter <eric@nettown.com>
To: Alex Mak <amak@ernie.eecs.uic.edu>
Subject: Re: Help: date and time
Message-Id: <33403C9F.3D3684@nettown.com>
Alex Mak wrote:
>
> Hi folks,
>
> I am hoping to write a sub that would take
> a year and a month as parameters and return the
> day of the week of that month.
>
> i.e:
>
> print 'first day of month: ', &firstDayOfMonth(3,1997);
>
> would return 6 for saturday.
>
> what is my best approach?
>
> Thanks,
>
> Alex Mak
If you want the super-module approach...
Give a look at:
http://nettown.com/perl/site_perl/Time/CTime.html
http://nettown.com/perl/site_perl/Time/ParseDate.html
#!/usr/bin/perl
use Time::CTime;
use Time::ParseDate;
print strftime "%A (%c)\n", localtime parsedate '04/01/1997';
# Yes, the leading zeros are required.
# for that you can do
$with_leading_zeros = sprintf "%02d/%02d/%04d", 4, 1, 1997;
--
Eric
<mailto:eric@nettown.com>
[http://nettown.com/perl/]
have a good day!
------------------------------
Date: Tue, 01 Apr 1997 02:36:56 GMT
From: soccer@microserve.net (Geoffrey Hebert)
Subject: Re: How Do I Use Perl To...
Message-Id: <5hprdl$b5h$1@news3.microserve.net>
HTML question - wrong group!
Jerome Bradenbaugh Bradenbaugh <bradenb@ibm.net> wrote:
>If I want to change the location of the document in my browser, I write
>something to the following effect:
>Print "Location: newpage.html\n";
>Fair enough, but how do I open new pages in different frames?
>Please respond to the following e-mail address:
>bradenb@ibm.net
>Regards,
>Jerry Bradenbaugh
------------------------------
Date: Mon, 31 Mar 1997 20:37:58 -0600
From: Bill Wenger <wwenger@wt.net>
Subject: Re: How to get from one array to another
Message-Id: <33407506.5403@wt.net>
christop@ozinter.co.jp wrote:
>
> Hi
>
> I have this:
>
> %Data = (
> group1 => ["one:1.htm","two:2.htm","three:3.htm"],
> group2 => ["ay:a.htm","bee:b.htm","cee:c.htm","dee:d.htm"]
> );
>
> and I want to get the group1 bits happily into elements of the list
> array @instruction.
>
> How do I do it ? Documentation has me stumped at this point..
>
> As always I would be eternally grateful and moved onto the next level by
> someone's assistance.
>
> Cheers, Christopher.
> Tokyo March 31st
> (On the road to Mandarray..)
You may want to try something like this:
%Data = (
group1 => ["one:1.htm","two:2.htm","three:3.htm"],
group2 => ["ay:a.htm","bee:b.htm","cee:c.htm","dee:d.htm"]
);
for $x (0 .. $#{$Data{group1}}) {
$instruction[$x]= $Data{group1}[$x];}
print "@instruction\n";
------------------------------
Date: Mon, 31 Mar 1997 22:22:57 -0500
From: bashcraf@crosslink.net (Brian Scott Ashcraft)
Subject: Installing Perl Scripts - Security Question/Concern
Message-Id: <MPG.daa499a7bfad338989680@news.crosslink.net>
I have several Perl CGI scripts running in the following format on my
server:
<A HREF="http://www.mydomain.com/~mydirectory/cgi-bin/myscript.pl>My
Link</A>
A person clicking the "My Link" hot area executes my cgi script.
It appears to me that because I have given the exact path and name of my
perl script in the link reference, that this would pose a very great
security risk to my scripts and my server.
I have seen several web sites that are obviously running Perl scripts,
but the linking URL does not contain a ".pl" or ".cgi" file extension. I
am wondering how this can be accomplished?
I read several of the FAQs, and did not find a satisfactory answer to my
question. I also own all of the O'Reilly Perl and CGI Programming books.
Most likely, the answer is staring me right in the face, and I just
cannot see it.
Any help appreciated.
Reply directly, or to the group at large.
Many, many thanks in advance for your help.
Brian Scott Ashcraft
ashcraft@io.com
------------------------------
Date: Tue, 01 Apr 1997 03:35:57 GMT
From: dopheide@uiuc.edu (Mike Dopheide)
Subject: Re: Installing Perl Scripts - Security Question/Concern
Message-Id: <5hpvqt$ri2@vixen.cso.uiuc.edu>
>I have seen several web sites that are obviously running Perl scripts,
>but the linking URL does not contain a ".pl" or ".cgi" file extension. I
>am wondering how this can be accomplished?
They might be using SSI (Server Side Includes) in their html pages.
Something like in an html document:
<!--#exec cmd="path/bob.pl"-->
Will execute bob.pl, but won't show any sign that it was ever
executed.
Mike
PS. I probably won't see your reply on the newsgroup
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mike Dopheide dopheide@uiuc.edu
http://isr1564.urh.uiuc.edu/ <-- TW4N
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Tue, 1 Apr 1997 03:47:06 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Installing Perl Scripts - Security Question/Concern
Message-Id: <E7xx6J.1os@presby.edu>
Brian Scott Ashcraft <bashcraf@crosslink.net> wrote:
>I have seen several web sites that are obviously running Perl scripts,
>but the linking URL does not contain a ".pl" or ".cgi" file extension. I
>am wondering how this can be accomplished?
This is a CGI question, not a Perl question. Try asking in
comp.infosystems.www.authoring.cgi. Look for the FAQ first.
--
Jon Bell <jtbell@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
[for beginner's Usenet info, see http://web.presby.edu/~jtbell/usenet/ ]
------------------------------
Date: Tue, 01 Apr 1997 06:00:27 +0300
From: Mike <blazer@mail.nevalink.ru>
Subject: NT-opendir+grep problem
Message-Id: <33406C3B.28E3@mail.nevalink.ru>
I've read smth here in this group that in some cases opendir+grep may
fail under NT. It was said that this problem is about glob. I don't know
what does this mean, and even have no place to read. Now it seems that I
got the same: when I moved my scripts (Win95+FolkWEB server -OK, NetBSD
- OK) on NT machine it fails right inside opendir statement.
Please help, if it sounds as something known.
Thanks.
--
***************************
Mike Blazer
blazer@mail.nevalink.ru
***************************
------------------------------
Date: Mon, 31 Mar 1997 20:29:10 -0800
From: Dmitri Lazorenko <dmitri@compass-da.com>
Subject: Re: Parsing file problem
Message-Id: <33408F16.18F8@compass-da.com>
try this:
#!/bin/awk -f
{ gsub (/NULL */,""); print $0 }
------------------------------
Date: Mon, 31 Mar 1997 22:23:26 -0600
From: "Jason J. Levit" <jlevit@ou.edu>
Subject: Question: Using perl to execute shell commands
Message-Id: <33408DBE.3EB9@ou.edu>
Hi everyone,
I'm trying to use perl to execute some simple shell commands, but
since they're built into the shell (i.e., sh, csh, tcsh, etc.), perl
can't
seem to handle them. For example, if I the perl command:
system 'source $name';
or
system 'setenv $name';
...both of these come up with the shell error 'source: command
not found'. Obviously, /bin/sh/source doesn't exist, since it's
built into the shell. However, I do have the need of sourcing
some files and setting some environment variables to run another
program, which actually uses these environment variables to run.
The perl script handles passing various values to be input into
the program...does anyone know how I can get around this?
Thanks for any help!
Jason Levit
jlevit@ou.edu
----------------------------------------------------------------------------
Jason John Levit, N9MLA Graduate Research,
University of Oklahoma Center for Analysis and Prediction of
Storms
School of Meteorology jlevit@ou.edu
405/325-0453 http://wwwcaps.gcn.ou.edu/
------------------------------
Date: 31 Mar 1997 23:39:22 -0500
From: mgflax@panix.com (Marshall G. Flax)
Subject: Re: Question: Using perl to execute shell commands
Message-Id: <5hq3hq$l5m@panix.com>
In article <33408DBE.3EB9@ou.edu>, Jason J. Levit <jlevit@ou.edu> wrote:
>Hi everyone,
>
> I'm trying to use perl to execute some simple shell commands, but
>since they're built into the shell (i.e., sh, csh, tcsh, etc.), perl
>can't
>seem to handle them. For example, if I the perl command:
>
> system 'source $name';
To execute a script whose first line has the #! command, use the
system "$name"
command; to manually specify a processing shell, you could use
system "/bin/sh $name"
syntax as well.
> or
>
> system 'setenv $name';
Here, use the %ENV associative array, such as
$ENV{"TERM"} = "vt320";
Marshall
--
[Marshall G. Flax -- mgflax@panix.com]
------------------------------
Date: 1 Apr 1997 02:25:40 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Replaceing Text
Message-Id: <5hprn4$mii@news-central.tiac.net>
In article <01bc3e1e$37c91fc0$0a91e9cd@scs>,
Stephen Hill <scs@huron.net> wrote:
>When I use the sniplet of script below it converts the text to all lower
>case, this is not what I want. I wish the text to have the same cases as
>before the manipulation. If the original word started with a capital I want
>the manipulated text to start with a capital..
>
>If you have any ideas please email me at scs@huron.net
OK, but...
>@lines[$i] =~s/@keywords[0]/<I>@keywords[0]<\/I>/;
did you mean this:
$lines[$i] =~ s/$keywords[0]/<I>$keywords[0]<\/I>/;
the $ and @ prefixes are imporatnt. Some idea of what $keywords[0] and
$lined[$i] contain might help, you might want to bracket the search
pattern with \Q \E to escape regex special characters and sequences, you
might want to say something like:
$lines[$i] =~ s:(\Q$keywords[0]\E):<I>$1</I>:g;
... a little more context would help - s/// doesn't do anything to case
unless you tell it to by accident or design.
Please take the time to look at the FAQ at http://www.perl.com/FAQ/ which
includes snippets like:
What is the difference between $array[1] and @array[1]?
The former is a scalar value, the latter an array slice, which makes
it a list with one (scalar) value. You should use $ when you want a
scalar value (most of the time) and @ when you want a list with one
scalar value in it (very, very rarely; nearly never, in fact).
Sometimes it doesn't make a difference, but sometimes it does. For
example, compare:
$good[0] = `some program that outputs several lines`;
with
@bad[0] = `same program that outputs several lines`;
The -w flag will warn you about these matters.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Mon, 31 Mar 1997 21:22:18 -0500
From: Douglas Lewis <dalewis@cs.buffalo.edu>
To: lhollman@nicom.com
Subject: Re: seeking easier pack/unpack from integer to 4-byte hex
Message-Id: <3340715A.3B64C8FE@cs.buffalo.edu>
lhollman@nicom.com wrote:
> I'm trying to convert an integer into hex format for a MIDI application.
> I need to write out a 4 byte hex representation of a number, e.g.:
>
> 136 becomes 00 00 00 88
>
> or
>
> 1336336 becomes 00 14 64 10
maybe i don't understand, but why don't you just:
$out = sprintf("%08X", 136);
or
$out = sprintf("%08X", 1336336);
dough
no_nick@ix.netcom.com
------------------------------
Date: 31 Mar 1997 19:57:05 -0800
From: mconst@soda.CSUA.Berkeley.EDU (Michael Constant)
Subject: Re: seeking easier pack/unpack from integer to 4-byte hex
Message-Id: <5hq12h$q1m@soda.CSUA.Berkeley.EDU>
Lance Hollman <lhollman@nicom.com> wrote:
>I need to write out a 4 byte hex representation of a number, e.g.:
>136 becomes 00 00 00 88
>
>my $note_length = '136';
>print unpack ("H8", pack ("I", $note_length));
>
>returned 88000000.
>
>[...] I'm wondering if there wasn't a way to accomplish the same thing
>using a different pack/unpack statement.
Indeed there is. Your machine happens to store integers in
little-endian order -- that is, least significant byte first --
and that's the order they're getting printed in. You can fix it
by forcing perl to pack the integer in big-endian order (which
is what you want here) regardless of your machine's conventions:
print unpack("H8", pack("N", $note_length));
Note the N for "long in network (big-endian) byte order" instead
of I for "integer in host (undetermined, in your case little-endian)
byte order".
But there's an easier way to do the whole thing, without worrying
about byte order:
printf "%08x", $note_length;
See perlfunc(1) and printf(3) for details.
--
Michael Constant (mconst@soda.csua.berkeley.edu)
------------------------------
Date: 1 Apr 1997 05:19:30 GMT
From: "Neil Edmondson" <neiled@enteract.com>
Subject: Sorting a List on multiple fields
Message-Id: <01bc3e5c$854c1340$2d9a70cf@nedmondson.iclretail.com>
I've spent the day reading FAQs and experimenting to sort a file the way I
want it.
My input list has a list of items, with sub-fields seperated by "|" ,
something like:
field1|field2|field3|field4|.....|fieldn
No problem doing a basic sort with:
@list = sort ($a cmp $b) @list;
What I want to do is sort the list by field3 within field2 within field4,
for example, in one clean move.
Any pointers?
While I wait guess I'll read the Camel Chapter 4 tutorial again...
neiled@enteract.com
------------------------------
Date: Tue, 01 Apr 1997 02:06:54 GMT
From: rosenthd@erols.com (Dan)
Subject: Re: Type glob/ max # of files
Message-Id: <5hpqm2$fhk@boursy.news.erols.com>
I think you forgot to close the files that you open. If you open
enough of them without a close PERL will choke.
Why don't you use you just operate on the name of the file directly
using
while <>
{
if (-e $file) && (-M $file > $age)
{ $count++ }
$loopcount++;
}
Dan
"Pat Doran" <stcpjd@micro.lucent.com> wrote:
>Help me if you can.....
>I have a simple PERL script that uses a type glob to count the number of
>files in a directory older than certain age. It seems to work fine for all
>my directory's except one. This directory also has a HUGE amount of small
>files !!!!
>Is there a limit to the number of files that perl can loop through (this
>does not seem to make sense) or is my script messed up (I am hoping this is
>the case) ???
>please email me some help at stcpjd@micro.lucent.com
>Below is my script......
>#!/usr/local/bin/perl
>(($dir = shift) && ($age = shift)) || die "/You messed up\n";
>$i = 0;
>$j = 0;
>while ( $filename = <$dir/*> ) #loop through files in dir
>{
> print "$filename \n";
> #open file, fail if file is not there
> open(WORDLIST, "$filename") ||
> die "Sorry, there is data file integrity problem!!!\n";
> $i++;
>
> #check if file is more than $age days old
> if (-M WORDLIST < $age )
> {
> $j++;
> }
>}
>print "\nTotal files: $i\n";
>print "\nOld files: $j\n";
------------------------------
Date: Mon, 31 Mar 1997 21:15:46 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Pat Doran <stcpjd@micro.lucent.com>
Subject: Re: Type glob/ max # of files
Message-Id: <Pine.GSO.3.96.970331211233.16684K-100000@kelly.teleport.com>
On 31 Mar 1997, Pat Doran wrote:
> I have a simple PERL script that uses a type glob to count the number of
> files in a directory older than certain age. It seems to work fine for
> all my directory's except one. This directory also has a HUGE amount of
> small files !!!!
Currently, file globs (not type globs, which are a totally different
species) are implemented in Perl by calling an external program, usually
/bin/csh. This program may have a limit which Perl doesn't have. Either
recompile Perl to use tcsh (which, I hear, has no such limit), or use
readdir and friends to do the job, and do it faster as well. I recommend
the latter. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 212
*************************************