[16506] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3918 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 4 18:10:35 2000

Date: Fri, 4 Aug 2000 15:10:22 -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: <965427022-v9-i3918@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 4 Aug 2000     Volume: 9 Number: 3918

Today's topics:
    Re: Graphic in a search results page <dominique.plu@ifrance.com>
    Re: Graphic in a search results page (David)
    Re: How do I convert a decimal number to a binary strin <lr@hpl.hp.com>
    Re: How to explain this expression? (Abigail)
    Re: How to explain this expression? <tim@ipac.caltech.edu>
    Re: How to print news with NNTP? (Abigail)
    Re: How to print news with NNTP? <hillr@ugsolutions.com>
    Re: How to print the thousands comma for financial numb <dmeyers@panix.com>
    Re: How to print the thousands comma for financial numb (David H. Adler)
    Re: I have an idea but will it work ? (Jon S.)
        insert 'n' amount of questions <star@sonic.net>
    Re: insert 'n' amount of questions <bean@agentkhaki.com>
    Re: insert 'n' amount of questions <care227@attglobal.net>
    Re: insert 'n' amount of questions <care227@attglobal.net>
    Re: insert 'n' amount of questions <bean@agentkhaki.com>
    Re: insert 'n' amount of questions michaeljgardner@my-deja.com
    Re: insert 'n' amount of questions <star@sonic.net>
    Re: insert 'n' amount of questions (Abigail)
    Re: insert 'n' amount of questions <star@sonic.net>
    Re: Is Learning Perl worth buying? <diab.litoNOdiSPAM@usa.net.invalid>
    Re: launch a browser and get a URL gtown97@my-deja.com
        matching *.h <pcr@pinnatel.net>
        My first module michaeljgardner@my-deja.com
    Re: My first module <aqumsieh@hyperchip.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 4 Aug 2000 20:19:21 +0200
From: "Dominique PLU" <dominique.plu@ifrance.com>
Subject: Re: Graphic in a search results page
Message-Id: <8mf11t$68q$1@vega.worldonline.fr>

Hello,

The good question is :
First : Have you examine the source of the page generated by your CGI
script, this may help to know what it want to write, and what it cannot load
Second you can use simple quote to your img src for example

your text was :

img align=center
src="http://www.vangoghgallery.com/images/banners/bw_02.gif"
width="411" height="66" border="2"alt="Barewalls.com  Art Prints and
Posters"

you can write this for generation

print " <img src='http://www.vangoghgallery.com/images/banners/bw_02.gif'
align=center
width='411' height='66' border='2' alt='Barewalls.com  Art Prints and
Posters' ";

It make the difference . (look at the same time the align parameter

Hope this will help you

Regards

Dominique PLU





David <brooksd@interlog.com> a écrit dans le message :
J%Ci5.7919$Lg1.144068@cac1.rdr.news.psi.ca...
> Thank you very much for your quick response!
>
> It doesn't work, though.  I followed your suggestion, but the result was
the
> same--no graphic appears on the search results page.
>
> David
>
>
>
>
> In article <398B0780.28DF26E2@mortgagestats.com>, Andras Malatinszky
> <andras@mortgagestats.com> wrote:
> >Use an absolute URL when you are referencing the image file, i.e.,
instead of
> >
> ><img align=center src="../images/banners/bw_02.gif" width="411"
height="66"
> >border="2"alt="Barewalls.com  Art Prints and Posters">
> >
> >put this:
> >
> ><img align=center
src="http://www.vangoghgallery.com/images/banners/bw_02.gif"
> >width="411" height="66" border="2"alt="Barewalls.com  Art Prints and
Posters">
> >
> >You see, your search results page is probably coming from your cgi-bin
> > directory,
> >so the ../ at the beginning of your image URL points to the directory
> > immediately
> >above that, but your images directory is probably somewhere else.
> >
> >Andras
> >
> >
> >
> >David wrote:
> >
> >> Hello, all: I was hoping that someone might have some advice.
> >>
> >> The truth is I don't really know Perl at all.  I have a search engine
on my
> >> site (www.vangoghgallery.com) and someone else did the coding for me
years
> >> ago.  Well, all I want to do is get a graphic to appear at the top of
the
> >> search results page.  I include the coding below and I was sure that it
would
> >> work, but it doesn't.  No graphic appears.  Can anyone let me know what
I'm
> >> doing wrong?
> >>
> >> Many thanks in advance.
> >>
> >> David Brooks
> >> www.vangoghgallery.com
> >>
> >> brooksd@interlog.com
> >> ________________________________________
> >>
> >> sub return_html {
> >> print "Content-type text/html\n\n";
> >> print "<html>\n <head>\n<title>Results of Search</title>\n </head>\n";
> >> print "<body><div align=center><center><a
> >>
href="&path=/cgi-bin/search.exe&searchstring=Vincent+van+Gogh">http//www.
> >> barewalls.com/cgi-bin/nph-referral.exe?code=VVGG&path=/cgi-bin/search.
> >> exe&searchstring=Vincent+van+Gogh" onMouseOver="(window.status='Vincent
van
> >> Gogh'); return true"><img align=center
src="../images/banners/bw_02.gif"
> >> width="411" height="66" border="2" alt="Barewalls.com - Art Prints and
> >> Posters"></a></center></div>"
> >> print "<center>\n <h1>Results of Search</h1>\n
> >> </center>\n";
> >> print "Below are the results of your Search in no particular
order<p><hr
> >> size=7 width=75%><p>\n";
> >> print "<ul>\n";
> >>    foreach $key (keys %include) {
> >>       if ($include{$key} eq 'yes') {
> >>          print "<li><a href=\"$baseurl$key\">$titles{$key}</a>";
> >>          print "&nbsp;&nbsp;-&nbsp;&nbsp;";
> >>          print "$key";
> >>       }
> >>    }
> >>    print "</ul>\n";
> >>
> >> (etc., etc.)
> >




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

Date: Fri, 04 Aug 2000 20:20:03 GMT
From: brooksd@interlog.com (David)
Subject: Re: Graphic in a search results page
Message-Id: <jrFi5.7924$Lg1.144749@cac1.rdr.news.psi.ca>

Thank you very much.  As with Andras's suggestion, though, this doesn't help 
either.  Same results--no graphic.

What about Dominique's comment: "First : Have you examine the source of the 
page generated by your CGI script, this may help to know what it want to 
write, and what it cannot load"?

Again, I don't know Perl at all, so it's all Greek to me.  She also gave a 
suggestion as to code substitution, but it didn't look right to me (I think 
that she left out a few characters).

It's a straightforward search.cgi file I'm using that I got from Matt's script 
archive.

If anyone can help, I'll include the text of it below (after putting in Bean's 
suggested change).

Sorry to be a pain in the neck.  I *really* appreciate everyone's help!

David

Here's the script:
________________________________________________

#!
/usr/bin/perl#################################################################
############## Simple Search                 Version 1.0                       
           ## Copyright 1996 Matt Wright    mattw@worldwidemart.com            
          ## Created 12/16/95              Last Modified 12/16/95              
         ## Scripts Archive at:           
http://www.worldwidemart.com/scripts/        
##############################################################################
## COPYRIGHT NOTICE                                                           
## Copyright 1996 Matthew M. Wright  All Rights Reserved.                     
##                                                                            
## Simple Search may be used and modified free of charge by anyone so long as 
## this copyright notice and the comments above remain intact.  By using this 
## code you agree to indemnify Matthew M. Wright from any liability that      
#  # might arise from it's use.                                                
 #  #                                                                          
  ## Selling the code for this program without prior written consent is        
 ## expressly forbidden.  In other words, please ask first before you try and  
## make money off of my program.                                              
##                                                                            
## Obtain permission before redistributing this software over the Internet or 
## in any other medium.  In all cases copyright and header must remain 
intact.
##############################################################################
## Define Variables                                                           
##$basedir = '/mnt/web/guide/worldwidemart/scripts/';$basedir = 
'/home/coruscant/vangogh/www/';#$baseurl = 
'http://worldwidemart.com/scripts/';$baseurl = 
'http://www.vangoghgallery.com/';#@files = 
('*.shtml','demos/links/*.html','demos/guest/*.html');@files = 
('biblio/*.htm','database/*.htm','database/letters/*.htm','forum/*.
htm','juvenil/*.htm','letters/*.htm','map/*.htm','misc/*.htm','misc/roulin/*.
htm','news/*.htm','painting/*.htm','painting/by_period/*.htm','photos/*.
htm','portrait/*.htm','sketches/*.htm','visitors/*.htm','watercolours/*.
htm','letters/sketches/*.htm','events/*.htm','influences/*.
htm','influences/millet/*.htm');#$title = "Matt's Script Archive";$title = 
"Vangogh";#$title_url = 'http://worldwidemart.com/scripts/';$title_url = 
'http://www.vangoghgallery.com/';#$search_url = 
'http://worldwidemart.com/scripts/demos/search/search.html';$search_url = 
'http://www.vangoghgallery.com/misc/search.html';# Done                        
                                               
##############################################################################
## Parse Form Search Information&parse_form;# Get Files To Search 
Through&get_files;# Search the files&search;# Print Results of 
Search&return_html;sub parse_form {   # Get the input   read(STDIN, $buffer, 
$ENV{'CONTENT_LENGTH'});   # Split the name-value pairs   @pairs = split(/&/, 
$buffer);   foreach $pair (@pairs) {      ($name, $value) = split(/=/, $pair); 
     $value =~ tr/+/ /;      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", 
hex($1))/eg;      $FORM{$name} = $value;   }}sub get_files {   
chdir($basedir);   foreach $file (@files) {      $ls = `ls $file`;      @ls = 
split(/\s+/,$ls);      foreach $temp_file (@ls) {         if (-d $file) {      
      $filename = "$file$temp_file";            if (-T $filename) {            
   push(@FILES,$filename);            }         }         elsif (-T 
$temp_file) {            push(@FILES,$temp_file);         }      }   }}sub 
search {   @terms = split(/\s+/, $FORM{'terms'});   foreach $FILE (@FILES) {   
   open(FILE,"$FILE");      @LINES = <FILE>;      close(FILE);      $string = 
join(' ',@LINES);      $string =~ s/\n//g;      if ($FORM{'boolean'} eq 'AND') 
{         foreach $term (@terms) {            if ($FORM{'case'} eq 
'Insensitive') {               if (!($string =~ /$term/i)) {                  
$include{$FILE} = 'no';                  last;               }               
else {                  $include{$FILE} = 'yes';               }            }  
          elsif ($FORM{'case'} eq 'Sensitive') {               if (!($string 
=~ /$term/)) {                  $include{$FILE} = 'no';                  last; 
              }               else {                  $include{$FILE} = 'yes'; 
              }            }         }      }      elsif ($FORM{'boolean'} eq 
'OR') {         foreach $term (@terms) {            if ($FORM{'case'} eq 
'Insensitive') {               if ($string =~ /$term/i) {                  
$include{$FILE} = 'yes';                  last;               }               
else {                  $include{$FILE} = 'no';               }            }   
         elsif ($FORM{'case'} eq 'Sensitive') {               if ($string =~ 
/$term/) {                  $include{$FILE} = 'yes';                  last;    
           }               else {                  $include{$FILE} = 'no';     
          }            }         }      }      if ($string =~ 
/<title>(.*)<\/title>/i) {         $titles{$FILE} = "$1";      }      else {   
      $titles{$FILE} = "$FILE";      }   }}      sub return_html { 
print "Content-type text/html\n\n"; 
print "<html>\n <head>\n<title>Results of Search</title>\n </head>\n"; 
print "<body><div align=center><center><a 
href="&path=/cgi-bin/search.exe&searchstring=Vincent+van+Gogh">http//www.
barewalls.com/cgi-bin/nph-referral.exe?code=VVGG&path=/cgi-bin/search.
exe&searchstring=Vincent+van+Gogh" onMouseOver="(window.status='Vincent van 
Gogh'); return true"><img align=center src=\"../images/banners/bw_02.gif\"> 
width=\"411\" 
height=\"66\" border=\"2\" alt=\"Barewalls.com - Art Prints and Posters
\"></a></center></div>"
print "<center>\n <h1>Results of Search</h1>\n 
</center>\n";
print "Below are the results of your Search in no particular order<p><hr 
size=7 width=75%><p>\n"; 
print "<ul>\n";   foreach $key (keys %include) {      if ($include{$key} eq 
'yes') {         print "<li><a href=\"$baseurl$key\">$titles{$key}</a>";       
  print "&nbsp;&nbsp;-&nbsp;&nbsp;";         print "$key";      }   }   print 
"</ul>\n";   print "<hr size=7 width=75%>\n";   print "Search 
Information:<p>\n";   print "<ul>\n";   print "<li><b>Terms:</b> ";   $i = 0;  
 foreach $term (@terms) {      print "$term";      $i++;      if (!($i == 
@terms)) {         print ", ";      }   }   print "\n";   print 
"<li><b>Boolean Used:</b> $FORM{'boolean'}\n";   print "<li><b>Case 
$FORM{'case'}</b>\n";   print "</ul><br><hr size=7 width=75%><P>\n";   print 
"<ul>\n<li><a href=\"$search_url\">Back to Search Page</a>\n";   print "<li><a 
href=\"$title_url\">$title</a>\n";   print "</ul>\n";   print "<hr size=7 
width=75%>\n";   print "Search Script written by Matt Wright and can be found 
at <a href=\"http://www.worldwidemart.com/scripts/\">Matt's Script 
Archive</a>\n";   print "</body>\n</html>\n";}   


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

Date: Fri, 4 Aug 2000 14:33:44 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How do I convert a decimal number to a binary string??
Message-Id: <MPG.13f4d6925924e71e98ac36@nntp.hpl.hp.com>

In article <8megku$nd8$1@lublin.zrz.tu-berlin.de> on 4 Aug 2000 13:32:14 
-0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> says...

 ...

> The number is the same, whether you write it 12, or 0x0C, or 1100(2)
> or even XIII.

Not exactly.  :-)

We have this concept of "a baker's dozen", where when you buy twelve 
bagels, say, a thirteenth is thrown in for free.  Perhaps that is what 
you meant.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 04 Aug 2000 16:01:08 EDT
From: abigail@foad.org (Abigail)
Subject: Re: How to explain this expression?
Message-Id: <slrn8om87k.pjo.abigail@alexandra.foad.org>

u8526505@ms27.hinet.net (u8526505@ms27.hinet.net) wrote on MMDXXX
September MCMXCIII in <URL:news:8mdcha$n2a@netnews.hinet.net>:
:: $_=<>;
:: /hello/ and print "abc\n",print "ok\n";
:: 
:: the result is
:: hello <-- I input this
:: ok
:: abc
:: 1

Your print statement prints "abc\n" and the result of 'print "ok\n"', 
which happens to be 1. The side effect of getting 1 is the printing
of "ok\n".

:: Is there a friendly way to rewrite it ?

To rewrite it doing what? If you just want the "abc\n" and "ok\n" printed,
do:

    print "abc\nok\n" if /hello/;



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

Date: Fri, 04 Aug 2000 13:03:56 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: How to explain this expression?
Message-Id: <398B21AC.A0C2FB71@ipac.caltech.edu>

u8526505@ms27.hinet.net wrote:
> 
> $_=<>;
> /hello/ and print "abc\n",print "ok\n";
> 
> the result is
> hello <-- I input this
> ok
> abc
> 1
> 
> Is there a friendly way to rewrite it ?

Well, I don't know about friendlier, but maybe this will explain it to
you:

if($_ =~ /hello/) { print("abc\n",$return_code = print("ok\n")); }

OK?

--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: 04 Aug 2000 16:04:06 EDT
From: abigail@foad.org (Abigail)
Subject: Re: How to print news with NNTP?
Message-Id: <slrn8om8d6.pjo.abigail@alexandra.foad.org>

Ying Hu (yhu@mail.nih.gov) wrote on MMDXXX September MCMXCIII in
<URL:news:398AEC6C.AD82EE0C@mail.nih.gov>:
--
-- @lines seems an array? How to print it? Thanks

Eh... by using the print function? As in:

    print @lines;

Utterly amazing syntax, isn't?


But what does your question have to do with the Subject line?



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

Date: Fri, 04 Aug 2000 13:31:42 -0700
From: Ron Hill <hillr@ugsolutions.com>
Subject: Re: How to print news with NNTP?
Message-Id: <398B282E.E8EC3B61@ugsolutions.com>

From the NNTP docs
body ( [ MSGID|MSGNUM ] )
Retrieve the body (text) of the specified article.

Takes the same arguments as article

Returns a reference to an array containing the body of the article.

The @lines needs to be changed to $lines then

print "@{$lines}";

Ying Hu wrote:

> Hi,
> @lines seems an array? How to print it? Thanks
> Ying
>
>  $server = Net::NNTP->new("news")
>   or die "Can't connect to news server:$@ $!\n";
>  ($narticles, $first, $last, $name) =
> $server->group("comp.lang.perl.misc")
>   or die "Can't select comp.lang.perl.misc\n";
>  foreach $megid ($first..$last){
>   @lines = $server -> body($megid);
>   unless (defined @lines ){
>    warn "$id ... :(\n";
>    next;
>   }
>   foreach $line (@lines){
>    print "$line\n";
>   }
>  }



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

Date: 04 Aug 2000 14:19:06 -0400
From: David Meyers <dmeyers@panix.com>
Subject: Re: How to print the thousands comma for financial numbers ( $ 12,8292.75)
Message-Id: <yob8zucyjmt.fsf@panix6.panix.com>

dha@panix.com (David H. Adler) writes:

> On Mon, 31 Jul 2000 10:06:33 GMT, Gibson <gibson70@libero.it> wrote:
> >Eric Bohlman <ebohlman@netcom.com> wrote in message
> >8lmbki$i9m$4@slb2.atl.mindspring.net...
> >> Louis Banens (louis.banens@xs4all.nl) wrote:

> >> : I cannot find out how to print the thousands comma for financial numbers

> >> Use the code shown in perlfaq5.

> >where is ?

> Although it is indeed at www.perl.com, it is also (assuming your perl
> installation was done correctly) on your computer, as is all of the
> documentatoin for perl.

To expand just a tiny bit, your perl distribution came
with complete documentation.  On a PC or Unix box, type

perldoc perlfaq5
or
perldoc -q commas

The latter searches the FAQs for the keyword commas and
comes right up with the correct answer.

If you are on a Mac, there is a documentation tool and
full docs online, too, but, obviously, the above commands
won't work...

--d



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

Date: 4 Aug 2000 19:18:32 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: How to print the thousands comma for financial numbers ( $ 12,8292.75)
Message-Id: <slrn8om5o8.ggh.dha@panix2.panix.com>

On 04 Aug 2000 14:19:06 -0400, David Meyers <dmeyers@panix.com> wrote:
>dha@panix.com (David H. Adler) writes:
>
>> On Mon, 31 Jul 2000 10:06:33 GMT, Gibson <gibson70@libero.it> wrote:
>> >Eric Bohlman <ebohlman@netcom.com> wrote in message
>> >8lmbki$i9m$4@slb2.atl.mindspring.net...
>> >> Louis Banens (louis.banens@xs4all.nl) wrote:
>
>> >> : I cannot find out how to print the thousands comma for financial numbers
>
>> >> Use the code shown in perlfaq5.
>
>> >where is ?
>
>> Although it is indeed at www.perl.com, it is also (assuming your perl
>> installation was done correctly) on your computer, as is all of the
>> documentatoin for perl.
>
>To expand just a tiny bit, your perl distribution came
>with complete documentation.  On a PC or Unix box, type
>
>perldoc perlfaq5
>or
>perldoc -q commas

That, of course needs to be done from a command prompt (i.e. in
windows, the MS-Dos prompt).  Perl for Windows also comes with
documentation in html format.

>If you are on a Mac, there is a documentation tool and
>full docs online, too, but, obviously, the above commands
>won't work...

FYI The tool is called Shuck.

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"It's all eggs, bacon, beans and a fried slice." - Madness


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

Date: Fri, 04 Aug 2000 18:16:19 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: I have an idea but will it work ?
Message-Id: <398afb58.14622229@news.earthlink.net>

On Thu, 3 Aug 2000 01:59:48 +0100, "Phil Latio"
<globalcon2isnot@myhouse.com> wrote:

>Many thanks for all those URL's.
>
>That should keep me out of mischief for while !!

Phil,

I should have mentioned that even though my first script took me a
while, I did lots of "homework" during that time.  I read at least 4
books cover to cover (HTML, Perl, DBI, etc.) and I've lurked on these
groups for months.  And, my first script was a full form based data
entry scheme linked to MySQL in it.   Now that I have it working, I'd
be able to recreate or rewrite it into something else within a very
short time.  As it is, I'm going to redo it in order to incorporate
arrays for raw lists of variables, etc.

Part of my time was working with my web hoster to set up my MySQL
account right, and another part was figuring out the right perl path
to get me to 5.004.  Just so I could run on the command line properly
to debug.

Now that it's done, it all looks simple to me, or at least, easy to
figure out again the next time.  I still have lots of trouble with
regular expressions and with conceiving array and hash schemes, so I
default to clumsy techniques.  But, they all work.

Jon 


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

Date: Fri, 04 Aug 2000 19:05:12 GMT
From: arthur <star@sonic.net>
Subject: insert 'n' amount of questions
Message-Id: <B5AFB920.4BAE%star@sonic.net>


Good Day,

I am trying to be able to give the "user" (I love that expression) a chance
to input some questions. I have this:
---
#!/usr/bin/perl -w


print "How many questions would you like to insert in the program?";
        chomp ($n = <STDIN>);

print "\n\nInput questions: ";
open(QUES, ">ques") || die "can't open ques: $!";

for ($i=1, $i<=$n, $i += 1;) {
@QUEStion = <STDIN>;
        print @QUEStion;}

print QUES @QUEStion;

close(QUES) || die "can't close QUES: $!";
-------------
I get this:
# syntax error, near ";) "
File 'StarMax HD:Desktop Folder:perl:Untitled #2'; Line 10
# syntax error, near ";}"
File 'StarMax HD:Desktop Folder:perl:Untitled #2'; Line 12
# Execution of StarMax HD:Desktop Folder:perl:Untitled #2 aborted due to
compilation errors.





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

Date: 04 Aug 2000 15:21:53 EDT
From: bean <bean@agentkhaki.com>
Subject: Re: insert 'n' amount of questions
Message-Id: <MPG.13f4df942839cbb798968b@news.concentric.net>

> #!/usr/bin/perl -w
> 
> 
> print "How many questions would you like to insert in the program?";
>         chomp ($n = <STDIN>);
> 
> print "\n\nInput questions: ";
> open(QUES, ">ques") || die "can't open ques: $!";
> 
> for ($i=1, $i<=$n, $i += 1;) {
> @QUEStion = <STDIN>;
>         print @QUEStion;}
> 
> print QUES @QUEStion;
> 
> close(QUES) || die "can't close QUES: $!";
> -------------
> I get this:
> # syntax error, near ";) "
> File 'StarMax HD:Desktop Folder:perl:Untitled #2'; Line 10
> # syntax error, near ";}"
> File 'StarMax HD:Desktop Folder:perl:Untitled #2'; Line 12
> # Execution of StarMax HD:Desktop Folder:perl:Untitled #2 aborted due to
> compilation errors.

My first guess would be to toss the ';' in line 10, changing it to:

for ($i=1, $i<=$n, $i += 1) {

I'm almost positive that will fix your error. That might correct the 
second error you're getting as well. 

bean


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

Date: Fri, 04 Aug 2000 15:27:43 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: insert 'n' amount of questions
Message-Id: <398B192F.6BBC589A@attglobal.net>

> #!/usr/bin/perl -w


 
> print "How many questions would you like to insert in the program?";
>         chomp ($n = <STDIN>);
> 
> print "\n\nInput questions: ";
> open(QUES, ">ques") || die "can't open ques: $!";
> 
> for ($i=1, $i<=$n, $i += 1;) {
           ^       ^ ^^^^^^^^

Bad syntax here.  First, just use $i++, as it does the same thing. 
Secondly, omit that semi-colon on the end and change the commas
to semicolons.  Like so:

for ($i=1; $i<=$n; $i ++) {

> -------------
> I get this:
> # syntax error, near ";) "
> File 'StarMax HD:Desktop Folder:perl:Untitled #2'; Line 10
> # syntax error, near ";}"
> File 'StarMax HD:Desktop Folder:perl:Untitled #2'; Line 12
> # Execution of StarMax HD:Desktop Folder:perl:Untitled #2 aborted due to
> compilation errors.

Is this MacPerl?  But with a *ix shebang line?  Odd.

Have you considered getting a module to read from the terminal?
Might make things easier.


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

Date: Fri, 04 Aug 2000 15:31:49 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: insert 'n' amount of questions
Message-Id: <398B1A25.CE5AFF0B@attglobal.net>

bean wrote:
> 
> My first guess would be to toss the ';' in line 10, changing it to:
> 
> for ($i=1, $i<=$n, $i += 1) {
> 
> I'm almost positive that will fix your error. That might correct the
> second error you're getting as well.
> 
> bean

That would fix the syntax error, but it would destroy the logic.
The syntax for such a control statment is:

 	 for ($i = 1; $i < 10; $i++) {}

Notice the semi-colons.  Doing a for loop with 3 comma seperated 
values does a very different thing.  Look at perlsyn under the 
foreach section and you'll get an idea.  

http://www.perl.com/pub/doc/manual/html/pod/perlsyn.html#For_Loops


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

Date: 04 Aug 2000 15:41:26 EDT
From: bean <bean@agentkhaki.com>
Subject: Re: insert 'n' amount of questions
Message-Id: <MPG.13f4e4327e02e57198968d@news.concentric.net>

>  	 for ($i = 1; $i < 10; $i++) {}
> 
> Notice the semi-colons.  Doing a for loop with 3 comma seperated 
> values does a very different thing.  Look at perlsyn under the 
> foreach section and you'll get an idea.  

So very true. Well, I was almost sure. That's gotta count for 
something... 

<grin>

bean


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

Date: Fri, 04 Aug 2000 19:40:22 GMT
From: michaeljgardner@my-deja.com
Subject: Re: insert 'n' amount of questions
Message-Id: <8mf675$8g6$1@nnrp1.deja.com>

In article <B5AFB920.4BAE%star@sonic.net>,
  arthur <star@sonic.net> wrote:
>
> Good Day,
>
> I am trying to be able to give the "user" (I love that expression) a
chance
> to input some questions. I have this:
> ---
> #!/usr/bin/perl -w
>
> print "How many questions would you like to insert in the program?";
>         chomp ($n = <STDIN>);
>
> print "\n\nInput questions: ";
> open(QUES, ">ques") || die "can't open ques: $!";
>
> for ($i=1, $i<=$n, $i += 1;) {
> @QUEStion = <STDIN>;
>         print @QUEStion;}
>
> print QUES @QUEStion;
>
> close(QUES) || die "can't close QUES: $!";
> -------------
> I get this:
> # syntax error, near ";) "
> File 'StarMax HD:Desktop Folder:perl:Untitled #2'; Line 10
> # syntax error, near ";}"
> File 'StarMax HD:Desktop Folder:perl:Untitled #2'; Line 12
> # Execution of StarMax HD:Desktop Folder:perl:Untitled #2 aborted due
to
> compilation errors.
>
>

In your FOR statement you've got

 for ($i=1, $i<=$n, $i += 1;) {

I think what you want is

 for ($i=1; $i<=$n; $i++)

in other words, change the commas to semicolons and see if that works.
Replacing the $i+=1 with $i++ is just makes it look better.  Either way
will work.

Cheers,
Michael


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 04 Aug 2000 20:48:18 GMT
From: arthur <star@sonic.net>
Subject: Re: insert 'n' amount of questions
Message-Id: <B5AFD165.4BDD%star@sonic.net>

THANKS, I FIXED IT BUT... HOW DO I END THE ENDLESS LOOP?


#!/usr/bin/perl -w


print "How many questions would you like to insert in the program?";
        chomp ($n = <STDIN>);

print "\n\nInput questions: ";
open(QUES, ">ques") || die "can't open ques: $!";

for ($i=1; $i<=$n; $i ++)  {
@QUEStion = <STDIN>;
        print $_;}

print QUES @QUEStion;

close(QUES) || die "can't close QUES: $!";

~ARTHUR



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

Date: 04 Aug 2000 21:25:08 GMT
From: abigail@foad.org (Abigail)
Subject: Re: insert 'n' amount of questions
Message-Id: <slrn8omd53.st1.abigail@alexandra.foad.org>

arthur (star@sonic.net) wrote on MMDXXX September MCMXCIII in
<URL:news:B5AFD165.4BDD%star@sonic.net>:
== THANKS, I FIXED IT BUT... HOW DO I END THE ENDLESS LOOP?
== 

No reason to shout.

The manual will provide you with several means of ending loops.
exit, goto, last, die, return, to name a few.

== 
== #!/usr/bin/perl -w
== 
== 
== print "How many questions would you like to insert in the program?";
==         chomp ($n = <STDIN>);
== 
== print "\n\nInput questions: ";
== open(QUES, ">ques") || die "can't open ques: $!";
== 
== for ($i=1; $i<=$n; $i ++)  {
== @QUEStion = <STDIN>;

This will read everything from STDIN into @QUEStion when $i == 1.

==         print $_;}

This won't print anything, as $_ is undefined.

== 
== print QUES @QUEStion;
== 
== close(QUES) || die "can't close QUES: $!";
== 
== ~ARTHUR
== 
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

Date: Fri, 04 Aug 2000 21:34:38 GMT
From: arthur <star@sonic.net>
Subject: Re: insert 'n' amount of questions
Message-Id: <B5AFDC42.5086%star@sonic.net>

in article B5AFD165.4BDD%star@sonic.net, arthur at star@sonic.net wrote on
8/4/00 12:48 PM:

> THANKS, I FIXED IT BUT... HOW DO I END THE ENDLESS LOOP?
> 
> 
OH Yeah an ifelse loop



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

Date: Fri, 04 Aug 2000 11:41:49 -0700
From: Diablito <diab.litoNOdiSPAM@usa.net.invalid>
Subject: Re: Is Learning Perl worth buying?
Message-Id: <20109413.cb677455@usw-ex0105-035.remarq.com>

john_s_brown@my-deja.com wrote:
>I am beginning to learn Perl. I have read Robert's Perl
Tutorial at
>http://www.netcat.co.uk/rob/perl/win32perltut.html almost
completely. I
>don't have any earlier experience with C, C++ or the like, but
I have
>programmed a bit with Turbo Pascal couple of years ago.
>
>Now, I would like to know if Learning Perl book is worth
buying? There
>are two reasons why I don't rush to the bookstore and buy it
right away:
>
>1. Learning Perl (2nd edition) is all about Perl 5, and I have
>installed Perl 5.6 on my machine! Do those Perl 5 tricks
presented in
>Learning Perl book work with Perl version 6.5?
>
>2. As I said, I have read Robert's Perl tutorial almost
completely.
>Would it be wiser with my previous knowledge to buy Programming
Perl
>(3rd edition) instead of Learning Perl?
>

Hi,
I have read the book a couple of weeks ago and my advice is to
buy it.I have found it clear and easy enough even for
beginners.The language is easy and effective and can be
unerstood even by readers who don't speak english as a first
language.You should eat it in a hearthbeat.Also don't worry
about the Perl version.If you are looking for that book,maybe
you don't need all the latest tricks and tools.

Mario


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

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



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

Date: Fri, 04 Aug 2000 17:56:59 GMT
From: gtown97@my-deja.com
Subject: Re: launch a browser and get a URL
Message-Id: <8mf058$3b2$1@nnrp1.deja.com>

In article <B5AECE32.4AD8%star@sonic.net>,
  arthur <star@sonic.net> wrote:
> in article 8md5jf$8nj$1@brokaw.wa.com, Lauren Smith at
> lauren_smith13@hotmail.com wrote on 8/3/00 5:18 PM:
> >
> > #!perl -w
> > $page = 'http://www.yahoo.com'; # Change this line
> > exec ("explorer $page"); # Adjust if using other browser
> >
> Thanks Lauren but when I try it I get:
>
> # exec? I'm not *that* kind of operating system,

I just found out that you are running MacPerl.  Since I don't know the
ins and outs of that OS, I'll just assume that the error is a MacPerl
message.  In that case, use this:

#!perl -w
$page = 'http://www.yahoo.com';
$file = 'file://somefile';
system("explorer $file");

You'll have Perl running until you close the browser, but you wouldn't
notice it I wouldn't think.

Lauren
--
Why is my regular newsfeed so slow?
print grep ord $_,map{y/a-z//d;$x.="+ $_";chr(eval $x)}
'J74u43-s2tA1-84n33o45th1er5-12-P3e13-82r48l21H13-a6-76
c40k25er2wx8-y6z13-81'=~m#([^!\n]{3})#g#tr/-0-9wxyz//d;print


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 04 Aug 2000 15:26:06 -0600
From: Phil Reardon <pcr@pinnatel.net>
Subject: matching *.h
Message-Id: <398B34EE.9A3F5C54@pinnatel.net>

How can I detect include files?  I tried /.h/ and /\.h/, as in ($file
=-  /\.h/), but they dont seem to work.



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

Date: Fri, 04 Aug 2000 19:23:36 GMT
From: michaeljgardner@my-deja.com
Subject: My first module
Message-Id: <8mf57h$7ik$1@nnrp1.deja.com>

I'm trying to make one of my subroutines into a module.  To use the
subroutine, I pass the path and file name of a file as one of the
arguments.  Which perldocs should I look at to see how to accomplish
passing this information to a module?

What I'm trying to do is to eliminate copying the subroutine into each
program that uses it.  I'd like to be able to "use modulename", and have
all the functionality of the subroutine available.

Any suggestions for further reading or research on creating modules
would be appreciated.  At this point I'm still pretty weak on OO
programming, so my best solution is one that doesn't require a lot of
object oriented knowledge.

Thanks,
Michael


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 04 Aug 2000 19:56:03 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: My first module
Message-Id: <7aaeeser6z.fsf@merlin.hyperchip.com>


michaeljgardner@my-deja.com writes:

> I'm trying to make one of my subroutines into a module.  To use the
> subroutine, I pass the path and file name of a file as one of the
> arguments.  Which perldocs should I look at to see how to accomplish
> passing this information to a module?

Checkout 'perlmodlib' and 'perlmod'.

--Ala


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 3918
**************************************


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