[18754] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 922 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 17 09:05:50 2001

Date: Thu, 17 May 2001 06:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <990104713-v10-i922@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 17 May 2001     Volume: 10 Number: 922

Today's topics:
    Re: \npeter <bart.lateur@skynet.be>
    Re: An Example Of A Polite FAQ <bart.lateur@skynet.be>
        check if file exists with different extensions <nospam@peng.nl>
        dynamic name for hashtable ... <Marc.Grietens@REMOVE-THIS.alcatel.be>
    Re: dynamic name for hashtable ... <Peter.Dintelmann@dresdner-bank.com>
    Re: find.pl private to Perl? <bart.lateur@skynet.be>
    Re: find.pl private to Perl? <koos_pol@nl.compuware.com.NOJUNKMAIL>
    Re: find.pl private to Perl? <a.v.a@home.nl>
    Re: find.pl private to Perl? (Anno Siegel)
    Re: find.pl private to Perl? <a.v.a@home.nl>
    Re: find.pl private to Perl? <bart.lateur@skynet.be>
    Re: find.pl private to Perl? <a.v.a@home.nl>
        FOUND IT dynamic name for hashtable ... <Marc.Grietens@REMOVE-THIS.alcatel.be>
    Re: Hashes and such ... help ! <koos_pol@nl.compuware.com.NOJUNKMAIL>
    Re: help needed in regex alternation (Anno Siegel)
        i want to tokenize a string <nachoman@ehpt.com>
    Re: i want to tokenize a string (Rafael Garcia-Suarez)
    Re: i want to tokenize a string (Anno Siegel)
    Re: i want to tokenize a string <peb@bms.umist.ac.uk>
    Re: i want to tokenize a string (Anno Siegel)
    Re: perl/XML question <thunderbear@bigfoot.com>
    Re: Random Numbers Script <a.v.a@home.nl>
        readline  is strange on WinNT <UKDED2@ukgateway.net>
    Re: Sending wav-file through perl-script <rebelvideo@hotmail.com>
        timeout after STDIN ? <ramos@terra7.de>
    Re: timeout after STDIN ? (Anno Siegel)
    Re: timeout after STDIN ? (Bernard El-Hagin)
    Re: timeout after STDIN ? <ramos@terra7.de>
    Re: timeout after STDIN ? (Bernard El-Hagin)
    Re: To compress and uncompress text files ? (Eric Bohlman)
    Re: To compress and uncompress text files ? <bart.lateur@skynet.be>
        transform html to xhtml <marco@uni.de>
    Re: URGENT: CGI program wanted! <hafner-usenet@ze.tu-muenchen.de>
    Re: What's wrong with my scope? (J.C.Posey)
    Re: Win32 fork() getting memory errors <rebelvideo@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 17 May 2001 10:21:39 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: \npeter
Message-Id: <n897gts90rr8cq0qkkfsmmen2p80qo6u7h@4ax.com>

Craig Berry wrote:

>jtjohnston (jtjohnston@courrier.usherb.ca) wrote:
>: I am parsing the contents of a text file.
>: I have certain lines that start with "&&4;" I would like to attach these
>: lines to the previous line as follows. But I don't know how. I figure I
>: have to search and replace for "\n&&4;" but ... ?
>
>If your file can fit in memory as a whole, just slurp it into a single
>scalar using any of the standard idioms, and then do
>
>  $text =~ s/\n(?=&&4;)//g;

That is quite beautiful. Unfortunately, this memory thing is one of the
limitations for perl regexes.

You could set $/ to "\n&&4;", then that would be the end of each "line"
read. But if the file is big and it contains very few of such string,
than the same memory problem remains.

You can also use the "lag one line" approach. You keep one line in a
buffer, and depending on what's in the next line, either remove the
newline, or not.

	my $previous;
	while(<>) {
	    defined $previous or next;
	    chop($previous) if /^&&4;/;
	    print $previous;
	} continue {
	    $previous = $_;
	}
	print $previous if defined $previous;

-- 
	Bart.


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

Date: Thu, 17 May 2001 10:41:10 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: An Example Of A Polite FAQ
Message-Id: <sha7gtkhn4lj8ui3uk9g54h64isplibout@4ax.com>

Godzilla! wrote:

>Welcome to comp.lang.perl.misc newsgroup!
 ...

Not bad. Not bad at all.

Except for this:

>3.  Social faux pas to avoid
>     3d. Getting along with others

Eh? You are wrong if you're trying to get along with others?

The text under this heading surely points the other way, so this is a
case of where the combination of these headings says something other
than they would do by themselves.
 
-- 
	Bart.


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

Date: Thu, 17 May 2001 12:24:00 GMT
From: "Lex" <nospam@peng.nl>
Subject: check if file exists with different extensions
Message-Id: <ApPM6.143329$Uo2.3806444@zwoll1.home.nl>

Hi,

question:

I have a perlscript that checks if a certain file exists, if so, it is shown
on a web page.
The code I'm using is:

 my $sourcefile = $rec{'ID'} ."a.gif";
 my $thumbfile  =
'/usr/home/lex/htdocs/btsbos.nl/portfolio/fotos/'.$sourcefile;

if (-e $thumbfile) {
print qq|
<td><img src="http://www.peng.nl/btsbos.nl/portfolio/fotos/$rec{'ID'}a.gif"
alt="" border="0">
</td>
|;
}


Now this works fine, but i'd like to change something.

It only works fine if the image has the extension .gif .
I would like it to work no matter if it is a .jpg .jpeg .gif .png (or all
those in capitals)

I don't know how to accomplish this.

Can somebody help?

Thanks,

Lex




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

Date: Thu, 17 May 2001 13:53:29 +0200
From: Marc GRIETENS <Marc.Grietens@REMOVE-THIS.alcatel.be>
Subject: dynamic name for hashtable ...
Message-Id: <3B03BBB9.CFA53576@REMOVE-THIS.alcatel.be>

Hellow,

i wonder if someone can help me out here...
or point me in the right direction...

i have a subroutine that does some things and then add the result to a
hash table.
The problem is that the name of the hashtable is not defined/known when
the program will be running


sub AddLine
  { #arg 1 : hashtable name
    #arg 2 : thing to add
    #arg 3 : value

   <do some things>

   print "@_[0]";
   @_[0]{@_[1]}=@_[2]; 
  }

for the last line i've tried several things ... adding $ signs,
backslashes and whatever i could think of...
but i didn't get the desired result or gave only syntax errors ...:(

from the main program, i just do Addline{table,$key,$value}
also tried: Addline{\%table,$key,$value}
without succes however :(

Any help would be appreciated...

Thanx,
Marc


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

Date: Thu, 17 May 2001 14:18:17 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: dynamic name for hashtable ...
Message-Id: <9e0f36$bpd6@news-1.bank.dresdner.net>

    Hi,

"Marc GRIETENS" <Marc.Grietens@REMOVE-THIS.alcatel.be> wrote in message
news:3B03BBB9.CFA53576@REMOVE-THIS.alcatel.be...

    [snip]

> i have a subroutine that does some things and then add the result to a
> hash table.
> The problem is that the name of the hashtable is not defined/known when
> the program will be running

    have you thought of returning a reference to
    a hash from your sub?

        Peter





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

Date: Thu, 17 May 2001 10:51:37 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: find.pl private to Perl?
Message-Id: <b5b7gt4bif2knlpj6m1cg8u7e58ki4m7m4@4ax.com>

Koos Pol wrote:

>Is find.pl private to Perl? I mean, is it internally used by Perl any 
>nowhere else and does Perl call it with a full path (/.../.../.../find.pl)? 
>I wrote a search script and wanted to call it find.pl. But I just 
>discovered there already is a find.pl in the Perl distribution. It would 
>not be smart of me to use this name if it could possibly break Perl...
>Anyone?

Don't worry. This file is the old perl4 library file, which is now
superceded by File::Find (Find.pm in a directory File). Unless you still
have (old) scripts that 'require "find.pl";', these won't ever
interfere.

-- 
	Bart.


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

Date: Thu, 17 May 2001 13:12:50 +0200
From: Koos Pol <koos_pol@nl.compuware.com.NOJUNKMAIL>
Subject: Re: find.pl private to Perl?
Message-Id: <9e0bni$mle@news.nl.compuware.com>

Bart Lateur wrote:

> Koos Pol wrote:
> 
> >Is find.pl private to Perl? I mean, is it internally used by Perl any
> >nowhere else and does Perl call it with a full path
> >(/.../.../.../find.pl)? I wrote a search script and wanted to call it
> >find.pl. But I just discovered there already is a find.pl in the Perl
> >distribution. It would not be smart of me to use this name if it could
> >possibly break Perl... Anyone?
> 
> Don't worry. This file is the old perl4 library file, which is now
> superceded by File::Find (Find.pm in a directory File). Unless you still
> have (old) scripts that 'require "find.pl";', these won't ever
> interfere.
> 

Thanks for the clarification Bart. Time to submit an "Announce:" post :-)
Cheers,

-- 
Koos Pol - Systems Administrator - Compuware Europe B.V. - Amsterdam
koos_pol@nl.compuware.com_NO_JUNK_MAIL



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

Date: Thu, 17 May 2001 12:10:58 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: find.pl private to Perl?
Message-Id: <3B0397E8.5F5375B7@home.nl>

Koos Pol wrote:

> Hello all,
>
> Is find.pl private to Perl? I mean, is it internally used by Perl any
> nowhere else and does Perl call it with a full path (/.../.../.../find.pl)?
> I wrote a search script and wanted to call it find.pl. But I just
> discovered there already is a find.pl in the Perl distribution. It would
> not be smart of me to use this name if it could possibly break Perl...
> Anyone?
>
> Cheers,
> --
> Koos Pol - Systems Administrator - Compuware Europe B.V. - Amsterdam
> koos_pol@nl.compuware.com_NO_JUNK_MAIL

no you can name it find.pl aslong as u put it in an other dir.
you can have 1000's of find.pl's if u like.



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

Date: 17 May 2001 12:28:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: find.pl private to Perl?
Message-Id: <9e0g5c$9qv$5@mamenchi.zrz.TU-Berlin.DE>

According to AvA  <a.v.a@home.nl>:

> no you can name it find.pl aslong as u put it in an other dir.
> you can have 1000's of find.pl's if u like.

I believe I'm not alone in saying I'd prefer if you used complete
words in your postings.  "U" for "you" and the like were once
fashionable, but these days they're falling out of favor even on IRC,
not to mention Usenet.

Anno


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

Date: Thu, 17 May 2001 12:27:04 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: find.pl private to Perl?
Message-Id: <3B039BAF.AA453135@home.nl>

Anno Siegel wrote:

> According to AvA  <a.v.a@home.nl>:
>
> > no you can name it find.pl aslong as u put it in an other dir.
> > you can have 1000's of find.pl's if u like.
>
> I believe I'm not alone in saying I'd prefer if you used complete
> words in your postings.  "U" for "you" and the like were once
> fashionable, but these days they're falling out of favor even on IRC,
> not to mention Usenet.
>
> Anno

irc destroyed my english



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

Date: Thu, 17 May 2001 12:37:27 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: find.pl private to Perl?
Message-Id: <vhh7gtkpgf8f3ptbmoga9e2i70hfcv8ep2@4ax.com>

AvA wrote:

>irc destroyed my english

"I Recall Correctly"?

Don't answer.

-- 
	Bart.


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

Date: Thu, 17 May 2001 12:47:21 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: find.pl private to Perl?
Message-Id: <3B03A06F.4B5ECDE8@home.nl>

Bart Lateur wrote:

> AvA wrote:
>
> >irc destroyed my english
>
> "I Recall Correctly"?
>
> Don't answer.

I wont




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

Date: Thu, 17 May 2001 14:11:52 +0200
From: Marc GRIETENS <Marc.Grietens@REMOVE-THIS.alcatel.be>
Subject: FOUND IT dynamic name for hashtable ...
Message-Id: <3B03C008.9121BB96@REMOVE-THIS.alcatel.be>

Marc GRIETENS wrote:
> <snip>
>
>   @_[0]{@_[1]}=@_[2];
>   }


This worked for me :)

@_[0]->{@_[1]}=@_[1]; 

and in the main:
Addline(\%table,$key,$value)


any comments/remarks/suggestions are still welcome however.

cya
MArc


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

Date: Thu, 17 May 2001 12:00:04 +0200
From: Koos Pol <koos_pol@nl.compuware.com.NOJUNKMAIL>
Subject: Re: Hashes and such ... help !
Message-Id: <9e07f4$k4r@news.nl.compuware.com>

grodan_kermit wrote:

> Hi everybody,
> 
> I'm having trouble understanding the first line in this snippet :
> 
> foreach $data (@{$result->[0]->{"data"}}) {

$result points to an array
the array elements (e.g. $result->[0]) point to a hash
the hash elements (e.g. $result->[0]->{"data"}) contain a list
@ makes sure that this list is interpreted as a list

HTH

-- 
Koos Pol - Systems Administrator - Compuware Europe B.V. - Amsterdam
koos_pol@nl.compuware.com_NO_JUNK_MAIL



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

Date: 17 May 2001 11:25:47 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: help needed in regex alternation
Message-Id: <9e0cfr$9qv$2@mamenchi.zrz.TU-Berlin.DE>

According to Gavin Sherlock  <sherlock@genome.stanford.edu>:
> Hi,
>    I have some line of text that I want to check for matches, that eg
> may be like:
> 
> p53||p53 encoding protein||tp53
> 
> and then say I have some input, p53, that I want to match against that
> text, but only to a whole entry, where whole entries are delimited by
> double pipes.  I did try:
> 
> if ($text =~ /\b$input\b/){ #stuff }
> 
> but this still gets the middle guy, when I only want the first one. 
> Really, want I want to say is just before the regex, either be the
> start of the string, or be a pipe, and after the regex, either be a
> pipe, or the end of the string.  It seems that I can't have an
> alternation between a pipe and the beginning/end of a string, eg,
> something like:
> 
> if ($text =~ /(^|\|)\b$input\b(\||$)/){ #stuff }
> 
> but obviousy you can't alternate caret or dollar to get them to mean
> beginning or end.  Is there a way I can do this?

As Tad has mentioned, your regex should do exactly what you want.
 
> I do know that I can split my string on double-pipes first, but I have
> many thousands of lines to go through.  With my 'not-quite-right'
> regex, it takes about 2 seconds to go through the file, doing the
> split, and checking each element takes about 10 fold-longer.

Since speed is a concern, you might want to benchmark another
approach:  Frame your text and the input in "|" and use index
to find an exact match:

    if ( index( "|$text|", "|$input|" ) >= 0 ) { ...

Anno



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

Date: Thu, 17 May 2001 10:18:25 GMT
From: nachoman <nachoman@ehpt.com>
Subject: i want to tokenize a string
Message-Id: <1103_990094705@kspc377>

if i have a string like

"mooo     ninja randy    dandy"

and use the split command

i get

"mooo"
"ninja"
"randy"
"dandy"

however i want to include the whitespaces up to the next word and get the output like this

"mooo   "
"ninja "
"randy   "
"dandy"

any suggestions on how to do this?



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

Date: 17 May 2001 10:29:44 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: i want to tokenize a string
Message-Id: <slrn9g7a33.s75.rgarciasuarez@rafael.kazibao.net>

nachoman wrote in comp.lang.perl.misc:
} if i have a string like
} 
} "mooo     ninja randy    dandy"
} 
} and use the split command
} 
} i get
} 
} "mooo"
} "ninja"
} "randy"
} "dandy"
} 
} however i want to include the whitespaces up to the next word and get the output like this
} 
} "mooo   "
} "ninja "
} "randy   "
} "dandy"
} 
} any suggestions on how to do this?

Play with assertions in your split regexp. The following works for your
example :

  my @tokens = split /\b(?=\w)/, $string;

Look in perlre for details.

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


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

Date: 17 May 2001 10:42:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: i want to tokenize a string
Message-Id: <9e09uh$5t2$2@mamenchi.zrz.TU-Berlin.DE>

According to nachoman  <nachoman@ehpt.com>:
> if i have a string like
> 
> "mooo     ninja randy    dandy"
> 
> and use the split command

How do you use the split command?  There are many ways.

> i get
> 
> "mooo"
> "ninja"
> "randy"
> "dandy"
> 
> however i want to include the whitespaces up to the next word and get
> the output like this
> 
> "mooo   "
> "ninja "
> "randy   "
> "dandy"
> 
> any suggestions on how to do this?

Split on the beginning of each word.  The pattern to do this could be
/\b(?=\w)/, that is, a word boundary, followed by a character that
begins a word.  Note that both \b and (?=\w) are zero-width assertions,
so the pattern matches wherever a word begins without consuming any
text.

Anno


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

Date: Thu, 17 May 2001 12:51:00 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: i want to tokenize a string
Message-Id: <3B03BB24.A7CF72DA@bms.umist.ac.uk>

Rafael Garcia-Suarez wrote:
> 
> nachoman wrote in comp.lang.perl.misc:
> } if i have a string like
> }
> } "mooo     ninja randy    dandy"

<snip split results>

> }
> } however i want to include the whitespaces up to the next word and get the output like this
> }
> } "mooo   "
> } "ninja "
> } "randy   "
> } "dandy"
> }
> } any suggestions on how to do this?
> 
> Play with assertions in your split regexp. The following works for your
> example :
> 
>   my @tokens = split /\b(?=\w)/, $string;

You'll get told off by Randal when he sees this ;-)

How did he put it... (this isn't a literal quote) "Use a pattern match
when you know what you want to keep. Use split when you know what you
want to throw away."

how about something like:-

$string = "mooo     ninja randy    dandy";
@results = $string =~ m/(\w+\s+)/g;

Paul


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

Date: 17 May 2001 11:58:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: i want to tokenize a string
Message-Id: <9e0ecj$9qv$4@mamenchi.zrz.TU-Berlin.DE>

According to Paul Boardman  <peb@bms.umist.ac.uk>:
> Rafael Garcia-Suarez wrote:

[snip]

> >   my @tokens = split /\b(?=\w)/, $string;
> 
> You'll get told off by Randal when he sees this ;-)
> 
> How did he put it... (this isn't a literal quote) "Use a pattern match
> when you know what you want to keep. Use split when you know what you
> want to throw away."
> 
> how about something like:-
> 
> $string = "mooo     ninja randy    dandy";
> @results = $string =~ m/(\w+\s+)/g;

Fair enough, but the rule, as stated, doesn't decide this case.  We
know both what to keep (whole words plus trailing spaces) and what
to throw away (nothing, but we want to throw it away at the beginning
of each word :).

Anno



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

Date: Thu, 17 May 2001 13:23:13 +0100
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: perl/XML question
Message-Id: <3B03C2B1.65CC1DA4@bigfoot.com>

"Peter Søgaard" wrote:

> Hmm, never mind...I found out ;)
> 
> Content-Type: text/xml\n\n
> 
> worked this time (it didn't yesterday ;) )

Reloading a document does not always pickup changes in the MIME-type in
IE.  When changing that, start up a fresh browser.

-- 
  Thorbjørn Ravn Andersen                "...plus...Tubular Bells!"
  http://bigfoot.com/~thunderbear


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

Date: Thu, 17 May 2001 12:20:52 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: Random Numbers Script
Message-Id: <3B039A3A.FA1BA48B@home.nl>

sas wrote:

> Does anyone have a script that will generate random numbers? Someone told me
> I could do it with Perl but I don't know where to start. It must be a 5
> digit random number which will be associated with a specific name, (an "ID"
> number), I want to check against a log file to be sure the number hasn't
> been used already and then add the number and associated name to that log
> file.  Any help will be greatly appreciated.
> Thanks
> sas
> saras@gj.net

creating a random number aint so difficult:

for ($i = 0;  $i < 5; $i++){
    $number .= $array[rand(@array = (0..9))];
}
print $number , "\n";





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

Date: Thu, 17 May 2001 11:58:57 +0100
From: "Timeon de Marque" <UKDED2@ukgateway.net>
Subject: readline  is strange on WinNT
Message-Id: <3b03af9e$0$15030$cc9e4d1f@news.dial.pipex.com>

Probably 'cos I am new at this but
and installation script I wrote asks for
input and reads it using 'readline STDIN'

This works on Win95, Win98 but
on WinNT4 it rattles through the script not
stopping for breath at the readline.

What am I missing here?  Is there a subtle
buffering difference in the two operating systems.

Works with $line = <STDIN> as an alternative,
I just want to know that the NT problems is.

Cheers,

Ti






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

Date: Thu, 17 May 2001 21:02:10 +0930
From: Chris <rebelvideo@hotmail.com>
Subject: Re: Sending wav-file through perl-script
Message-Id: <3B03B6BA.42495E6C@hotmail.com>


Scroll down

"Godzilla!" wrote:
> 
> Chris wrote:
> 
> (snipped previous article)
> 
> > to get around the "inherent problem' (see below) and still process the
> > wave file with your script
> 
> > you could try calling the script in this fashion
> 
> > http://mydomain.com/cgi-bin/waveprocess.pl?sound.wav
> 
> > the browser sees the last .wav and uses that as the file extension and
> > therefore the helper program gets a proper extension
> 
> > I am not sure if this will work with all browsers on all platforms, but
> > give it a try
> 
> My compliments. I tried your method and it does work
> on a Sun Solaris / Mozilla 4.x combination. This will
> most likely work on many system / browser combinations.

Ta :)

> 
> I did not test removal of the binmode of the filehandle.
> However, this is more of a system specific consideration.

true

> 
> Additional tests were run with printing to a logfile,
> in addition to my test scripts above, as is. This was
> also successful. This would be a good method to log
> accesses to a binary file and keep a file location
> relatively hidden.

It allows me to check and see if a user is registered before sending a file to them 
redirections reveal the location of the file and so are not secure
you can keep the file outside of your html directory and then no-one can access it at all except through your script.

also if you send a 401 response the browser will automatically ask for a username and password
neat especially if your ISP doesn't allow you to use password protected directories or wants to charge you for the privilege.

the same script will work with different files and types

http://mydomain.com/cgi-bin/waveprocess.pl?sound1.wav
http://mydomain.com/cgi-bin/waveprocess.pl?sound2.mid

$file = $ARGV[0];

if ($file =~ /\.mid$/i)
{
 print "Content-type: audio/midi\n\n";
}
else
{
 print "Content-type: audio/wave\n\n";
}

open (IN, "/internal/path/to/resources/$file");
binmode (IN);
while (<IN>)
 { print $_; }
close (IN);


> 
> Still, there is a bit of a letdown in having to dedicate
> a script to this single function of printing a binary
> and printing to a file handle which does not require a
> Content-type, 

see above example

The print statement does need a content-type, because your are not "printing" to a disk you are printing to a browser
just the same as some OS's need the binmode() which is the same as a Content-type.

ergo...

sub BinMode {
my $type = shift;

	if ($type =~ /\.mid$/i)
	{
	 "Content-type: audio/midi\n\n";
	}
	else
	{
	 "Content-type: audio/wave\n\n";
	}
}

and the script becomes...

$file = $ARGV[0];

open (IN, "/internal/path/to/resources/$file");
binmode (IN);
print BinMode($file);
while (<IN>)
 { print $_; }
close (IN);


> with no ability to generate a page for
> viewing via a browser, with sounds.


If you wish to embed a sound file into a generated file 
simply add the above link as an <embed> tag or similar

at least using this method you can modify the web page to suit the web browser 

eg:
	if ($browser eq 'ie')
	{
	  print '<object width="32" height="32" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="SRC" value=http://mydomain.com/cgi-bin/waveprocess.pl?sound.wav"> </object>';
	}
	elsif ($browser eq 'netscape')
	{
	 print '<embed src="http://mydomain.com/cgi-bin/waveprocess.pl?sound.wav"></embed>'; 
	}
	else # unknown browser??
	{
	  print '<A HREF="http://mydomain.com/cgi-bin/waveprocess.pl?sound.wav" >Click here to for lotsa noise</A>';
	}
 

> 
> This will work though as a hot link within a page,
> if a file location is to be kept relatively hidden.
> Not as fast as a direct link, but works!
> 
> Say, you have any secret methods for printing both
> html and a binary file with one script?

? I am not sure what you mean by this.

are you saying the user clicks on a link and a web page is displayed, and once displayed the browser commences the download of a binary file?

If so, I can think of one method that would work

include a refresh header in the generated html

print '<meta http-equiv="refresh" content="1;URL=sound.wav">';

this will load and display the web page and one second later start to load the wav file, without removing the web page
a time of zero will cancel the redirect

> 
> Godzilla!


-- 
Regards

Chris
rebelvideo@hotmail.com


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

Date: Thu, 17 May 2001 13:23:59 +0200
From: "Sebastian Ramos" <ramos@terra7.de>
Subject: timeout after STDIN ?
Message-Id: <9e0c6m$e6ik$1@ID-63849.news.dfncis.de>

Hello,

i want my perlscript to continue with next line if nothing happens after
waiting 10 seconds for $input = <STDIN>;

is this possible without the use of any sockect or IO ???


thanks in advance

Sebastian Ramos





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

Date: 17 May 2001 11:32:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: timeout after STDIN ?
Message-Id: <9e0crr$9qv$3@mamenchi.zrz.TU-Berlin.DE>

According to Sebastian Ramos <ramos@terra7.de>:
> Hello,
> 
> i want my perlscript to continue with next line if nothing happens after
> waiting 10 seconds for $input = <STDIN>;

This is a FAQ, and "perldoc -q timeout" takes you there.  You are
supposed to check the FAQ before posting here.
 
> is this possible without the use of any sockect or IO ???

Huh?  Why would you think you need a socket or IO to do that?
And if, in another universe, these were useful, why wouldn't
you want to use them?

Anno


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

Date: Thu, 17 May 2001 11:36:58 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: timeout after STDIN ?
Message-Id: <slrn9g7de5.pk3.bernard.el-hagin@gdndev25.lido-tech>

On Thu, 17 May 2001 13:23:59 +0200, Sebastian Ramos <ramos@terra7.de> wrote:
>Hello,
>
>i want my perlscript to continue with next line if nothing happens after
>waiting 10 seconds for $input = <STDIN>;

This is a FAQ, you know.

alarm (10) or $input = <STDIN>;

>is this possible without the use of any sockect or IO ???

<boggle>

Cheers,
Bernard


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

Date: Thu, 17 May 2001 14:01:16 +0200
From: "Sebastian Ramos" <ramos@terra7.de>
Subject: Re: timeout after STDIN ?
Message-Id: <9e0eak$eghq$1@ID-63849.news.dfncis.de>

"Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> schrieb im Newsbeitrag
news:slrn9g7de5.pk3.bernard.el-hagin@gdndev25.lido-tech...
[...]
> alarm (10) or $input = <STDIN>;
[...]

thanks a lot.
and: i will read FAQ :) sorry for that.

greets
Sebastian Ramos




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

Date: Thu, 17 May 2001 12:17:13 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: timeout after STDIN ?
Message-Id: <slrn9g7fpm.6co.bernard.el-hagin@gdndev25.lido-tech>

On Thu, 17 May 2001 14:01:16 +0200, Sebastian Ramos <ramos@terra7.de> wrote:
>"Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> schrieb im Newsbeitrag
>news:slrn9g7de5.pk3.bernard.el-hagin@gdndev25.lido-tech...
>[...]
>> alarm (10) or $input = <STDIN>;
>[...]
>
>thanks a lot.
>and: i will read FAQ :) sorry for that.

Please be advised that that is only an example which you'll have to
modify for your needs. Just read the FAQ and post your code if you can't
get it to work as you'd expect.

Cheers,
Bernard


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

Date: 17 May 2001 12:11:13 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: To compress and uncompress text files ?
Message-Id: <9e0f51$fo6$1@bob.news.rcn.net>

nosabi <nosabi@snospamabi.com> wrote:
> Hi Bart,
> Thank You for all the Great Info.

>> In what way? Are all ads being skimmed , filtered, and the appropriate
>> ones displayed? Or are you just displaying one ad at a time?

> The perl script just displays each ad into html tables.
> With the newest displayed at the top of the page.
> Nothing Fancy I guess. I'm an old time trs-80 enthusiast
> that use to love writting text adventure games, using lots of arrays.

OK, that basically means that every time the script runs it will have to
access all the records in any case, so you're not likely to gain any
speedup from using an RDBMS (the speed advantage of an RDBMS comes from
being able to selectively retrieve records without having to go through
all of them).  Reading the raw text is going to be as fast as you can get,
so it looks like disk space is the only thing you can do anything about.  
However, if the file is "small" enough that its entire contents can be
translated into an HTML page of a size that can reasonably be delivered to
and read by a user, then it's not big enough to worry about.  It's not
like we're talking tens of megabytes here.

The question is what you're going to do when the number of ads becomes to 
big to deliver them all as a single Web page, and you have to decide how 
you're going to deliver them before you can start thinking about 
implementation.



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

Date: Thu, 17 May 2001 12:34:29 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: To compress and uncompress text files ?
Message-Id: <jah7gt8rgr66sdrq8ev0updc6sq0jiv51c@4ax.com>

nosabi wrote:

>But Bart, what is the MySQL doing that is different from the old text array?

If you have, say, a few (ten)thousand of records, and you want to show
only some, based on some properties (like category), a database like
MySQL will do a faster job than reading and filtering them all yourself
in plain perl. If you're searching for one particular item, the speed
boost might be quite significant.

If you intend to show them all anyway, it doesn't really matter.

-- 
	Bart.


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

Date: Thu, 17 May 2001 14:36:24 +0200
From: "Marco Tölle" <marco@uni.de>
Subject: transform html to xhtml
Message-Id: <9e0gjt$s5m$01$1@news.t-online.com>

Hi !

Can anyone tell me how to transform HTML to XHTML using Perl ?
Is there a module ?

Thanks,
Marco




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

Date: 17 May 2001 12:21:48 +0200
From: Walter Hafner <hafner-usenet@ze.tu-muenchen.de>
Subject: Re: URGENT: CGI program wanted!
Message-Id: <srj7kzguvgj.fsf@w3proj1.ze.tu-muenchen.de>

Uri Guttman <uri@sysarch.com> writes:

> that web site is off limits. you just marked yourself as a disciple of
> the matt wright school of bad perl programming. 

Care to give an explanation of your statement?

-Walter


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

Date: 17 May 2001 12:29:30 +0100
From: jcp@myrtle.ukc.ac.uk (J.C.Posey)
Subject: Re: What's wrong with my scope?
Message-Id: <jkovgn01aed.fsf@myrtle.ukc.ac.uk>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:

> Your scoping is fine.  You don't quite understand Perl variables.

Okay, then mabye I need _this_ issue clarified. :)

[snip code]

> > my $file = $ARGV[0];
> > my %urls = ();
> 
> This declares the hash %urls.

Yes, that is what I want.

[snip more code]

> > 	$urls{$fields[1]} += [$fields[2], $fields[3], $fields[4], $fields[5]];
> 
> The above line is, well, nonsense.  "[$fields[2], ... $fields[5]]" is an
> array ref.  You can't reasonably add that to a scalar, as you are trying
> to do.  You probably meant to say
> 
>        $urls{$fields[1]} +=
>            $fields[2] + $fields[3] + $fields[4] + $fields[5];

Okay, I was under the impression to create a hash with an array you did:

	my $hash{"a_key"} = ["a value", "another", $my_var];

I just assumed one could use an array ref the same as a var. We all know
what happens when one *assumes* . . . but it's just me!

> But this has nothing to do with your question.

I believe you.

[snip even more code]

> > for my $domain (sort keys %urls){
> >     print $domain, @{ $urls->{$domain}}."\n";
> 
> Here you are accessing the scalar variable $urls.  It would have
> to contain an array reference to be usable this way, but since
> it has never been declared, Perl complains.  Lose the "->".

I was trying to create an array reference...hmmm, didn't quite get there.
 
> If you look at the error message closely, you will find that it
> doesn't mention %urls but $urls.

Yes, indeed that is true, I've mish-mashed my variables.  

Thanks for the help.

Jake <--must spend more time on Perl



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

Date: Thu, 17 May 2001 21:06:59 +0930
From: Chris <rebelvideo@hotmail.com>
Subject: Re: Win32 fork() getting memory errors
Message-Id: <3B03B7DB.8B0324D1@hotmail.com>



try searching MSDN.microsoft.com for this error
I seem to recall its a windows thing

have you tried doing the telnet bit without the fork?
does it work?



u185760498@spawnkill.ip-mobilphone.net wrote:
> 
> Win2000.  Forking to create telnet sessions (Net::Telnet).  Getting:
> 
>   "The memory could not be 'read'"
> 
> when loggin in session (even 1 child).
> 
> Any help appreciated.
> 
> ~Tom
> 
> 
> --
> Sent by tjones from  timetra piece from com
> This is a spam protected message. Please answer with reference header.
> Posted via http://www.usenet-replayer.com/cgi/content/new

-- 
Regards

Chris
rebelvideo@hotmail.com


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 922
**************************************


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