[8477] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2094 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 13 20:15:57 1998

Date: Fri, 13 Mar 98 17:00:26 -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           Fri, 13 Mar 1998     Volume: 8 Number: 2094

Today's topics:
        [Perl Mongers] Find Perl Hackers Near You! (brian d foy)
    Re: Are There Any Snazzy Perl Editors for Windows? <dmeyers@panix.com>
    Re: Contents of a file into checkbox's [CGI.pm] <perera@coffeepot.cs.rpi.edu>
    Re: E-Mail priority? (Neil Briscoe)
    Re: find a word (Chris Sherman)
    Re: Good Perl book <upsetter@shore.net>
    Re: Help sought with web programming security problem (Kenny A. Chaffin)
    Re: HELP, can't get PERL script to work through web bro ggibbs@Jeppesen.COM
        In the news .... <sp17@cornell.edu>
    Re: In the news .... (John Stanley)
    Re: Informix conectivity w/perl <mike@unival.com>
    Re: Is there a "Newsgroup" for Newbies to Perl? (Stefaan A. Eeckels)
        Is there any way to evaluate a string as a variable nam <john@apte.com>
        MS PWS won't run CGI dbreedlo@ix.netcom.com
    Re: newbie's 1st question (Craig Berry)
    Re: Perl4 vs Perl 5 (Jim Michael)
    Re: preserving age of file? (jay)
    Re: Problem stripping Mac headers off of GIF's (Paul J. Schinder)
    Re: Problem stripping Mac headers off of GIF's <uri@sysarch.com>
    Re: Problem stripping Mac headers off of GIF's (Andrew M. Langmead)
        Reference to a part of a hash? <jgoerzen@southwind.net>
    Re: regexp list context substitution <ryanpc@lbin.com>
    Re: regular expressions and control characters <uri@sysarch.com>
    Re: User-interface Quandary (Stefaan A. Eeckels)
    Re: User-interface Quandary <dean@tbone.biol.sc.edu>
    Re: User-interface Quandary shaker@netusa1.net
    Re: What? <sowmaster@juicepigs.com>
        Writing to a socket <mmcm@swbell.net>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 13 Mar 1998 18:38:07 -0500
From: comdog@computerdog.com (brian d foy)
Subject: [Perl Mongers] Find Perl Hackers Near You!
Message-Id: <comdog-ya02408000R1303981838070001@news.panix.com>
Keywords: from just another new york perl hacker


Perl Mongers [1] is an organization devoted to developing local Perl
users groups, such as NY.pm and Boston.pm [2].  one of the major
barriers to such an undertaking is finding the people to make up
the Perl user group.  as such, Perl Mongers is developing a service
that allow persons interested in being part of a local users group
to register who and where they are so that others in their area may
find and contact them [3].  direct yourself to 

   <URL:http://www.pm.org/register.html>

for more information :)

you don't have to be a guru or use perl extensively to register.  
from my involvement with NY.pm, i know that people even indirectly 
related to Perl, such as ISP staff and even family and friends,
have something to add to a user group.

since this is our first iteration of this service, we have provided
the source and will cheerfully accept comments, suggestions, and
patches :)


[1]
Perl Mongers <URL:http://www.pm.org>

[2]
NY.pm <URL:http://ny.pm.org>
Boston.pm <URL:http://boston.pm.org>

[3]
due to address harvesting concerns, we've turned off searching
temporarily, but don't let that stop you from registering!  we
expect to have this resolved RSN.

-- 
brian d foy                                  <comdog@computerdog.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: 13 Mar 1998 19:45:18 -0500
From: David Meyers <dmeyers@panix.com>
Subject: Re: Are There Any Snazzy Perl Editors for Windows?
Message-Id: <yobiupi6qxv.fsf@panix.com>

dks@mediaweb.com (dk smith) writes:
> <tkho@technologist.com> wrote:
> > should we do. We should do a chart of comparison together and post it to
> > Perl's FAQ. How is this idea?
> 
> Please include Mac OS editors too. BBEdit is excellent. Metrowerks mayhave
> Perl coloring but I do not know.

For the Mac, check out Alpha, by Pete Keleher at Rice Univ.
It has the ability to pipe selections and buffers into
and out of perl directly, sports a nifty MacPerl
menu, etc.  Very strong for tex, too.   And the default
keybindings are emacs-ish.


-- 
dmeyers@panix.com
"Any technology distinguishable from magic is insufficiently advanced."
Unsolicited commercial e-mail will not be accepted.  Dont waste
your time SPAMming me.  And no mail from @hotmail either. 


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

Date: 13 Mar 1998 18:19:34 -0500
From: Amitha Perera <perera@coffeepot.cs.rpi.edu>
Subject: Re: Contents of a file into checkbox's [CGI.pm]
Message-Id: <ycdvhtidvqx.fsf@coffeepot.cs.rpi.edu>

[followups restricted to c.l.p.misc]

Hi there

First, I try and avoid "barewords" as in
   $input=catlist;
I prefer to use
   $input="catlist";

Second, your problem lies with the way <> works for reading in a file.
   @mfc = <INPUT>;
would create an array @mfc with _one_entry_per_line_ of INPUT. Since your
input file has only one line, the array has only one entry, i.e.
   $mfc[0] = "eenie meenie minie"

The simplest solution, in your case, would be to put each of the values on
a separate line in the input file.

Another solution is something like the following:
   open(INPUT, $input) or die("Could not open $input: $!\n");
   while($line = <INPUT>) {
      # Divide each line on whitespace and append into the array
      push(@things, split(/\s+/,$line));
   }
   # now do whatever with @things

The while loop can be simplified further:
   while(<INPUT>) {
      push(@things,split);
   }

Have a look at the perlop manpage (under I/O Operators) and at the perlfunc
manpage under "split".

Hope this helps.

Amitha.

--
Amitha Perera                     tel: +1-518-276-6340
Computer Science Department
Rensselaer Polytechnic Institute


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

Date: 13 Mar 1998 23:36:24 GMT
From: neilb@zetnet.co.uk (Neil Briscoe)
Subject: Re: E-Mail priority?
Message-Id: <memo.19980313233622.62363A@skep.compulink.co.uk.cix.co.uk>

In article <3505C5A1.FBFC6641@websolution.com>, mknutson@websolution.com
(Mick Knutson) wrote:

> I have a form I send to a perl script.  I format this form, and generate
> an e-mail to a specified user.  How can I set the priority of that
> messsage to something other than normal.  Say High or Low priority.
>
>

Include a Priority: header in what you send perhaps.

This isn't a perl question, its a Sendmail/SMTP one.

Regards
Neil



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

Date: Sat, 14 Mar 1998 00:28:24 GMT
From: sherman@unx.sas.com (Chris Sherman)
Subject: Re: find a word
Message-Id: <Eps9BC.E2@unx.sas.com>

In comp.lang.perl.misc you write:

>Hi. I've been doing perl thingies for a short time
>Now I'm trying some regexp. I got the camel but the
>explanations I found are too short for me.

>I'd appreaciate if someone could give me an example
>of how to find the first word in a string.

>Someone gives me $a="blah     "
>			spaces

>I want $b="blah" but I've been playing with \W and \w
>unsuccessfully and I'm driving myself crazy 'cause I
>see it must be EASY

>I tried many many things ...
>why didn't that worked ?

>$_="blah  ";
>$b=~ /(\W)/g

Yeap, regular expressions are fun.  I'm really good at them now, 
but it has taken me a while...  :-)

Let me see if I can cover a couple of basic points that I think
you might be confused about, and maybe that will help.  Then, I'll
show you an example to get your example working.

The special regexp commands like \w and \W mean _one_ alphanumeric
character and _one_ non-alphanumeric character, respectfully.

You don't want to use the \W in this case, because "blah" contains
type \w type characters.

So you want to match 1 or more \w type characters.  The regexp symbol
for this is "+".  And this is where it works differently than, say,
in a Unix command line shell.

Have you ever done anything like this in Unix?

$ ls *.c
main.c sort.c

Stuff like that???  In the shell, the * means 0 or more alphanumeric
characters.

Perl works differently.  The symbols "*" and "+" mean something slightly
different.

"*" means 0 or more of the previous character
"+" means 1 or more of the previous character

You would use them like this:

   $line="one two three";
   print "line is: $line\n";

   $line=~s/^(\w+).*/\1/;
   print "line is now: $line\n";

Which returns:

   line is: one two three
   line is now: one

See how it kept the first word?   This is because:

  (\w+) gobbled up all the alphanumeric chars until it hit a character
        that wasn't one (the space), and put the characters into \1 
        (regular expression register 1).

  .*    gobbled everything up till the end of the line.  Dot '.' means
        any kind of character, and "*" means 0 or more of them.

  s/stuff/newstuff/ changes the first "stuff" it finds in $_ to "newstuff"
        using complicated rules.  s///g means change all occurrences of 
        stuff to newstuff on that line.

Let's look at your code above:

   >$_="blah  ";
   >$b=~ /(\W)/g

First of all, \W won't work because you wanted alphanumerics, not
non-alphanumerics.

"$b=~ blah blah" won't work because $b is empty so far.  =~ acts
on the thing to its left.  You probably wanted $b="blah  " instead.

And "/blah blah/" by itself just checks to see if "blah blah" is in
$_, but doesn't actually do anything to it.


Anyway, this is just some ground work.  Please see if the info above
helps your understanding when you go back and try to make sense of the
docs.  See if you can find examples in source posted to this group.  That
is what really helped me to learn.

Hope this helps...
-- 
     ____/     /     /     __  /    _  _/    ____/
    /         /     /     /   /      /     /          Chris Sherman
   /         ___   /        _/      /          /
 _____/   __/   __/   __/ _\    _____/   _____/           sherman@unx.sas.com


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

Date: 13 Mar 1998 23:08:21 GMT
From: Art Cohen <upsetter@shore.net>
Subject: Re: Good Perl book
Message-Id: <6ece95$gb3@fridge.shore.net>

Ed Jamison <edwardt@i.really.really.hate.spam.jamison.com> wrote:
: The Dummies books are not dry, as many other books tend to be, but they 
: lack in content.

I wouldn't consider "Learning Perl" to be dry... (Or "Programming Perl" 
for that matter) but the humor tends to be more programmer-related ("This
is generally considered a feature") and a little more subtle than in the
Dummies books. (Actually, it's a lot more subtle. "Married With Children"
is a *little* more subtle than the humor in the Dummies books). 

--Art

National Ska/Reggae Calendar: www.ziplink.net/~upsetter/ska/calendar.html
        Boston Ska Home Page: www.ziplink.net/~upsetter/ska/index.html



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

Date: Fri, 13 Mar 1998 16:25:12 -0700
From: kenny@kacweb.com (Kenny A. Chaffin)
Subject: Re: Help sought with web programming security problem
Message-Id: <MPG.f736e435739a310989ca3@news.dimensional.com>

In article <3508F97E.61B4@isporg.com>, wd@isporg.com says...
> I am in need of a way of providing web page readers with a visual
> certification that they are viewing an "official" web page and
> not someone's copy of it. I have been thinking along the lines
> of developing a "seal of approval" gif file image which will be kept
> secure. At the top of each web page using this scheme would be a request
> to a CGI program for the "seal of approval" image. If the requesting
> page were a "proper" one (i.e. located on the secured server rather
> than on someone's own server) the program would return the gif file.
> Otherwise, the program would return a different "seal of unapproval"
> gif file contents.
> 
> So, can one do this and if so how or what might be another approach?
> 

Why? If it's going to be on a secure server anyway. I must be missing 
something. And what's to keep some proxy from copying the page on the fly 
(with the image included), etc....

-- 
KAC
Website Design, Programming, Graphics --> http://www.kacweb.com
kenny@kacweb.com


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

Date: Fri, 13 Mar 1998 17:41:37 -0600
From: ggibbs@Jeppesen.COM
Subject: Re: HELP, can't get PERL script to work through web browser
Message-Id: <6ecg4v$6al$1@nnrp1.dejanews.com>

In article <6e5q3s$drj$2@news.kornet.nm.kr>,
  "Sanghyun Lee" <dragon@soback.kornet.nm.kr> wrote:
>
> OK, I wrote a simple Perl script. I ran it on my ISP (UNIX) through Telnet.
> It appeared to work. Then I typed in the address of the script through my
> web-browser. It just printed the whole script out instead of running it!!
> What's wrong?
> Also is there anyway to use C to write CGI scripts? I tried C too but it
> just returns a 500 error... Maybe you have to compile the thing under a UNIX
> compiler? Where do I get one of these if they are available??
>
> Please help me to get PERL CGI to work in web browser...
> Or better yet help me get C/C++ CGI to work...
> Or even better help me get both to work...
>
> Note: I am a complete beginner and know next to nothing about UNIX, CGI,
> PERL, etc. etc. etc.
>
> PS. Please E-mail reply also...
>
> Thanks
>
>

Well there could be a number of things wrong.

1) your isp does not allow cgi scripts.
2) your isp allows cgi scripts, and assumes they are called filename.cgi
   not filename.pl
3) the permissions are wrong. remember the actual user that executes your
   cgi is usually "nobody". Make sure your file is executable by everyone.
4) the cgi-bin directory is incorrect.
5) check the log file. (you may need to ask the isp where it is located).

just my 2cents worth.

Geoff Gibbs


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Fri, 13 Mar 1998 19:47:06 -0500
From: "Steve Pacenka" <sp17@cornell.edu>
Subject: In the news ....
Message-Id: <6eck1a$inj@newsstand.cit.cornell.edu>

>From an article today about the asteroid that was formerly scheduled to hit
the Earth in a couple of decades:

   "It's all in a day's work," said Don Yeomans, a senior scientist at
NASA's JPL,
    who helped make the calculation that saved the Earth from possible
destruction.

"Made a calculation" and "JPL" summon forth the image of one Larry Wall who
once worked at JPL.

Could there have been an extra Perl 1.0 interpreter left laying around that
Mr Yeomans used to save us all?

-- :^), SP





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

Date: 14 Mar 1998 00:53:33 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: In the news ....
Message-Id: <6ecked$se9$1@news.orst.edu>

In article <6eck1a$inj@newsstand.cit.cornell.edu>,
Steve Pacenka <sp17@cornell.edu> wrote:
>From an article today about the asteroid that was formerly scheduled to hit
>the Earth in a couple of decades:
>
>   "It's all in a day's work," said Don Yeomans, a senior scientist at
>NASA's JPL,
>    who helped make the calculation that saved the Earth from possible
>destruction.
>
>"Made a calculation" and "JPL" summon forth the image of one Larry Wall who
>once worked at JPL.
>
>Could there have been an extra Perl 1.0 interpreter left laying around that
>Mr Yeomans used to save us all?

Perl may be a wonderful language, but I don't think it could make a
calculation that would save the Earth from being hit by an asteroid the
way this one was.



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

Date: Fri, 13 Mar 1998 15:19:49 -0800
From: Mike Hitchcock <mike@unival.com>
To: bpszenny@baynetworks.com
Subject: Re: Informix conectivity w/perl
Message-Id: <3509BF15.E4596894@unival.com>

bpszenny@baynetworks.com wrote:
> 
> Hello,
> 
> Could anyone let me know what I need, and where to get it, to connect to an
> Informix database using perl?
> 
> Idealy I want a WWW page to allow useres to dynamicly send queries to teh dB.
> 
> Thanks for any assistance!
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/   Now offering spam-free web-based newsreading

You probably already got responses, but I have been doing a
lot of Perl/Informix stuff (7.22 and now "Universal Server").

I use the DBI (database interface) and DBD::Informix (database
driver, Informix) modules from the CPAN (check out
http://www.perl.com). You will also need Informix's "esql"
product (i.e, more $ and licensing headache) to compile the
DBD::Informix. Let me know if you need more info/help!

-- 
Mike Hitchcock
mike@unival.com
hitchcock@earthling.net


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

Date: 13 Mar 1998 22:55:47 GMT
From: Stefaan.Eeckels@ecc.lu (Stefaan A. Eeckels)
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <6ecdhj$3vb$1@justus.ecc.lu>

In article <6e9qcv$rb1@newsops.execpc.com>,
	Mark Stackhouse <stackhou@execpc.com> writes:
> 
> Don't you Pros know that suggesting we look in this perldoc
> or that perldoc doesn't really help someone who can't
> understand the docs because we don't know enough about the
> language yet?  Most of the online docs I've read just add
> more to the confusion!  These are fine for someone who
> already knows the language and just needs a refresher
> but for someone just learning... they suck.
This paragraph only proves that you've not even tried to
read the docs. I grant you that, if you've no programming
experience whatsoever, the Perl docs are not sufficient to
teach you programming and/or teach you Perl. Other than that,
they're pretty slick and complete.
Do you expect this newsgroup to be a 'gosh-I-have-20-private-tutors'
experience just because you condescended to using Perl? 
> 
> We need a good list of tutorials, our own Newsgroup, some
> good books, and a few  mentors who don't mind answering (and
> explaining) our "Newbie" questions.  Then we get out of your
> bandwidth.
Then start the process to set up such a newsgroup - it's not
rocket science, and you don't need anybody to do it for you.
Good books exist - 'Learning Perl' comes to mind ;-)
As to mentors, who's going to pay them for endlessly
regurgitating the same answers? The 'newbie' type that
irritates the 'Pros' so much is too lazy to read the docs,
and too lazy to search the archives. It reminds me of the
samba newsgroup, where a lot of the bandwidth is taken by
the same questions (I can't print, why does NT4SP3 not work
anymore etc). After a while, one just tires of repeating
the same answer. 

-- 
Stefaan
-- 

PGP key available from PGP key servers (http://www.pgp.net/pgpnet/)
___________________________________________________________________
  "Don't worry about people stealing your ideas.  If your ideas
   are any good, you'll have to ram them down people's throats."
                                                -- Howard Aiken


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

Date: 14 Mar 1998 00:15:04 GMT
From: "John Hibscher" <john@apte.com>
Subject: Is there any way to evaluate a string as a variable name?
Message-Id: <01bd4edd$7ad59ac0$8fa7f9c7@hamachi.apte.nunet.net>

Hello,

Is there any way to evaluate a string as a variable name? For example, I
have a dynamic number of form fields, each named wc1, wc2, wc3, ..., wcn
and I know the value of n. Now how do I refer to these fields in perl? I
tried variations on the following, but I think I'm in error:

for ($i=1; $i<=$wcnum; $i++) {
  $wcname = 'wc'.$i;
  print MAIL "$FORM{$wcname}\n\n";
}

If you could send me a reply via e-mail, I will be very happy. Thanks for
your time, folks.

Regards,

John Hibscher


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

Date: Fri, 13 Mar 1998 17:42:03 -0600
From: dbreedlo@ix.netcom.com
Subject: MS PWS won't run CGI
Message-Id: <6ecg5p$6cu$1@nnrp1.dejanews.com>

Have MS Personal Web Server running on Win95 with no network connection.
Trying to use it to learn/test CGI scripts.

The following should cause my script (Cgi.exe) to execute, yes?
<P><A HREF="http://localhost/cgi-bin/cgi.exe">Cgi.exe</A></P>

Instead, the browser asks where I want the file saved.

My question: Where in Personal Web Server do I turn on CGI execution?
Are there any docs available for PWS?

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 13 Mar 1998 23:06:16 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: newbie's 1st question
Message-Id: <6ece58$1jc$1@marina.cinenet.net>

John Hibscher (john@apte.com) wrote:
: 	Is there any recommended code to simulate a web page counter out there?
: I'm trying to use the counter to generate unique file names. I've been
: looking at the man pages for perl and it seems I may need to go buy a book
: to understand perl functions. 

You definitely should buy a book -- two, in fact.  _Learning Perl_ to 
learn the language, _Programming Perl_ for reference and to get into more 
esoteric topics.  There are many other very good Perl books, but these 
are the key ones to have.

: 	My approach would be to have a file containing the current count. Then
: each time the page is accessed, the count would be incremented and
: re-written back to the file. It seems like no problem, but I'm lost in
: syntax. Any help is greatly appreciated.

You can indeed use the exact same approach as is used in web-page counter
scripts to accomplish this.  That approach is a FAQ.  Best of luck! 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Fri, 13 Mar 1998 23:16:13 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Perl4 vs Perl 5
Message-Id: <genepoolEps5z2.Gx1@netcom.com>

Craig Berry (cberry@cinenet.net) wrote:
: Jim was doing a distorted version of what amounts to a c.l.p.m in-joke. 
: The canonical phrase is "There are no plans to make Perl 4 Y2K-compliant." 

Yeah, I hate it when I blow the punchline like that.

Cheers,

Jim
--
Ask me about my vow of silence.


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

Date: Sat, 14 Mar 1998 00:26:53 GMT
From: mocat@spamtrap.best.com (jay)
Subject: Re: preserving age of file?
Message-Id: <3509ce2a.81847263@nntp.best.com>

On Thu, 12 Mar 1998 11:32:48 GMT, mocat@spamtrap.best.com (jay) wrote:

>I want to keep the newest entry in the logfile at the top of the
>logfile.  Here's a rough idea on how I did this:
>
>open(RLOG, "logfile");
>@rlog = <RLOG>;
>close(RLOG);
>open(LOG, ">logfile");
>
>print "$newest_entry\n"."@rlog";
>
>But I want to keep a "yesterday" log, and in order to do this, the
>program has to move the "today" log to the "yesterday" log every 24
>hours and start building up a new "today" log.
>Whenever the program opens the "today" log for writing, it deletes the
>old one and starts a new one.  So everytime the file is modified, it
>gets a new timestamp.

What I have come up with to solve this problem is

$fileage = (-M "logfile");
blah blah blah blah blah
print TODAYLOG "$stuff\n";
utime($fileage, $fileage, "logfile");

Too bad it doesnt work...
But then again I haven't done much reading on timestamps or the utime
function...

Any suggestions?


-j
:mocat@best.com/www.best.com/~mocat:


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

Date: Fri, 13 Mar 1998 17:52:56 -0500
From: schinder@leprss.gsfc.nasa.gov (Paul J. Schinder)
Subject: Re: Problem stripping Mac headers off of GIF's
Message-Id: <schinder-1303981752560001@schinder.clark.net>

In article <3509951A.E3C20A4F@ixlabs.com>, chris@ixlabs.com wrote:

}  Hi,
}  
}  I'm a UNIX web developer who works with web designers who are not.
}  
}  Often, they will email me GIF's which have (what I assume is) Macintosh
}  binary header information on them, rendering them useless on anything
}  else..

How exactly are they sending you these files?  It's quite easy for a Mac
user to send files with the data fork only (speaking as a Mac user using a
Mac at this very moment.)  A little user education would go a long way to
help you solve this.  Since you say they're using e-mail, if you're in a
position where you can tell them that you'll only accept the images if
they're sent "AppleDouble", that will solve your problem immediately.

Anyway, there are no "Mac headers" stored in files on a Mac.  Mac specific
information in a GIF image is stored in the "resource fork" of a double
forked file, with the "data fork" holding the GIF itself.  Sounds like
what's happening is that these files are getting packaged into one of the
transport formats that are used to send Mac files through non-Mac
machines.  The one you're most likely dealing with is MacBinary. 
MacBinary puts a fixed 128 byte header at the beginning of the file, and
the end of the file can be null padded to a 128 byte boundary.  You can
find pointers to details about the format (which comes in I, II, and III
flavors) at the following site: <http://www.lazerware.com/~leonardr/>.  I
have a publicly available Perl module, intended for use with MacPerl,
which among other things decodes MacBinary II into native Mac files,
available at <ftp://ftp.clark.net/pub/schinder/Conversions.pm>, which you
might want to look at.

My guess is that you can make the files usable simply by discarding the
first 128 bytes.

}  
}  I wrote a Perl script which strips off everything up until /GIF8\d/.
}  This script worked fine for the first two batches I received, but now it
}  fails to make the regexp substitution:
}  
}  [read the GIF file into an array, and join '' it into a $gifin]
}  
}  $gifin=~s/^(.*)(GIF8\d.*)$/$2/;
}  
}  Although I can look at the file and see "GIF89a" in there, and strip the
}  header off with an editor, this regexp does not match.
}  
}  Here is the whole program, which also archives the original file to
}  $filename.bak (using Perl 5.004_03, BTW):
}  
}  #!/usr/bin/perl -w
}  use strict;
}  
}  use File::Copy;
}  
}  defined $ARGV[0] or die "Usage: $0 [files...]";
}  my @gifin;
}  my $gifin;
}  
}  foreach(@ARGV){
}          next && print STDERR "Cannot read $_\n" unless -r $_;
}          next && print STDERR "Cannot copy $_ to $_.bak" unless
}  copy($_,"$_.bak");
}          next && print STDERR "Cannot open $_ for reading\n" unless
}  open(MACIN,"$_.bak");
}          next && print STDERR "Cannot open $_.gif for writing" unless
}  open(GIFOUT,">./$_");
}  
}          $gifin=join('',<MACIN>);
}  
}          print 'yes' if $gifin=~s/^(.*)(GIF89.*)$/$2/;
}  
}          print GIFOUT $gifin;
}  
}          close MACIN;
}          close GIFOUT;
}  
}  }

-- 
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693, Greenbelt, MD 20771
schinder@leprss.gsfc.nasa.gov


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

Date: 13 Mar 1998 18:21:10 -0500
From: Uri Guttman <uri@sysarch.com>
To: chris@ixlabs.com
Subject: Re: Problem stripping Mac headers off of GIF's
Message-Id: <x7lnuexjmh.fsf@sysarch.com>

Chris Schoenfeld <chris@ixlabs.com> writes:

> #!/usr/bin/perl -w
> use strict;
> 
> use File::Copy;
> 
> defined $ARGV[0] or die "Usage: $0 [files...]";
> my @gifin;
> my $gifin;
> 
> foreach(@ARGV){
>         next && print STDERR "Cannot read $_\n" unless -r $_;
>         next && print STDERR "Cannot copy $_ to $_.bak" unless
> copy($_,"$_.bak");
>         next && print STDERR "Cannot open $_ for reading\n" unless
> open(MACIN,"$_.bak");
>         next && print STDERR "Cannot open $_.gif for writing" unless
> open(GIFOUT,">./$_");
> 
>         $gifin=join('',<MACIN>);

this is a big waste. set $/ to undef and read the file in as one long string.

> 
>         print 'yes' if $gifin=~s/^(.*)(GIF89.*)$/$2/;

several points here, use .+ since you know you will match chars. .* could
match nothing and is slower.  also if by chance the string GIF89 were in
the actual binary GIF data you would delete all the binary data up to
that string. use non-greedy modifier to match until the first appearance
of GIF89. finally you don't have to match the text after the GIF89 and
sub it back in, just sub in the GIF89 for itself
this should work.

	$gifin =~ s/^.+?(GIF89)/$1/;

or this might be a little faster

	$gifin =~ s/^.+?GIF89/GIF89/;
 
>         print GIFOUT $gifin;
> 
>         close MACIN;
>         close GIFOUT;
> 
> }

a much shorter and faster (untested) version is :


#!/usr/bin/perl -0pi.bak

print 'yes' if s/^.+?GIF89/GIF89/ ;

if you want it explained i will post one.

uri

-- 
Uri Guttman                     SYStems ARCHitecture and Software Engineering
uri@sysarch.com                                          Have Perl, Will Hack
http://www.sysarch.com                (781) 643-7504 x*2  FAX: (781) 643-2710
Try the Best Search Engine on the Net -------->  http://www.northernlight.com


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

Date: Fri, 13 Mar 1998 23:19:19 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Problem stripping Mac headers off of GIF's
Message-Id: <Eps647.JtM@world.std.com>

Chris Schoenfeld <chris@ixlabs.com> writes:

>Often, they will email me GIF's which have (what I assume is) Macintosh
>binary header information on them, rendering them useless on anything
>else..

If the files are encoded in "MacBinary II" format, there are exactly
128 bytes of header information. Certain parts of the header contain
the lengths of the data fork and resource fork that follow. If there
is no resource fork, (Does the GIF file format deal well with trailing
garbage?) you could just skip the header.

open MACGIF, "<$in_filename" or die "Can't open $in_filename: $!\n";
open GIF, ">$out_filename" or die "Can't open $out_filename: $!\n";
$buffersize = (stat GIF )[11] || 4096;
seek MACGIF 128, 0;

while(read MACGIF, $buffer, $buffersize) {
  print GIF $buffer;
}

>[read the GIF file into an array, and join '' it into a $gifin]

>$gifin=~s/^(.*)(GIF8\d.*)$/$2/;

One problem with this method, is that the dot will not match the
(local operatorating systems interpretation of a) newline character
unless the "/s" modifier is appended to the substitution operator. So
on a unix system if any byte in the file equals 10 decimal, your match
will fail. (any 10 in the MacBinary header will caause the first
dot-star to tail, any 10 in the GIF data will cause the second one to
do so.)

If you want to perform a more detailed MacBinary conversion, take a
look at the spec at <URL:http://www.netreach.net/people/leonardr/
macbinary/macbinary_ii.html>

-- 
Andrew Langmead


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

Date: 13 Mar 1998 18:25:40 -0600
From: John Goerzen <jgoerzen@southwind.net>
Subject: Reference to a part of a hash?
Message-Id: <r6zg1kmgltn.fsf@peridot.southwind.net>

Hi,

I am wanting to create a reference to an entity in a hash...  For
instance...

%hash = ('asdf' => 'qwerty');

$ref = \{$hash{asdf}};

However, this doesn't work.  Any idea how to do this?

Thanks,
John

-- 
John Goerzen                              Southwind Internet Access, Inc.
E-mail: Business, jgoerzen@southwind.net; Personal, jgoerzen@complete.org
Computer Science Dept., Wichita State University,    jgoerzen@cs.twsu.edu
Developer, Debian GNU/Linux                       <http://www.debian.org>


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

Date: Fri, 13 Mar 1998 15:22:53 -0800
From: ryan pc gibson <ryanpc@lbin.com>
Subject: Re: regexp list context substitution
Message-Id: <3509BFCD.D7BC913C@lbin.com>

i figured out how to do this by converting array to multiline string with
$html = join('',@html);
i always thought string ended at first newline.  amazing.

ryanpc

ryan pc gibson wrote:

> hello,
>
>     how can i apply a substitution regexp to an array?  for example:
>
>     @html = <FH>;
>     @html =~ s/<tr>(.*)<\/tr>/<tr align=center>$1<\/tr>/sm;
>
>     ...perl compiler complains that it can't modify array deref in
> substitution.  any ideas?
>
>     i am tired of coding around this, and have been unable to unearth
> anything regarding why it can not be done.  this seems like it would be
> a common enough task.
>
>     going loopy looping - ryanpc.
>
> --
> ::__________ Ryan PC Gibson __________________________
> ::__webmaster:
> ::___________  lightbinders, inc., san francisco, ca__



--
::__________ Ryan PC Gibson __________________________
::__webmaster:
::___________  lightbinders, inc., san francisco, ca__




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

Date: 13 Mar 1998 17:59:34 -0500
From: Uri Guttman <uri@sysarch.com>
To: lespin03@cs.fiu.edu
Subject: Re: regular expressions and control characters
Message-Id: <x7ogzaxkmh.fsf@sysarch.com>


luis a espinal <lespin03@fiu.edu> writes:

> Given a text file that may contain ^U or ^D ( these are actual ascii
> chars
> '^' and 'U', 'D' not the actual ^U and ^U ), I need to replace those
> substrings by the real ^U and ^D. I did that already with
> s/^U/\xU/g;
> s/^D/\xD/g;

this is your first mistake. \xU is meaningless as U is not a valid hex
char. you probably mean \cU which is ^U (the real thing)
 
> The problem is that I haven't been able to do the following:
> $a="D"; # or "U"
> s/^\\$a/\x\\$a/g;

why are you (single or double) backslashing $a? it should be bare in
both cases. also the bare ^ is going to be the beginning of string
anchor and not a literal ^ which is what you want.

this works directly from the ^D form to the control char for all A-Z

s/\^([A-Za-z])/qq("\\c$1")/eeg ;

i leave it as an exercise to figure out how it works. i will post the
answer if asked enough times or i don't get tons of followups explaining
it first.

uri

-- 
Uri Guttman                     SYStems ARCHitecture and Software Engineering
uri@sysarch.com                                          Have Perl, Will Hack
http://www.sysarch.com                (781) 643-7504 x*2  FAX: (781) 643-2710
Try the Best Search Engine on the Net -------->  http://www.northernlight.com


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

Date: 13 Mar 1998 22:31:35 GMT
From: Stefaan.Eeckels@ecc.lu (Stefaan A. Eeckels)
Subject: Re: User-interface Quandary
Message-Id: <6ecc47$3p1$1@justus.ecc.lu>

In article <6ebsam$lfv$1@csnews.cs.colorado.edu>,
	Tom Christiansen <tchrist@mox.perl.com> writes:
> In short, they compile into this, searching for "Fred"
> 
>     Anywhere		    /Fred/
>     Whole Words Only 	    /\bFred\b/
>     Entire Field	    /^Fred$/
> 
> My problem is that I have not in several years come up with anything
> conveys the /^Fred$/ case.  I've tried `Entire', but the users always
> think that it means search the entire field, which of course is what
> `Anywhere' does.  I've tried `Exact' as in fgrep -x, but because I also
> sometimes have a `Fuzzy' option for agrep style mistakes, they think that
> `Exact' is merely intolerate of spelling errors.
> 
> Is there some obvious word or phrase I could use for the /^Fred$/ case?
> I have tried a long time, and nothing seems to work.  Users never ever
> understand this.

How about 'Exact match', or 'Pattern only'?

I sympathise - I've grown used to regexes (ed, vi, sed,
egrep, awk, perl...) and they allow incredible feats of
locating and modifiying text, but they're almost impossible
to explain to people who haven't used them. 

Keep up the good work,

-- 
Stefaan
-- 

PGP key available from PGP key servers (http://www.pgp.net/pgpnet/)
___________________________________________________________________
  "Don't worry about people stealing your ideas.  If your ideas
   are any good, you'll have to ram them down people's throats."
                                                -- Howard Aiken


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

Date: 13 Mar 1998 16:58:27 -0500
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: User-interface Quandary
Message-Id: <87ogzagsn0.fsf@tbone.biol.sc.edu>

Tom Christiansen <tchrist@mox.perl.com> writes:
 ...
> Imagine this phrase:
> 
>     "My name is Fred"
> 
> I provide three choices:
> 
>     Anywhere
>     Whole Words Only 
>     Entire Field
 ...
>     Entire Field	    /^Fred$/
> My problem is that I have not in several years come up with anything
> conveys the /^Fred$/ case.  I've tried `Entire', but the users always
 ...

Depending on the context, how about something like:

Search string: ________________
The search string can match:
   * anywhere
   * only as complete words
   * only as the entire entry

I'd be careful to avoid buzzwords that mean things to us, but may not
to "point and drool"ers: key, field, record, string (yeah, well - I
used it since its meaning should be clear by connection with the
"search string" the user just entered), etc.

-Dean
-- 
N. Dean Pentcheff                                          <pentcheff@acm.org>
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-7068)


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

Date: Fri, 13 Mar 1998 18:33:24 -0600
From: shaker@netusa1.net
Subject: Re: User-interface Quandary
Message-Id: <6ecj5o$c6h$1@nnrp1.dejanews.com>

In article <6ebsam$lfv$1@csnews.cs.colorado.edu>,
  tchrist@mox.perl.com (Tom Christiansen) wrote:
>

< snip >

> I provide three choices:
>
>     Anywhere
>     Whole Words Only
>     Entire Field
>

How about the following alternatives for the above three (in order) ?

Match of Letters

Match of Words

Match of Whole Phrase

(The 'Match of' may be left out for conciseness.)

V. Chandrasekhar

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Fri, 13 Mar 1998 19:38:38 -0500
From: Bob Trieger <sowmaster@juicepigs.com>
Subject: Re: What?
Message-Id: <3509D18E.37A3@juicepigs.com>

Rich Grise wrote:
> 
> What?

Where?


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

Date: Fri, 13 Mar 1998 17:54:53 -0600
From: Mike McMillan <mmcm@swbell.net>
Subject: Writing to a socket
Message-Id: <3509C74D.4B73@swbell.net>

Hi.

I have inherited a socket app (written in C) where the client sends
requests as byte streams. Some Java code that sends requests uses the
writeBytes methods, as in:

out.writeBytes("somestring");

How can I implement something like the writeBytes method in Perl? I've
tried syswrite, write, print and none of them work.

Thanks.

Mike McMillan
T4 Systems, Inc.
mmcm@swbell.net


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

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 2094
**************************************

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