[6273] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 895 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 4 21:57:29 1997

Date: Tue, 4 Feb 97 18:00:21 -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           Tue, 4 Feb 1997     Volume: 7 Number: 895

Today's topics:
     Re: @ <stevej@wco.com>
     Re: [help] matching multiple patterns (Jeffrey)
     Adding a carrage return (Jeremy Coulter)
     Can't locate CGI.pm ?? (Jeremy Coulter)
     Re: controlling case sensitivity (Mike Heins)
     Frivilous request for new Perl function <chris@ixlabs.com>
     Re: How to do this using perl? <tchrist@mox.perl.com>
     Re: How to make a ftp script (Chaim Frenkel)
     Re: mail and perl - help (Hugo van der Sanden)
     Need CGI script that reads files from another HTTP serv bart@cloud9.net
     Re: Need Script (Joy ('Marcie') Locke)
     Nice perl way to generate n! permutations for n=8 ?? (NCPSLtd)
     Re: opening a file in a Recursive Call (Perl Question) (Tad McClellan)
     Output SMTP-compatible date? (Derek Chee)
     paching nested C-structure <dosreis@DPTMaths.ENS-Cachan.Fr>
     PERL AND C ROUTINES <emf@remus.rutgers.edu>
     Perl problem, help! (Anicia Limmany)
     Re: Perl problem, help! <egwong@netcom.com>
     Re: regex eats newline? (Jeffrey)
     Re: space stripping <kevlar@ns.net>
     Re: space stripping (Tad McClellan)
     Spooling gifs <stevej@wco.com>
     Telnet through Proxy?  protocol negotiations <mkruse@shamu.netexpress.net>
     Re: Trimming Dollar Value <osborri@mail.northgrum.com>
     Re: Trimming Dollar Value (Chaim Frenkel)
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: 4 Feb 1997 21:47:16 GMT
From: Steve Johnson <stevej@wco.com>
Subject: Re: @
Message-Id: <5d8ap4$n30@news.wco.com>

Dean Hollister <deanh@nospam.net.au> wrote:
> Becky Schonfeld wrote:

> > Can someone give a very inexperienced programmer a short explanation of
> > how to send mail to a different machine?  I have the script sending mail
> > on the same machine but the "@" seems to mess things up.  Right now I
> > have a sub mail which I send an address parameter to and then say
> >  open (MAIL, "| mail $ad");

> You need to place a backslash before the @ character.

> open (MAIL, "| mail someone\@somewhere.net");

> or

> $ad="someone\@somewhere.net"


NOTE:  This doesnt always work.. Im running Perl 5.003 on Linux and this
bombs..  usualy i have to do it this way
$ad="someone\100"."somewhere.net";


-Steve






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

Date: 04 Feb 1997 15:27:04 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: pudge@pobox.com (Chris Nandor)
Subject: Re: [help] matching multiple patterns
Message-Id: <JFRIEDL.97Feb5002704@tubby.nff.ncl.omron.co.jp>

[mailed and posted]

Chris Nandor <pudge@pobox.com> wrote:
|> # but only using 1 statement... like:
|> # 
|> #         $text =~ /%name , %info/i   
|> 
|> $text =~ /%name|%info/i
|>
|> XRef:
|>    Blue Camel, p. 59.
|>    Hip Owls, p. 15.
|>    perlre manpage

Not to take away from Chris' point, but if efficiency is an issue,
I'd recommend that
	$text =~ /%name|%info/i
be written as:
	$text =~ /%(?:name|info)/i

This keeps the (relatively costly) alternation at bay until the % can
actually match. [See Hip Owls p. 155, mid-page]

Of course, if it's something that won't be executed in a loop, and not on a
long string, then perhaps the clarity of /%name|%info/ is to be preferred --
it's a you-had-to-be-there call.

	Jeffrey

NB: "Hip Owls" is the book referenced in my sig.

----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@omron.co.jp> Omron Corp, Nagaokakyo, Kyoto 617 Japan
O'Reilly & Associates' _Mastering Regular Expressions_
                                   http://enterprise.ic.gc.ca/~jfriedl/regex/


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

Date: Wed, 05 Feb 1997 00:57:32 GMT
From: vss@xtra.co.nz (Jeremy Coulter)
Subject: Adding a carrage return
Message-Id: <32f7daa7.63880037@202.37.101.7>

HI I have a wee script I have written.
It writes some info to a log file.
But what I need, is for it to append a line to a new line, rather that
straight after the last entery.

Any Ideas?


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

Date: Tue, 04 Feb 1997 23:48:50 GMT
From: vss@xtra.co.nz (Jeremy Coulter)
Subject: Can't locate CGI.pm ??
Message-Id: <32f7c7c2.59042693@202.37.101.7>

Hi, Have downloaded the CGI.pm file and added it to the Perl/Lib
directory, but I still get the following error :-

Can't locate CGI.pm in @INC at d:\WEBSITE\CGI-SHL\ACCESSES.PL line 27.
BEGIN failed--compilation aborted at d:\WEBSITE\CGI-SHL\ACCESSES.PL
line 27

why is this, and how do I fix it ?

Cheer, Jeremy Coulter


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

Date: 4 Feb 1997 23:20:47 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: controlling case sensitivity
Message-Id: <5d8g8f$8v3@vixen.cso.uiuc.edu>

Dan Lipofsky (danlip@proton.cyc.com) wrote:
: 
: I would like to control case sensitivity of matching
: based on a variable in my script.  Obviously this would work:
: if ($sensitive) {
: 	if ( m/$word/ ) { ... }
: }
: else {
: 	if ( m/$word/i ) { ... }
: }
: 
: But this involves an extra if for each match.
: Since there will be a large number of repetitions,
: this isnt too efficient.  I tried 
:         if ( m/$word/$tags ) { ... }
: where $tags was set to "i" or "", but this gave
: me syntax errors.
: 
: What is the most efficient way to accomplish my goal.
: 

I suggest using the new embedded modifier capability in
Perl 5:

	$_ = 'Foo';
	$word = '(?i)foo';
		print "Matched $_ case-insensitive with $word\n" if /$word/;
	$word = 'foo';
		print "Matched $_ case-sensitive with $word\n" if /$word/;

	$_ = 'foo';
	$word = '(?i)foo';
		print "Matched $_ case-insensitive with $word\n" if /$word/;
	$word = 'foo';
		print "Matched $_ case-sensitive with $word\n" if /$word/;

-- 
Regards,                                                      ___       ___
Mike Heins     [mailed and posted]  http://www.iac.net/~mikeh|_ _|____ |_ _|
                                    Internet Robotics         | ||  _ \ | |
This post reflects the              Oxford, OH  45056         | || |_) || | 
opinion of my employer.             <mikeh@iac.net>          |___|  _ <|___|
                                    513.523.7621 FAX 7501        |_| \_\   


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

Date: Tue, 04 Feb 1997 15:08:50 -0800
From: Chris Schoenfeld <chris@ixlabs.com>
Subject: Frivilous request for new Perl function
Message-Id: <32F7C182.3C51@ixlabs.com>

Hi,

It would be great, and a little more Perlish, if there were a chop that
returned the truncated string, rather than what was chopped off. It
could be called chew, or perhaps masticate.

That way you could plop the chew call right in the print LIST. No Perl
programmer wants a sorry line like plain 'ol:
chop $scaler;


-- 
Chris Schoenfeld
IX Development Laboratories   
Santa Rosa, California
(707)-543-8030 Ext. 12


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

Date: 5 Feb 1997 01:22:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to do this using perl?
Message-Id: <5d8nc1$9qr$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "Samir Grover" <sgrover@elizacorp.com> writes:
:@data = split("\", "c:\speech\work");
:
:I want to split "c:\speech\work" into array of "c:", "speech" and "work".
:
:"\" is creating a problem for perl compiler.

And likewise for awk, C, C++, Tcl, Python, or Java -- or in fact any
language reasonable or otherwise.  It's a stoopid microsoft megablunder.
Just use real slashes like God and Dennis intended.

    @elements = split( m#/#, "c:/speech/work" );

Yes, the real slashes work just fine in pathnames.

--tom
-- 
Tom Christiansen      Perl Consultant, Gamer, Hiker      tchrist@mox.perl.com
    "Do we define evil as the absence of goodness?  It seems only logical
    that shit happens--we discover this by the process of elimination."
    	--Larry Wall


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

Date: 5 Feb 1997 01:42:28 GMT
From: Chaimf@cris.com (Chaim Frenkel)
Subject: Re: How to make a ftp script
Message-Id: <5d8oi4$gp8@chronicle.concentric.net>

[poster cc'ed]

Check out your nearest CPAN and look for the excellent libnet
distribution by Graham Barr. You are interested in the Net::FTP module.
Comes with examples.

<chaim>

Sebastien Lambert (slambert@avenor.com) (comp.lang.perl.misc <01bc12de$6af349e0$370a010a@slamber.Avenor.com>) wrote:
: I want to make a program who is going to get a file by ftp in
: a specified site.
: 
: How could I do that automatic...
: 
: Thanks for help...
: 
: 


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

Date: 4 Feb 1997 23:19:44 GMT
From: hv@crypt.compulink.co.uk (Hugo van der Sanden)
Subject: Re: mail and perl - help
Message-Id: <5d8g6g$q8u@zinc.compulink.co.uk>

joseph norris (josephn@mail.mcoe.k12.ca.us) wrote:
:I have finished producing some reports via perl that run on a monthly
:basis.
: I would like to email these to those who should get them but I am unsure
:has to how to do this. I've seen examples of how to open mail via a pipe
:but I don't know how to attach a file to this email. 
:Can you give me any suggestions? Thanks joseph.
To go direct to a pipe you've already opened, just print to the filehandle
you got back. Check the documentation for the program you opened the
pipe to to see what it is expecting, eg on my system I could do:
  open PIPE, "| /bin/mail -s Report boss@machine.site.com"
    or die "Couldn't open pipe: $!";
  print PIPE "Hi boss, here is the report:\n"
    or die "Couldn't write to pipe: $!";
  print PIPE $report;
# etc ...
  close PIPE;

An alternative would be to install MailTools from CPAN, and do
something more like this:

  use Mail::Mailer;
  my $mailer = new Mail::Mailer;
  $mailer->open(
    'To' => 'boss@machine.site.com',
    'Subject' => "Monthly sales report for $monthname",
  );
  print $mailer "Hi boss, here is the report:\n";
  print $mailer $report;
  $mailer->close;

which is probably more portable to other mailers or other
maintainers in the future. Note that in both cases, the mail is
not sent until you close the filehandle. And don't forget to put
in the error checking I left out. :)

Hugo van der Sanden


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

Date: Tue, 04 Feb 1997 18:51:08 -0600
From: bart@cloud9.net
Subject: Need CGI script that reads files from another HTTP server...
Message-Id: <855103447.28814@dejanews.com>

I am looking for a CGI script that will read files from an HTTP server and return them to the client.  I would appreciate it if someone could point me to a nice simple, expandable script that will do the job.  What I really want to do is combine sever files from another HTTP server into a combined file. It could be called like: http:/www.whatever.com/cgi-bin/getsite.cgi?HREF1=www.microsoft.com/index.html/&HREF2=whatever.com
ANY replies will be appreciated!  Please CC me at my email address.
Thanks a lot,
---Bart, bart@cloud9.net

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Fri, 31 Jan 1997 23:11:29 GMT
From: marcie@meta3.com (Joy ('Marcie') Locke)
Subject: Re: Need Script
Message-Id: <32f27c16.178776137@news>

On Thu, 30 Jan 1997 19:46:31 -0500, "Gary A. Sylvia"
<atm4news@wsii.com> wrote:

>E-mail Me for full details

You've gotta be kidding.

Joy "Marcie" Locke =/\= Now Voyager =/\= NrrdGrrl! ==
= reply address altered to prevent spam: remove the =
= word "spam" to reply ==============================
=============== http://www.nerdherd.net/marcie ======


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

Date: 5 Feb 1997 00:51:54 GMT
From: ncpsltd@aol.com (NCPSLtd)
Subject: Nice perl way to generate n! permutations for n=8 ??
Message-Id: <19970205005100.TAA09653@ladder01.news.aol.com>

I'm unable to come up with a nice "algorithm" to generate the permutations
for 12345678.  

Perl has always given me clever, compact ways to do such jobs, and I'm at
a loss for this one.

Ideas, gurus ??
Thanks very much.

grechnitz@juno.com


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

Date: Tue, 4 Feb 1997 16:27:34 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: opening a file in a Recursive Call (Perl Question)
Message-Id: <m4d8d5.ij4.ln@localhost>

Samir Grover (sgrover@elizacorp.com) wrote:
: Hello all,
: I think my problem is overwring the same filehandle.

: Consider this:
: ...
: $inName = "foo";
: &doCommand($inName);
: ....
: ....
: sub doCommand {

: open(FILEHANDLE, "$_[0]");
: while ($x = <FILEHANDLE>) {
: 	...
: 	...
: 	&doCommand($x);
: 	...
: }

: #END

: When doCommand is called recursively from itself, it looks like its
: overwriting 
: FILEHANDLE and, thus it stops without completing the reading of very first
: file.
: How to get rid of this problem?
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


You simply read FAQ #5.25  ;-)

Don't see how you missed that when you checked before posting
(*all* good net citizens check before posting, so I'm assuming 
you did too, you just missed this one which answers your question...)


5.25) How can I use pass a filehandle to a function, or make a list of
      filehandles?

    If you've ever tried to use a variable for a filehandle, you may well
    have had some problems.  This is just revealing one of the icky places
    in perl: filehandles aren't first-class citizens the way everything
    else is, and it really gets in the way sometimes.

    ...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 5 Feb 97 00:28:53 GMT
From: dchee@uci.edu (Derek Chee)
Subject: Output SMTP-compatible date?
Message-Id: <derek.855102533@holmes.oas.uci.edu>


Does anybody know of a quick function or module that will output an
SMTP format compatible date (i.e., Tue, 4 Feb 1997 16:05:15 -0800)
using the current time?  Right now I'm just letting sendmail insert
the Date: field, but that seems sloppy to me.

-- Derek
--
___________________________________________________________________________
Derek Chee (dchee@uci.edu)        |  This signature is in need of repair.
Office of Analytical Studies      |  Accepting contractor bids now.
University of California, Irvine  |


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

Date: 05 Feb 1997 01:49:51 +0100
From: Gabriel Dos Reis <dosreis@DPTMaths.ENS-Cachan.Fr>
Subject: paching nested C-structure
Message-Id: <v8vn2tk6pqo.fsf@piano.dptmaths.ens-cachan.fr>



How does one pack the utmpx scturture in Perl ? Just saying

$utmpx_t = 'A32 A4 A32 l s s2 l2  l l5 s A257';

doesn'y work. (Its size is 369 bytes whereas a C-program (included
below) says it is 372 bytes) 

Any help appreciated.

-- Gaby



##################### utmpx struct ##############################
     struct utmpx  {
        char    ut_user[32];                /* user login name */
        char    ut_id[4];                   /* inittab id */
        char    ut_line[32];                /* device name */
                                            /* (console, lnxx) */
        pid_t   ut_pid;                     /* process id */
        short   ut_type;                    /* type of entry */
        struct  exit_status ut_exit;        /* process termination/exit */
                                            /* status */
        struct  timeval ut_tv;              /* time entry was made */
        long    ut_session;                 /* session ID, used for */
                                            /* windowing */
        long    pad[5];                     /* reserved for future use */
        short   ut_syslen;                  /* significant length of */
                                            /* ut_host */
                                            /* including terminating null */
        char    ut_host[257];               /* remote host name */
        };
############################################################


############# exit_status struct ###########################
struct exit_status {
        short e_termination;    /* Process termination status */
        short e_exit;           /* Process exit status */
};
############################################################


################## timeval struct #########################
struct timeval {
        long    tv_sec;         /* seconds */
        long    tv_usec;        /* and microseconds */
};
###########################################################


/************ The C program *************/

#include <stdio.h>
#include <utmpx.h>

main()
{
    printf("%d\n", sizeof(struct utmpx));
}

/****************************************/




-- 
"God never does mathematics."
	-- H. Hahn.


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

Date: Tue, 04 Feb 1997 15:28:15 -0500
From: John Fishbone <emf@remus.rutgers.edu>
Subject: PERL AND C ROUTINES
Message-Id: <32F79BAE.168A@remus.rutgers.edu>

I need to call the "crypt function that is found in the unistd.h"

Can I call this function from within my PERL script? 

Does anyone know if i call this will I be able to give it filehandles
as paramters or just straight files from my UNIX environment?

Thanks!


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

Date: 4 Feb 1997 23:04:16 GMT
From: msl@kewlaid.highfiber.com (Anicia Limmany)
Subject: Perl problem, help!
Message-Id: <5d8f9g$h08@underdark.highfiber.com>

I'm relatively new to perl, and I'm having some problems.

Situation: I've got a file containing data, and I want to get my perl program 
to read the file containing data, and strip it of essential information, and 
write that to the screen.  It works right now, but with two problems.

1) Problem one.  The data file has <CR>s at the beginning of the file and it 
is reading it in, so when the program writes to the screen, it's having a 
whole bunch of <CR>s at the top of the screen before I see any data.

2) Problem two.  I need to tell the program to stop when it reaches the EOF. I 
Right not, it keeps on scrolling on forever until it is canceled.

Here's the code:

#!/usr/bin/perl
# a report on bom data
format STDOUT_TOP =

 .
format STDOUT = 
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$MOD                               
 .


open(INPUT, '/users/dscampb/bom/bill_of_materials') || die "Can't open file: $!\n";

while (INPUT) {
$_ = <INPUT>;
tr/a-zA-Z0-9=_.?-/,/cs;
$in = substr($_,2,1);                 # save check for data line 
if (s/Bill,Of,Materials/ /){
   $modiss = substr($_,1,15); 
}   

if (s/ITEM_NUMBER/ /){
   next;
   }elsif ($in =~ /^[0-9]/) { 
   next;
   }else {
print $modiss; 
print;
}
($mod) = split(/ /);    
write;
}

And here's the data file:

 FIL-15     00131-SS     Bill Of Materials 
 
 


  ITEM_NUMBER       COMPANY PART NO.            GEOMETRY         COUNT            PROPERTIES/REC_ID/TOOL                REFERENCE      

       1                 1N4112                    d07             2    rec_id=463, tool=R35199-0.550               CR6 CR7            
       2                 1N4534                   d034             3    rec_id=466, tool=R35199-0.375               CR3 CR4 CR5        
       3                 1N5806                  axial4            3    rec_id=494, tool=R35199-0.450               CR1 CR2 CR8        
       4                  2000               diameter_2.000        1                                                L1                 
       5                 2N2222A                 vt018co           1    rec_id=1863, tool=T98609                    Q2                 
       6                 2N2907A                 vt018co           1    rec_id=2051, tool=T98609                    Q1                 
       7              44/0411-22-9             wpd086_042          6    rec_id=2127                                 Q3_D Q3_S Q4_D     
                                                                                                                    Q4_S Q5_D Q5_S     
       8              44/7011-24-9             wpd062_030          3    rec_id=2124                                 Q3_G Q4_G Q5_G     
       9              44/7011-26-9               jumper2           2    rec_id=2125                                 HW1 HW2            
      10                   500                diameter_.500        2                                                L4 L5              
      11                   600                diameter_.600        2                                                L2 L3              
      12               87106-1.2UF          cap_desc5_no-tie       1    rec_id=2783                                 C51                
      13               87106-2.2UF          cap_desc5a_no-tie      2    rec_id=2647                                 U4 U5              
      14               87106-3.3UF          cap_desc5b_no-tie      3    rec_id=3378                                 C48 C49 C50        
      15                 AR9104              bead_.405_4pins       3    rec_id=5243                                 B3 B6 B7           
      16                AR9101-1                bead_.168          2    rec_id=1859, tool=S91109-0.350              B4 B5              
      17                CD4093BK              fp14_mil_std         1    rec_id=93, tool=R37944-225                  U3                 
      18              CKR11-0.01UF                ckr11            3    rec_id=571, tool=S91109-0.350               C42 C43 C47        
      19             CKR11-10PF-NPO               ckr11            1    rec_id=518, tool=S91109-0.350               C7                 
      20             CKR11-220PF-NPO              ckr11            1    rec_id=550, tool=S91109-0.350               C10                
      21             CKR11-330PF-NPO              ckr11            1    rec_id=547, tool=S91109-0.350               C9                 
      22               CKR11-33PF                 ckr11            1    rec_id=561, tool=S91109-0.350               C8                 
      23              CKR11-4700PF                ckr11            1    rec_id=576, tool=S91109-0.350               C41                
      24             CKR11-560PF-NPO              ckr11            1    rec_id=556, tool=S91109-0.350               C16                
      25              CKR12-0.01UF                ckr12            4    rec_id=578, tool=S91109-0.425               C13 C14 C18 C23    
      26              CKR12-0.047UF               ckr12            1    rec_id=586, tool=S91109-0.425               C44                
      27             CSR13-50VC-18UF             csr13c           16    rec_id=1535, tool=S91109-1.025              C24 C25 C26 C27    
                                                                                                                    C28 C29 C30 C31    
                                                                                                                    C32 C33 C34 C35    
                                                                                                                    C36 C37 C45 C46    
      28                  DW38                  trans_rw3          1    rec_id=3554                                 T1                 
      29                HA2-2520                 vt099co           1    rec_id=777, tool=T98609                     U2                 
      30                HA2-2600                 vt099co           1    rec_id=805, tool=T98609                     U1                 
      31               HDRA004-71G             pin_conn4b         11    rec_id=3549                                 B A C D E F G H I  
                                                                                                                    J K                
      32         MG-211-074-145-0000-T06       conn74pscm          1    rec_id=5073                                 J1                 
      33                PD062_030              wpd062_030          4                                                L4_1 L4_2 L5_1     
                                                                                                                    L5_2               
      34                PD075_034              wpd075_034          8                                                L2_1 L2_2 L2_3     
                                                                                                                    L2_4 L3_1 L3_2     
                                                                                                                    L3_3 L3_4          
      35                PD086_042              wpd086_042          6                                                L1_1 L1_2 L1_3     
                                                                                                                    L1_4 L1_5 L1_6     
      36                PD125_067              wpd125_067          1                                                A1                 
      37              PICO-267-1.5A               fuse1           20    rec_id=1443, tool=R35199-0.500              F3 F4 F5 F6 F7 F8  
                                                                                                                    F9 F10 F11 F12 F13 
                                                                                                                    F14 F15 F16 F17    
                                                                                                                    F18 F19 F20 F23    
                                                                                                                    F24                
      38                RNC50-100                 rnc50            2    rec_id=1116, tool=S91109-0.350              R18 R24            
      39               RNC50-100K                 rnc50            3    rec_id=2460, tool=S91109-0.350              R2 R4 R5           
      40                RNC50-10K                 rnc50            1    rec_id=1207, tool=S91109-0.350              R11                
      41                RNC50-20K                 rnc50            1    rec_id=1990, tool=S91109-0.350              R16                
      42               RNC50-26.7K                rnc50            1    rec_id=1996, tool=S91109-0.350              R15                
      43                RNC50-2K                  rnc50            1    rec_id=1175, tool=S91109-0.350              R21                
      44               RNC50-30.1K                rnc50            2    rec_id=2408, tool=S91109-0.350              R14 R25            
      45                RNC50-698                 rnc50            1    rec_id=2495, tool=S91109-0.350              R12                
      46               RNC50-90.9K                rnc50            1    rec_id=1251, tool=S91109-0.350              R17                
      47              RNC50-SELECT                rnc50            3    rec_id=3541, tool=S91109-0.350              R6 R8 R34          
      48               RWR81-0.215                rwr81            1    rec_id=628, tool=S91109-0.425               R20                
      49               RWR81-1.21                 rwr81            1    rec_id=633, tool=S91109-0.425               R30                
      50               RWR81-1.82                 rwr81            1    rec_id=631, tool=S91109-0.425               R22                
      51                RWR81-10                  rwr81            2    rec_id=651, tool=S91109-0.425               R9 R10             
      52                RWR81-226                 rwr81            1    rec_id=704, tool=S91109-0.425               R13                
      53               RWR81-4.64                 rwr81            1    rec_id=647, tool=S91109-0.425               R23                
      54              RWR81-SELECT                rwr81            7    rec_id=3544, tool=S91109-0.425              R1 R3 R7 R19 R31   
                                                                                                                    R32 R33            
      55               S61363-000                                  2    rec_id-1772_insulator                                          
      56               S61363-002                                  2    rec_id-1771_insulator                                          
      57             SC-P-0-80X.188                                4    rec_id-4256_PAN_HEAD_SCREW_CR_0-80X.188                        
      58               T90648-000                                  1    CONNECTOR_MOUNT                                                
      59                WIRE_BUSS                                  1    #24_AWG_SOLID_TINNED                                           





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

Date: Wed, 5 Feb 1997 01:03:37 GMT
From: Eric Wong <egwong@netcom.com>
Subject: Re: Perl problem, help!
Message-Id: <egwongE53uy1.Cno@netcom.com>

Anicia Limmany <msl@kewlaid.highfiber.com> wrote:
: I'm relatively new to perl, and I'm having some problems.

: Situation: I've got a file containing data, and I want to get my perl program 
: to read the file containing data, and strip it of essential information, and 
: write that to the screen.  It works right now, but with two problems.
 
: 1) Problem one.  The data file has <CR>s at the beginning of the file and it 
: is reading it in, so when the program writes to the screen, it's having a 
: whole bunch of <CR>s at the top of the screen before I see any data.

To read the file until the first non-blank line:
  while (<INPUT> =~ /^$/) { ; }

: 2) Problem two.  I need to tell the program to stop when it reaches the
: EOF.  I  Right not, it keeps on scrolling on forever until it is
: canceled.

: Here's the code:
[ cut ]

: while (INPUT) {
: $_ = <INPUT>;

Here's your problem.  These two lines ought to be replaced with
  while (<INPUT>)     # read next line of INPUT and put it in scalar $_

Your statement 'while (INPUT)' will always be true.

Actually, you could solve both problems with
  while (<INPUT>) {
    next if (/^$/); 
    .
    .
    etc.
    .

The 'next' statement says that if the line is empty, skip the
rest of the loop.

[ cut ]
[ cc'd ]


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

Date: 04 Feb 1997 15:14:54 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: fpostma@inter.nl.net
Subject: Re: regex eats newline?
Message-Id: <JFRIEDL.97Feb5001454@tubby.nff.ncl.omron.co.jp>

[mail and post]

Frans Postma <F.Postma@inter.NL.net> wrote:
|> #!perl
|> $x='Subject:
|> To: bla@abla
|> Date: Sat 01-02-1997';
|> $x=~s/Subject:\s*([^\n]*?)\s*\n/Subject: $1\n/im;
|> print $x;
|> __END__
|> 
|> Output of this is:
|> Subject: To bla@abla
|> Date: Sat 01-02-1997
|> 
|> Question: why does the regexp on $x eat the line on the Subject line?

Because \s can match a newline. Use, perhaps, [\t ] and your problem
will go agway.

	Jeffrey

PS: boiling down the problem into a short snippet was a good idea. I wish
    all posters did so. Thanks.

----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@omron.co.jp> Omron Corp, Nagaokakyo, Kyoto 617 Japan
O'Reilly & Associates' _Mastering Regular Expressions_
                                   http://enterprise.ic.gc.ca/~jfriedl/regex/


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

Date: Tue, 04 Feb 1997 14:40:43 -0800
From: Kevin Healy <kevlar@ns.net>
Subject: Re: space stripping
Message-Id: <32F7BAEB.2781@ns.net>

Tom Christiansen wrote:
> 
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc,
>     Randal Schwartz <merlyn@stonehenge.com> writes:
> :From one of the slides in my class:
> :       while (<>) {
> :               s/#.*//; # kill comments
> :               next if /^\s*$/; # skip blanks
> :               redo if s/\s*\\\s*\n$/<>/e; # fold \
> :               s/^\s*//; # kill prefix whitespace
> :               s/\s*$//; # and suffix whitespace
> :               ...
> :       }
> :
> :Yours, for free. :-)
> 
> I think I would much prefer
> 
>     s/^\s+//; # kill prefix whitespace
>     s/\s+$//; # and suffix whitespace
> 
> Go read jfriedl's book for why. :-)

Is it available outside of ora.com?  My bookstore (Stacey's) has
had it on order for months but it is still nowhere to be found.
Do tell...

Kevin

<kevlar@ns.net>



> 
> --tom
> --
> Tom Christiansen      Perl Consultant, Gamer, Hiker      tchrist@mox.perl.com
>     > This made me wonder, suddenly: can telnet be written in perl?
>     Of course it can be written in Perl.  Now if you'd said nroff,
>     that would be more challenging...   --Larry Wall


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

Date: Tue, 4 Feb 1997 18:01:42 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: space stripping
Message-Id: <6li8d5.q05.ln@localhost>

Kevin Healy (kevlar@ns.net) wrote:
: Tom Christiansen wrote:
: > 
: >  [courtesy cc of this posting sent to cited author via email]
: > 
: > In comp.lang.perl.misc,
: >     Randal Schwartz <merlyn@stonehenge.com> writes:
: > :From one of the slides in my class:
: > :       while (<>) {
: > :               s/#.*//; # kill comments
: > :               next if /^\s*$/; # skip blanks
: > :               redo if s/\s*\\\s*\n$/<>/e; # fold \
: > :               s/^\s*//; # kill prefix whitespace
: > :               s/\s*$//; # and suffix whitespace
: > :               ...
: > :       }
: > :
: > :Yours, for free. :-)
: > 
: > I think I would much prefer
: > 
: >     s/^\s+//; # kill prefix whitespace
: >     s/\s+$//; # and suffix whitespace
: > 
: > Go read jfriedl's book for why. :-)

: Is it available outside of ora.com?  My bookstore (Stacey's) has
: had it on order for months but it is still nowhere to be found.
: Do tell...


I've checked for it several times at Borders and Book Stop. Neither
even could tell that it was a book in print...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 4 Feb 1997 21:59:03 GMT
From: Steve Johnson <stevej@wco.com>
Subject: Spooling gifs
Message-Id: <5d8bf7$n30@news.wco.com>



I've seen counters that you call up via an <img src="couter"> type
command.  And I Sapose the cgi program just streams the gif data directly
to the web browser.. (graphicle counters do this)    My Question is how is
this done?  Can someone post an example of this?  thanks

-Steve



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

Date: 4 Feb 1997 23:40:26 GMT
From: Matt Kruse <mkruse@shamu.netexpress.net>
Subject: Telnet through Proxy?  protocol negotiations
Message-Id: <5d8hda$q7c@news1-alterdial.uu.net>

I have a telnet script working fine on unix and NT.  But now I want to 
telnet through a proxy, and it's not going well :(

I can login to the proxy and issue a telnet command from there, but then 
I get an IAC request.  255 253 24, to be exact.  I know enough about the 
telnet protocol to know that I'm supposed to negotiate some settings, 
here, but I have no idea what they are or how my client should respond.  
All I want is a nice, easy connection like the first one to the proxy :)

Is there an easy way to handle this?  Is there a piece of code that will 
handle the negotiations for me and just get a unix prompt?  (I'm 
telnetting into linux).  Or do I really have to dive into RFC 854 to 
figure this junk out?

Thanks!

-- 
Matt Kruse
mkruse@netexpress.net
http://www.netexpress.net/~mkruse/                  http://www.mkstats.com/
---------------------------------------------------------------------------
Unsolicited advertising of any type to this addresss will not be tolerated.


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

Date: 5 Feb 1997 01:35:46 GMT
From: "Rick Osborne" <osborri@mail.northgrum.com>
Subject: Re: Trimming Dollar Value
Message-Id: <01bc1304$dc887aa0$1f7fe484@mlbweb>

Bok Nan Lo <support@inklineglobal.com> wrote in article
<01bc12ba$5595f800$61a915a5@cafe>...
> I'm having hard time with formatting and trimming an amount in a
variable.

$var=int($var*100)/100;

_________ o s b o r n e @ g a t e w a y . g r u m m a n . c o m _________
We would've believed it was an accidental shooting if he hadn't changed
magazines ......TWICE


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

Date: 5 Feb 1997 01:38:38 GMT
From: Chaimf@cris.com (Chaim Frenkel)
Subject: Re: Trimming Dollar Value
Message-Id: <5d8oau$gp8@chronicle.concentric.net>

[cc sent to poster]

Assuming you've removed any non-numeric garbage...

	int($amount*1e2+.5)/1e2		# To round.
	int($amount*1e2)/1e2		# To truncate.

<chaim>

In article <01bc12ba$5595f800$61a915a5@cafe> (comp.lang.perl.misc) you wrote:
: I'm having hard time with formatting and trimming an amount in a variable.
: 
: e.g. $3.4405
: 
: I just wanted it to be $3.44 rather than four decimal places. How can I get
: it solved?!
: 
: P/S: I want to actually trim it rather than formatting to STDOUT using
: printf().
: 


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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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 V7 Issue 895
*************************************

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