[8361] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1978 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 26 05:08:05 1998

Date: Thu, 26 Feb 98 02:00:32 -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           Thu, 26 Feb 1998     Volume: 8 Number: 1978

Today's topics:
    Re: better way to do this? uri@sysarch.com
    Re: better way to do this? (Craig Berry)
    Re: CGI.pm a part of Perl (was Re: Cookies) <rjk@coos.dartmouth.edu>
    Re: CGI.pm a part of Perl (was Re: Cookies) uri@sysarch.com
    Re: CGI.pm a part of Perl (was Re: Cookies) uri@sysarch.com
    Re: CGI.pm a part of Perl (was Re: Cookies) (Bart Lateur)
    Re: convert a string to a number <vulture@teleport.com>
        Getting Directory Listing <fake@here.com>
    Re: Getting Directory Listing <eike.grote@theo.phy.uni-bayreuth.de>
    Re: Getting Directory Listing (Tom Grydeland)
    Re: Getting Directory Listing <naamah@haifa.vnet.ibm.com>
    Re: How do I create my own perl libraries? [SEEFAQ][SEE (Martin Vorlaender)
    Re: Newbie Question about Perl and Server Side Includes <cartwrightm@ssg.gunter.af.mil>
    Re: Newbie Question: df in a perl script <jhi@alpha.hut.fi>
        ODBC.pm and Fetch() <bob_barthelow@hp.com>
    Re: Regex substitutions <rjk@coos.dartmouth.edu>
    Re: Regex substitutions <danboo@negia.net>
    Re: Replacement of characters <rjk@coos.dartmouth.edu>
    Re: Script error need help please.... uri@sysarch.com
        splitting with a '\' (backlash) <glchy@csah.com>
    Re: splitting with a '\' (backlash) <eike.grote@theo.phy.uni-bayreuth.de>
    Re: splitting with a '\' (backlash) (Tom Grydeland)
    Re: The Ineffable Tom C. (Tom Grydeland)
    Re: Unwanted Character Displays <rjk@coos.dartmouth.edu>
        using a Module <naamah@haifa.vnet.ibm.com>
    Re: Using strings as filehandles (Jonathan Feinberg)
    Re: Using strings as filehandles (Craig Berry)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 26 Feb 1998 01:11:27 -0500
From: uri@sysarch.com
Subject: Re: better way to do this?
Message-Id: <x7yayy28vk.fsf@sysarch.com>

mocat@spamtrap.best.com (jay) writes:

> #!/usr/bin/perl
> %images = (
> 	"jpg"  =>  "jpeg image",
> 	"jpeg" =>  "jpeg image",
> 	"gif"  =>  "gif image",
> );
> @html = <>;
> foreach $line (@html) {
>         ($imgargs) = $line =~ /<img(.*?)>/i;
>         if ($imgargs !~ /\balt\s?=/i) {

use \s* since there could be more than 1 whitespace

>                 ($alt) = $imgargs =~ /\bsrc\s?=\s?"(.*?)"/i;

use \s* since there could be more than 1 whitespace

>                 $size = -s $alt;
>                 ($imgtype) = $alt =~ /\.(.*?)$/;
>                 $line =~ s/\bsrc/alt="$images{$imgtype}($size bytes)"
> src/i; #damn wordwrap :)
>         }
>                 print $line;
> }                                                         

i'm glad you added the image type and size. you still haven't addressed
the possibility that the <img> itself could be wrapped around a
line. that is where doing a global replace on the single string of the
entire file wins. you could still use most of your new code but the
s///xeg statement i previously posted will process the entire file for
you. 

uri

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


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

Date: 26 Feb 1998 07:04:36 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: better way to do this?
Message-Id: <6d3464$gac$1@marina.cinenet.net>

jay (mocat@spamtrap.best.com) wrote:
: Alright, with some help from you guys, and some tweaking around of my
: own, here is what I got so far:
: 
: #!/usr/bin/perl

Still no -w and 'use strict'?  Do you *enjoy* pain? :)

: %images = (
: 	"jpg"  =>  "jpeg image",
: 	"jpeg" =>  "jpeg image",
: 	"gif"  =>  "gif image",
: );

No need to quote the keys on the left sides of => (that's one of the
nicest things about => as an alternative for comma). 

: @html = <>;
: foreach $line (@html) {
:         ($imgargs) = $line =~ /<img(.*?)>/i;
:         if ($imgargs !~ /\balt\s?=/i) {

Might suggest \s* rather than \s? -- can be any number of spaces before 
the '='.

:                 ($alt) = $imgargs =~ /\bsrc\s?=\s?"(.*?)"/i;

Ditto on both \s? here.

:                 $size = -s $alt;
:                 ($imgtype) = $alt =~ /\.(.*?)$/;

That regex won't work on file pathnames with more than one . in them.  I 
think you want /\.([^.\/]*)$/ instead.

:                 $line =~ s/\bsrc/alt="$images{$imgtype}($size bytes)"
: src/i; #damn wordwrap :)

Might suggest /\bsrc\b/ in the match part.

:         }
:                 print $line;
: }                                                         
: 
: It works fine, except for one thing...
: When I try to match $imgtype, it works fine for normally named images
: such as indexmap.gif, but it doesn't match anything for images named,
: say, index.map.gif.  I don't know why this pattern match is not
: working.

Ah, good, you noticed -- made comments above before reading this.  Let's 
look at your regex:

   /\.(.*?)$/

In English, that read "A literal dot, followed by the least-length run of
zero or more non-newline characters, ending at the end of string."  That
sounds weird because with that $ anchor right afterward, the non-greedy ?
modifier doesn't mean anything.  Eliminating it gives us

  /\.(.*)$/

which means "A literal dot, followed by a run of zero or more non-newline 
characters, followed by the end of string (or a newline just before it)."

This pattern will always store into $1 everything following the first . 
through the end of the string (minus any trailing newline).

My alternative is

  /\.([^.\/]*)$/

or "A literal dot, followed by a run of zero or more non-dot, non-slash
characters, ending at the end of string."  This would require some
tweaking if newline could be at the end of string, but that can't happen
in your case. 

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


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

Date: Thu, 26 Feb 1998 00:14:24 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: CGI.pm a part of Perl (was Re: Cookies)
Message-Id: <34F4FA30.EADD487@coos.dartmouth.edu>

John Porter wrote:
> 
> Nah, I propose that Perl (uc) is the full distribution, while
> perl (lc) is the interpreter and the language being interpreted.

Actually, that would be Perl (ucfirst lc) and perl (lc).  :-)

-- 
 _ / '  _      /             rjk@coos.dartmouth.edu
( /)//)//)(//)/(                     chipmunk@m-net.arbornet.org
    /                                        http://www.ziplink.net/~rjk/
        It's funny 'cause it's true ... and vice versa.


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

Date: 26 Feb 1998 00:38:49 -0500
From: uri@sysarch.com
Subject: Re: CGI.pm a part of Perl (was Re: Cookies)
Message-Id: <x71zwr2ady.fsf@sysarch.com>

John Porter <jdporter@min.net> writes:

> uri@sysarch.com wrote:
> > 
> 
> Nah, I propose that Perl (uc) is the full distribution, while
> perl (lc) is the interpreter and the language being interpreted.
                                       ^^^^^^^^
again, perl is the program/interpreter/command and Perl is the language.
a program can't be a language, only an implementation of a language. the
fact that there is generally only 1 perl doesn't change that. actually
ther is more than 1 perl depending on your version, but the language is
generally is most accurately supported by the latest version (and no
guarantee that is bug free). theoretically a language is always bug
free :-) but its compilers/interpreters are not. (PL/I being a major
exception since the ANSI language specs has know inconsistancies/bugs)

as martien wrote in another followup, i use larry's definition

Perldoc perlfaq1

	What's the difference between "perl" and "Perl"?

	One bit.  Oh, you weren't talking ASCII? :-) Larry now uses "Perl"
	to signify the language proper and "perl" the implementation of
	it, i.e. the current interpreter.

uri

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


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

Date: 26 Feb 1998 01:16:18 -0500
From: uri@sysarch.com
Subject: Re: CGI.pm a part of Perl (was Re: Cookies)
Message-Id: <x7wwei28nh.fsf@sysarch.com>

Chipmunk <rjk@coos.dartmouth.edu> writes:

> John Porter wrote:
> > 
> > Nah, I propose that Perl (uc) is the full distribution, while
> > perl (lc) is the interpreter and the language being interpreted.
> 
> Actually, that would be Perl (ucfirst lc) and perl (lc).  :-)

i missed john's post with the uc/lc. but he is disagreeing with larry's
definition. i say we make the infidel program in cobol :-)

uri

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


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

Date: Thu, 26 Feb 1998 08:37:21 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: CGI.pm a part of Perl (was Re: Cookies)
Message-Id: <34f528af.3187407@news.tornado.be>

mgjv@comdyn.com.au (Martien Verbruggen) wrote:

>What about the core modules, like CORE, UNIVERSAL, SUPER, Dynaloader,
>Exporter, etc.. etc.. Are they not part of perl? What about the
>pragmatic modules? strict? diagnostics? vars? builtin?

Somehow I have difficulty to see "strict" as a module.

HTH,
Bart.


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

Date: Wed, 25 Feb 1998 22:04:53 -0800
From: Terry Ellis <vulture@teleport.com>
Subject: Re: convert a string to a number
Message-Id: <Pine.GSO.3.96.980225220035.9079D-100000@user2.teleport.com>

$y = $x ; # does the trick, but then $x was already a number. (see
Programming Perl). 

On Wed, 25 Feb 1998, Maxine G. wrote:

> I'm afraid this may be one of those really obvious beginner questions, but 
> here goes:
> How do I convert a string containing numeric data to a numeric variable? In 
> other words, if I have $x = "0123", I want $y = 123. 
> tia!
> 
>  
> *********************************************************
> return address changed to prevent spamming
> Remove "NOSPAM" in the return address
> Maxine Gerber
> PCG Systems
> *********************************************************
> 
> 

TE



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

Date: 26 Feb 1998 07:46:09 GMT
From: "Alex" <fake@here.com>
Subject: Getting Directory Listing
Message-Id: <01bd428a$9f97fce0$83834dd1@default>

Anyone know howto read a directory listing into an array?
Thanks.



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

Date: Thu, 26 Feb 1998 09:57:16 +0100
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: Getting Directory Listing
Message-Id: <34F52E6C.167E@theo.phy.uni-bayreuth.de>

Hi,

Alex wrote:
> 
> Anyone know howto read a directory listing into an array?

Use opendir() - readdir() - closedir():

   opendir(DIR,$directory);
   @list = readdir(DIR);
   closedir(DIR);


Bye, Eike
-- 
=======================================================================
>>--->>    Eike Grote  <eike.grote@theo.phy.uni-bayreuth.de>    <<---<<
-----------------------------------------------------------------------
 Home Page, Address, PGP,...:  http://www.phy.uni-bayreuth.de/~btpa25/
-----------------------------------------------------------------------
 PGP fingerprint:      1F F4 AB CF 1B 5F 4B 1D 75 A1 F9 C5 7B 3F 37 06
=======================================================================


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

Date: 26 Feb 1998 09:39:02 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Getting Directory Listing
Message-Id: <slrn6fae1m.v6e.Tom.Grydeland@mitra.phys.uit.no>

On 26 Feb 1998 07:46:09 GMT,
Alex <fake@here.com> wrote:
> Anyone know howto read a directory listing into an array?
> Thanks.
> 

readdir


-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: Thu, 26 Feb 1998 11:55:17 +0200
From: Naama Kraus <naamah@haifa.vnet.ibm.com>
To: Alex <fake@here.com>
Subject: Re: Getting Directory Listing
Message-Id: <34F53C05.A9898472@haifa.vnet.ibm.com>

Alex wrote:

> Anyone know howto read a directory listing into an array?
> Thanks.

@Array = `ls`;chomp @Array;
  Naama.   --> naamah@haifa.vnet.ibm.com





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

Date: Thu, 26 Feb 1998 06:06:12 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: How do I create my own perl libraries? [SEEFAQ][SEEMAN]
Message-Id: <34f4f844.524144494f47414741@radiogaga.harz.de>

Joe McMahon (joe.mcmahon@gsfc.nasa.gov) wrote:
[...]
: one of the default places Perl looks for modules is in the same directory as
: the one where the program resides.

No. perl looks for modules in the current working directory, not in the
one where the program resides.

That's where some trouble stems from with Micro$oft's IIS, when it calls
CGI scripts with the CWD set to the top-level cgi-bin directory.

cu,
  Martin
--
                          | Martin Vorlaender | VMS & WNT programmer
 Ceterum censeo           | work: mv@pdv-systeme.de
 Redmondem delendam esse. |       http://www.pdv-systeme.de/users/martinv/
                          | home: martin@radiogaga.harz.de


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

Date: Wed, 25 Feb 1998 12:21:46 -0600
From: Mark Cartwright <cartwrightm@ssg.gunter.af.mil>
Subject: Re: Newbie Question about Perl and Server Side Includes
Message-Id: <34F4613A.8DB6266B@ssg.gunter.af.mil>

I don't believe that the Personal Web server supports server-side
includes at all...  It is not a very robust server at all.  if you
insist on running a server on your 95 box (for testing or whatever you
use it for) try FNORD.  I think it has SSI, and is also free, as well as
being much more feature-rich.  You can download it from your local
Tucows mirror (http://www.tucows.com to find a mirror); I found it very
simple to set up when i ran it under 95.  Good luck.

Phil Anderson wrote:
> 
> I am new to programming PERL and am having problems getting a Server Side
> Include to function correctly.
> 
> My PERL script generates all the HTML and sends it to the browser, but the
> server doesn't seem to recognize the <!--#include file="x.html"--> tag.  By
> that I mean it doesn't do the include, I see the tag as a comment in the
> HTML source.
> 
> I'm running PersonalWebServer Win95 with PERL version 5.003_07.
> 
> Thanks in advance
> --------------------
> Phil Anderson
> AMC Theatres
> EMail: PAnderson@AMCTheatres.com

-- 
Mark Cartwright
GTE Government Systems
HQ/SSG Network Control Division - SCLW


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

Date: 26 Feb 1998 10:59:05 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Newbie Question: df in a perl script
Message-Id: <oee67m2hhd2.fsf@alpha.hut.fi>


> Is there anyway to similulate or pass a df -k command in a perl script?
> Specifically, I need to find the percent of capacity occupied on the disk.
> I've tried to use stat but it isn't supplying the info I need.
> --Mark Witt--                             --"Psychiatrists say that 1 of 4--
> --mc-witt@students.uiuc.edu--          --people are mentally ill.  Check 3--

system() (what others have proposed) won't do because from that you won't
get any input.  open(DF, "df -k|") and you can read the output of the
command.  You will need split() and/or regexes to parse the output.

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: Tue, 24 Feb 1998 10:20:28 -0800
From: bob_barthelow <bob_barthelow@hp.com>
Subject: ODBC.pm and Fetch()
Message-Id: <34F30F6C.3FAC@hp.com>

I am using the 970208 version of ODBC.pm and am uncertain if this
supports only SQLExtendedFetch() or if SQLFetch() is still available.
The ODBC driver I must use does not support SQLExtendedFetch(). Does
anyone know?

thanks
bob


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

Date: Thu, 26 Feb 1998 00:31:39 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Jerome O'Neil <joneil@cks.ssd.k12.wa.us>
Subject: Re: Regex substitutions
Message-Id: <34F4FE3C.F27B7349@coos.dartmouth.edu>

[posted and mailed]

Jerome O'Neil wrote:
> 
> possible formats it was in.  The problem was that .+ is a greedy operator,
> and misunderstood what that meant.  The .+? fixed it.

I'd recommend using '[^(]+' rather than '.+?'.  For your regex and your target
strings, they should match the same thing, but the former will be much more
efficient, and is more explicit about what you are trying to do.

-- 
 _ / '  _      /             rjk@coos.dartmouth.edu
( /)//)//)(//)/(                     chipmunk@m-net.arbornet.org
    /                                        http://www.ziplink.net/~rjk/
        It's funny 'cause it's true ... and vice versa.


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

Date: Thu, 26 Feb 1998 00:23:28 -0500
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Regex substitutions
Message-Id: <34F4FC50.F3EFD578@negia.net>

Jerome O'Neil wrote:
> 
> Dan Boorstein wrote:
> 
> > my idea is to replace the end of the string, that is all the
> > parens and their possible leading space, with themselves
> > preceded by a space and the string to add.
> >
> 
> That is a soulution, but the context of my (within a loop) regex precludes
> it.  It looks like this:

uhh, but isn't this effectively the same as Christopher Masto's (which
you liked)? i may have shown its effectiveness differently, but the
regex is almost identical.

dan


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

Date: Thu, 26 Feb 1998 00:34:20 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Michael Martin <dmmartin@home.net>
Subject: Re: Replacement of characters
Message-Id: <34F4FEDD.176B4B5E@coos.dartmouth.edu>

[posted and mailed]

Michael Martin wrote:
> 
> $buffer =~ s/%28/(/ig; #the i and the g tell perl to be case insensitive, and
>                        #to match multiple times in one string
> $buffer =~ s/%29/)/ig;

Because you never know when you're going to encounter an uppercase percent symbol...

???

-- 
 _ / '  _      /             rjk@coos.dartmouth.edu
( /)//)//)(//)/(                     chipmunk@m-net.arbornet.org
    /                                        http://www.ziplink.net/~rjk/
        It's funny 'cause it's true ... and vice versa.


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

Date: 26 Feb 1998 00:54:35 -0500
From: uri@sysarch.com
Subject: Re: Script error need help please....
Message-Id: <x7zpje29no.fsf@sysarch.com>

corey@carnivore.net (Corey) writes:

> I'm trying to add a subroutine to this script that will add city shipping tax
> if certain fields values are met..will someone tell me why this isn't working?

i am not sure whay this doesn't work since there is not data, nor di you
say what symptoms you have. on the other hand i can make many comments
on the actual code.

> sub  calculate_tax  {
> 
> $tax = 0;
> 
> $tax_total = $discount_total;

declare these with my. you obviously are not using -w or use strict if
this didn't generate errors

> 
> if (lc $taxtype eq 'none')
> 	{return 0;}
> else {  #### Calculate for the Default Tax Type
> 
> 	#### Add Tax if tax should be added for the customer's State ####
> 	if (uc $country eq 'USA') {
> 		foreach $Tax_State_Rate (@Tax_States) {

why not use a hash and get the correct tax in one statement rather than
a loop

> 			($Tax_State, $Tax_Rate) = split(/ /,$Tax_State_Rate);

also you should presplit these into the hash saving more work each time
this is called.
> 			if ($state eq $Tax_State){
> 				$tax = $sub_total * ($Tax_Rate / 100);
> 				$tax = $sub_total * ($Tax_Rate / 100);

why the double statements?
why the double statements?

> 				$tax = sprintf("%.2f", $tax);
> 				$tax_currency = &Currency($tax);
> 				$tax_total = $discount_total + $tax;	
> 	
> 				$order_total += $tax;

you sprintf $tax to make 2 decimal places. when you add it back it is
now a float. was the $sub_total in integral cents?
you shouldn't use floats for money, keep it in integer and only when
printing make 2 decimal places with:

	sprintf( "%d.%02d", $cents / 100, $cents % 100 )

> 				last;
> 			}	
> 		}
> 	}
> {
> 		
> 		foreach $Tax_City_Rate (@Tax_City) {

why not use a hash and get the correct tax in one statement rather than
a loop

> 			($Tax_City, $Tax_Rate) = split(/ /,$Tax_City_Rate);
> 			if ($city eq $Tax_city){
> 				$tax = $sub_total * ($Tax_Rate / 100);
> 				$tax = $sub_total * ($Tax_Rate / 100);

why the double statements?
why the double statements?

> 				$tax = sprintf("%.2f", $tax);

snip. all comments same as above

> }#sub
> 

hope this helps,

uri

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


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

Date: Thu, 26 Feb 1998 15:27:32 +0800
From: Gilles Chong <glchy@csah.com>
Subject: splitting with a '\' (backlash)
Message-Id: <34F51963.9B963719@csah.com>

Hi,
wondering wheth u guys have come across this peculiar prob when using
the perl function 'split' with the backlash "\".
Say $a="C:\X\Y\Z\test.doc";
@x=split(/\\/, $a);  {need the '\\' for the backlash '\'}
Executing the script will give @x= C:WindowsXY  est.doc
and there's only 1 element in the @x array ie $x[0]= C:WindowsXY
est.doc n $x[1] is null
Notice also tt the "t" in "test.doc" got swallowed up!!!
Actually i just wanna get the "test.doc" from the string. So i was
thinking of splitting the string on the '\' and popping the array. I
just need the last element of the array. $a can be 'C:\test1.doc' or
'C:\X\test2.doc' or 'C;\X\Y\test3.doc', etc. N all i need is
"test1.doc", "test2.doc", "test3.doc".

Any sol? Pls email.
Cheers

G.
--
Gilles Chong (glchy@csah.com, glchy@csa.com.sg)
Systems Engineer, Internet Division
CSA Holdings Ltd, Singapore.




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

Date: Thu, 26 Feb 1998 09:54:02 +0100
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: splitting with a '\' (backlash)
Message-Id: <34F52DAA.41C6@theo.phy.uni-bayreuth.de>

Hi,

Gilles Chong wrote:
> 
> Hi,
> wondering wheth u guys have come across this peculiar prob when using
> the perl function 'split' with the backlash "\".
> Say $a="C:\X\Y\Z\test.doc";
> @x=split(/\\/, $a);  {need the '\\' for the backlash '\'}
> Executing the script will give @x= C:WindowsXY  est.doc
> and there's only 1 element in the @x array ie $x[0]= C:WindowsXY
> est.doc n $x[1] is null
> Notice also tt the "t" in "test.doc" got swallowed up!!!

The problem is that you're using double quotes which causes characters
preceded by a backslash to be interpreted as special ones (like "\n"
standing for a "newline").

Try this:

   #!/usr/local/bin/perl -w

   $a="C:\X\Y\Z\test.doc";   ## (double quotes)
   print $a."\n";            ## note: "\t" becomes a "tab"

   $a='C:\X\Y\Z\test.doc';   ## (single quotes)
   print $a."\n";            ## looks fine now ...

   @x = split(/\\/, $a);
   print $x[-1]."\n";        ## and this works now, too ...


Bye, Eike
-- 
=======================================================================
>>--->>    Eike Grote  <eike.grote@theo.phy.uni-bayreuth.de>    <<---<<
-----------------------------------------------------------------------
 Home Page, Address, PGP,...:  http://www.phy.uni-bayreuth.de/~btpa25/
-----------------------------------------------------------------------
 PGP fingerprint:      1F F4 AB CF 1B 5F 4B 1D 75 A1 F9 C5 7B 3F 37 06
=======================================================================


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

Date: 26 Feb 1998 09:49:16 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: splitting with a '\' (backlash)
Message-Id: <slrn6faeks.v6e.Tom.Grydeland@mitra.phys.uit.no>

On Thu, 26 Feb 1998 15:27:32 +0800,
Gilles Chong <glchy@csah.com> wrote:
> Hi,
> wondering wheth u guys have come across this peculiar prob when using
> the perl function 'split' with the backlash "\".
> Say $a="C:\X\Y\Z\test.doc";

You need to say

$a = "C:\\X\\Y\\Z\\test.doc";

> Any sol? Pls email.

Please read the newsgroup.

> Gilles Chong (glchy@csah.com, glchy@csa.com.sg)

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: 26 Feb 1998 09:31:46 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: The Ineffable Tom C.
Message-Id: <slrn6fadk2.v6e.Tom.Grydeland@mitra.phys.uit.no>

On 26 Feb 1998 02:41:14 GMT,
Kenneth Herron <kherron@campus.mci.net> wrote:
> each()-like capability that only returned keys.  It seems that each()
> in a scalar context does this and has since 5.003 at least, but it
> wasn't *documented* until 5.004 (and this hypothetical later printing
> of the camel book; one of the RTFM'ers said it's in his copy),

It's in my copy; last line on p. 159.

> Kenneth Herron -- kherron@campus.mci.net

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: Thu, 26 Feb 1998 00:40:52 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: bfredett@sprynet.com
Subject: Re: Unwanted Character Displays
Message-Id: <34F50066.7A7E4C36@coos.dartmouth.edu>

[posted and mailed]

bfredett@sprynet.com wrote:
> 
> my $headline = open IN, "headline.txt" || die $!;

You need to look up operator precedence.  This line is equivalent to:

my $headline = open IN, ("headline.txt" || die $!);

You need to either add parens or use 'or' (or both):

open (IN, "headline.txt) || die $!;

open IN, "headline.txt" or die $!;

-- 
 _ / '  _      /             rjk@coos.dartmouth.edu
( /)//)//)(//)/(                     chipmunk@m-net.arbornet.org
    /                                        http://www.ziplink.net/~rjk/
        It's funny 'cause it's true ... and vice versa.


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

Date: Thu, 26 Feb 1998 11:44:34 +0200
From: Naama Kraus <naamah@haifa.vnet.ibm.com>
Subject: using a Module
Message-Id: <34F53982.763BA7CE@haifa.vnet.ibm.com>

Hi!
I have a module residing in a non standard directory. I would like to
use it in a perl
program (use MyModule). How can I teach perl to look for my module in
that directory?
Thanks in advance,
  Naama.

---> naamah@haifa.vnet.ibm.com



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

Date: Wed, 25 Feb 1998 23:03:27 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: Using strings as filehandles
Message-Id: <MPG.f5eb3977cd4211b989746@news.concentric.net>

doug@weboneinc.net said...
: Luis J. Martinez wrote:
: > Is there a way to use very large strings as files?
: Could you be any more vague?
Would that make you even more annoyed?
-- 
Jonathan Feinberg         jdf@pobox.com        Sunny Brooklyn, NY


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

Date: 26 Feb 1998 07:15:15 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Using strings as filehandles
Message-Id: <6d34q3$gac$2@marina.cinenet.net>

Douglas Clifton (doug@weboneinc.net) wrote:
: Luis J. Martinez wrote:
: > 
: > Is there a way to use very large strings as files?
: 
: Could you be any more vague?

I believe he's asking whether it is possible to open a filehandle
(old-fashioned or OO-modern) on a scalar string rather than a file, and
then do file operations on it (<> and so forth).  It's an interesting
question I think, similar in concept to (e.g.) strstreams in C++.  Has
anyone done this in Perl? 

(By the way, Luis, my apologies if I've guessed your meaning incorrectly.)

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


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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


------------------------------
End of Perl-Users Digest V8 Issue 1978
**************************************

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