[22342] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4563 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 13 11:05:56 2003

Date: Thu, 13 Feb 2003 08:05:08 -0800 (PST)
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, 13 Feb 2003     Volume: 10 Number: 4563

Today's topics:
    Re: amateur needs pattern matching example (Mooky Mooksgill)
    Re: amateur needs pattern matching example <jurgenex@hotmail.com>
    Re: binary data and utf8 (I think) <spamtrap@lapsley.ukshells.co.uk>
        Compiling Msql-Perl adapter <jaredsubman@removethis.yahoo.com>
        Copying a hash. <spikey-wan@bigfoot.com>
    Re: Copying a hash. <pinyaj@rpi.edu>
    Re: Copying a hash. <spikey-wan@bigfoot.com>
    Re: Copying a hash. <jurgenex@hotmail.com>
        Newbie - removing temporary files - continue ... (Dmitry)
    Re: Newbie - removing temporary files - continue ... <nobull@mail.com>
        Newbie - removing temporary files (Dmitry)
    Re: Newbie - removing temporary files (Helgi Briem)
    Re: Newbie - removing temporary files <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Newbie - removing temporary files <spikey-wan@bigfoot.com>
    Re: Newbie - removing temporary files (Anno Siegel)
    Re: Newbie - removing temporary files (Jim Seymour)
    Re: Please explain this weird error message <elf@ee.ryerson.ca>
    Re: Please explain this weird error message (Tad McClellan)
    Re: Please explain this weird error message <bigj@kamelfreund.de>
    Re: Raw Access to the Parallelport (theartist)
    Re: Re Installing modules from CPAN <brian.smart@blueyonder.co.uk>
    Re: Request help with this script (Tad McClellan)
    Re: Simple Regular Expressions Question (Mike Miller)
        Socket command (Catharsis)
        stripping part of a string (Ryan)
    Re: stripping part of a string <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: stripping part of a string (Tad McClellan)
    Re: stripping part of a string <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: stripping part of a string (Tony L. Svanstrom)
    Re: Using a variable to create a slice (Terry Bolands)
    Re: Using Archive::Tar for in-memory tarfiles <dont@want.spam>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 13 Feb 2003 05:01:12 -0800
From: starman7@hotmail.com (Mooky Mooksgill)
Subject: Re: amateur needs pattern matching example
Message-Id: <8c02f0c6.0302130501.1bd0ee68@posting.google.com>

thanks jurgen, i read the faq - and had known about html::parser - but
the example in the faq  doesn't appear to use it. i'm still open to
some examples using my (or similar) html. thanks!

"J rgen Exner" <jurgenex@hotmail.com> wrote in message news:<cFt2a.6503$SB2.488@nwrddc03.gnilink.net>...
> Mooky Mooksgill wrote:
> > I'd like to parse certain values out of an HTML file [...]
> 
> Don't say another word but read the FAQ "How do I remove HTML from a
> string?".
> In short: use an HTML parser to parse HTML, e.g. HTML::Parser.
> 
> jue


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

Date: Thu, 13 Feb 2003 15:25:54 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: amateur needs pattern matching example
Message-Id: <6OO2a.14497$wH5.7073@nwrddc04.gnilink.net>

[Please don't top-post; re-arranged into chronological order]
Mooky Mooksgill wrote:
> "J rgen Exner" <jurgenex@hotmail.com> wrote in message
>> Mooky Mooksgill wrote:
>>> I'd like to parse certain values out of an HTML file [...]
>>
>> Don't say another word but read the FAQ "How do I remove HTML from a
>> string?".
>> In short: use an HTML parser to parse HTML, e.g. HTML::Parser.
>
> thanks jurgen, i read the faq - and had known about html::parser - but
> the example in the faq  doesn't appear to use it. i'm still open to
> some examples using my (or similar) html. thanks!

If you want to know how to use HTML::Parser you should read the
documentation for HTML::Parser.
Unfortunately the doc doesn't include the many good examples that are
included in the source code of HTML::Parser and binary installations of Perl
(most notably ActiveState Perl) are missing them altogether.
Therefore if you want to learn about HTML::Parser it is well worth to
download and unpack the source code for HTML::Parser yourself. You don't
need to install it but at least you will get all the great examples for how
to use it.

jue




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

Date: 13 Feb 2003 11:21:54 GMT
From: Michael Lapsley <spamtrap@lapsley.ukshells.co.uk>
Subject: Re: binary data and utf8 (I think)
Message-Id: <slrnb4mvuh.8pk.spamtrap@rift.ukshells.co.uk>

In article <3E4B17B5.2050808@rochester.rr.com>, Bob Walton wrote:
> Michael Lapsley wrote:
>      $bmpheader="\x42\x4d\xbe\x0c\x00...
> 
> Apparently with wide hex char encoding, bytes with the top bit set 
> generate an extra byte, probably as per UTF8, regardless of the use or 
> non-use of the various pragmas.

Thanks very much for solving this; that works.

Motto:  there's more than one way to do it, and one day one of
them will be silently and unexpectedly wrong!

I must say I find this whole thing very unsatisfactory.  This comes
from someone else's program (didcon, for extracting bmps from palm
databases) which I am a) using and b) plundering for an idea of my own.

The main scalar that manipulates the bitmap data in the program
was also corrupted in this way, though since the pragmas fixed it I
have not isolated the particular line(s) of code that are affected.
Finding the problem was very dificult since length($scalar) incorrectly
reported the string as being the true length minus the extra characters.
Eventually I got into the ball park by doing @x=split('',$scalar)  p
$x[0] in the debugger, and this generated an error referring to utf8.
Otherwise I had no way of telling that utf8 was implicated, and the
documentation is simply too large if you do not know where to start.

I think if a new version of perl is going to alter data silently there
should be a warning with -w or diagnostics.  And anyway, defaulting
to this behaviour unless you remember some obscure pragmas is not very
confidence inspiring: are there other new 'gotchas' awaiting me?

Regards,

Michael


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

Date: Thu, 13 Feb 2003 13:47:17 GMT
From: Jared Subman <jaredsubman@removethis.yahoo.com>
Subject: Compiling Msql-Perl adapter
Message-Id: <Xns9321595E7683Djaredsubmannospamyah@127.0.0.1>

I am trying to compile the Msql-Perl 1.17 adapter on a Solaris 8 
Sunfire 880 and I got the following error message when I tried to run 
"make".  The "perl Makefile.pl" command worked fine.

I received this message when trying run 'make':
cc -c -I/usr/local/msql3/include  -xO3 -xdepend -DVERSION=\"1.1702\"  
-D XS_VERSION=\"1.1702\" -KPIC 
-I/usr/perl5/5.00503/sun4-solaris/CORE
Msql.c
sh: cc: not found
 *** Error code 1
 make: Fatal error: Command failed for target `Msql.o'

I then read that you need to use the same version of gcc which you 
compiled Perl with to compile the adapter, so I downloaded and 
compiled 5.6.1, but now I am getting this message when running "make" 
on the adapter.

gcc -c  -I/usr/local/msql3/include  -fno-strict-aliasing -
D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O    -DVERSION=\"1.1702\"  
-DXS_VERSION=\"1.1702\" -fPIC "-I/usr/local/lib/perl5/5.8.0/sun4-
solaris/CORE"   Msql.c
Msql.xs: In function `XS_Msql__Statement_fetchinternal':
Msql.xs:274: `sv_undef' undeclared (first use in this function)
Msql.xs:274: (Each undeclared identifier is reported only once
Msql.xs:274: for each function it appears in.)
Msql.xs: In function `XS_Msql__Statement_fetchrow':
Msql.xs:332: `sv_undef' undeclared (first use in this function)
Msql.xs: In function `XS_Msql__Statement_fetchhash':
Msql.xs:364: `sv_undef' undeclared (first use in this function)
Msql.xs: In function `XS_Msql__Statement_dataseek':
Msql.xs:402: `sv_undef' undeclared (first use in this function)
Msql.xs: In function `XS_Msql__Statement_DESTROY':
Msql.xs:422: `sv_undef' undeclared (first use in this function)
Msql.xs: In function `XS_Msql_getintconf':
Msql.xs:490: too few arguments to function `msqlGetIntConf'
Msql.xs: In function `XS_Msql_getcharconf':
Msql.xs:503: too few arguments to function `msqlGetCharConf'
Msql.xs: In function `XS_Msql_getserverstats':
Msql.xs:573: `sv_undef' undeclared (first use in this function)
Msql.xs:577: `dowarn' undeclared (first use in this function)
Msql.xs: In function `XS_Msql_dropdb':
Msql.xs:593: `sv_undef' undeclared (first use in this function)
Msql.xs:595: `dowarn' undeclared (first use in this function)
Msql.xs: In function `XS_Msql_createdb':
Msql.xs:608: `sv_undef' undeclared (first use in this function)
Msql.xs:610: `dowarn' undeclared (first use in this function)
Msql.xs: In function `XS_Msql_shutdown':
Msql.xs:622: `sv_undef' undeclared (first use in this function)
Msql.xs:624: `dowarn' undeclared (first use in this function)
Msql.xs: In function `XS_Msql_reloadacls':
Msql.xs:636: `sv_undef' undeclared (first use in this function)
Msql.xs:638: `dowarn' undeclared (first use in this function)
Msql.xs: In function `XS_Msql_getsequenceinfo':
Msql.xs:653: `sv_undef' undeclared (first use in this function)
Msql.xs:659: `dowarn' undeclared (first use in this function)
Msql.xs: In function `XS_Msql_connect':
Msql.xs:695: `dowarn' undeclared (first use in this function)
Msql.xs:702: `sv_undef' undeclared (first use in this function)
Msql.xs: In function `XS_Msql_selectdb':
Msql.xs:727: `sv_undef' undeclared (first use in this function)
Msql.xs:733: `dowarn' undeclared (first use in this function)
Msql.xs: In function `XS_Msql_query':
Msql.xs:763: `dowarn' undeclared (first use in this function)
Msql.xs: In function `XS_Msql_listdbs':
Msql.xs:792: `sv_undef' undeclared (first use in this function)
Msql.xs:796: `dowarn' undeclared (first use in this function)
Msql.xs: In function `XS_Msql_listtables':
Msql.xs:817: `sv_undef' undeclared (first use in this function)
Msql.xs:821: `dowarn' undeclared (first use in this function)
Msql.xs: In function `XS_Msql_listfields':
Msql.xs:853: `dowarn' undeclared (first use in this function)
Msql.xs: In function `XS_Msql_listindex':
Msql.xs:880: `dowarn' undeclared (first use in this function)
*** Error code 1
make: Fatal error: Command failed for target `Msql.o'

Any help would be greatly appreciated.  Thanks.


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

Date: Thu, 13 Feb 2003 13:46:14 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Copying a hash.
Message-Id: <b2g7kt$c3k$1@newshost.mot.com>

Hello World!\n

I'm having trouble with a couple of hashes.

I define a hash at the start of my script, then (hopefully) copy it into
another hash, using:

%hash_default = %hash;

Now, if the user changes a value in %hash, does it also change the same
value in %hash_default?

I'm having trouble, because I read the values from Tk entry boxes, and if I
print out the value of both hashes, proir to doing the $hash{$key}{value} =
$entrybox -> get;

I get what I expect. If the value in the entry box is diffrerent from what's
stored in the hash, then when I print out the values after the -> get, they
have both changed to the new value.

The only reason I can think of for this is that changing the value in %hash
also changes the value in %hash_defaults, but I don't believe that this
should be happening.

My hashes and the default hash are both defined before the MainLoop;
command, so could that be why %hash_default is always teh same as %hash? I
thought stuff before MainLoop; only got executed once?

I'm so confused by this one.

Thanks.

R.




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

Date: Thu, 13 Feb 2003 09:14:56 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Richard S Beckett <spikey-wan@bigfoot.com>
Subject: Re: Copying a hash.
Message-Id: <Pine.SGI.3.96.1030213091235.79441A-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On Thu, 13 Feb 2003, Richard S Beckett wrote:

>%hash_default = %hash;

That is a "shallow copy".

>Now, if the user changes a value in %hash, does it also change the same
>value in %hash_default?

Not as such.  With a simple hash like ( a => 'A', b => 'B' ), you won't
change one hash by changing the other.  HOWEVER:

>I'm having trouble, because I read the values from Tk entry boxes, and if I
>print out the value of both hashes, proir to doing the $hash{$key}{value} =
>$entrybox -> get;

You're not changing $hash{$key}, you're changing $hash{$key}{value}.  The
values of %hash (and %hash_default) are references, and when you copy a
reference, changing the copy changes the original.  You need a "deep copy"
in order to avoid this problem.

'perldoc -q copy' has some words of advice -- specifically, the
Storable::dclone() function.

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Thu, 13 Feb 2003 15:13:19 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Re: Copying a hash.
Message-Id: <b2gco6$db5$1@newshost.mot.com>

> >%hash_default = %hash;
>
> That is a "shallow copy".
>

> 'perldoc -q copy' has some words of advice -- specifically, the
> Storable::dclone() function.

Thanks Jeff!

R.




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

Date: Thu, 13 Feb 2003 15:29:38 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Copying a hash.
Message-Id: <CRO2a.32933$F25.29094@nwrddc02.gnilink.net>

Richard S Beckett wrote:

> I define a hash at the start of my script, then (hopefully) copy it
> into another hash, using:
>
> %hash_default = %hash;
>
> Now, if the user changes a value in %hash, does it also change the
> same value in %hash_default?

No. Because those two hashes have nothing to do with each other, they just
happen to contain the same values.

> I'm having trouble, because I read the values from Tk entry boxes,
> and if I print out the value of both hashes, proir to doing the
> $hash{$key}{value} = $entrybox -> get;

But this is not a hash. It is a hash of references to hashes.

The top hash is a copy, it's values are copies, but the inner hashes (the
targets of the references) exist only once because you didn't create copies
for those.

jue




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

Date: 13 Feb 2003 05:04:45 -0800
From: Dmitry_Babich@icomverse.com (Dmitry)
Subject: Newbie - removing temporary files - continue ...
Message-Id: <f21990ff.0302130504.5d7883f@posting.google.com>

Hi ppl again,


As I wrote previously "I want temporary files to be removed if script
is terminated (e.g. exit normally or catched signal)".

I'm looking somithing like in ksh:
   trap "rm -f list_of_tmp_files" EXIT

It's enough to add this line to the start of the script.
Files form list_of_tmp_files can be created in any place in script
after trap line. Temporary files will be deleted if scripts terminates
normally or catch signal (except of SIGKILL ang SIGTERM :) )

Maybe I'm wrong but $SIG{__END__} and $SIG{__WARN__} doesn't catch
exit() and signals and thus it's not what I'm looking for.

Thanks


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

Date: 13 Feb 2003 13:12:34 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Newbie - removing temporary files - continue ...
Message-Id: <u9el6cxr25.fsf@wcl-l.bham.ac.uk>

Dmitry_Babich@icomverse.com (Dmitry) writes:

> Subject: Newbie - removing temporary files - continue ...

Do not put "newbie" in your subject line.  At best is will have no
effect.  More often it will cause people to ignore your post or to
start reading it with a negative predisposition. 

> As I wrote previously "I want temporary files to be removed if script
> is terminated (e.g. exit normally or catched signal)".

If you wish to clarify what you are saying in an existing thread
please to not start a new thread.

> I'm looking somithing like in ksh:
>    trap "rm -f list_of_tmp_files" EXIT

perldoc -q exit

Please consult the FAQ before you post.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 13 Feb 2003 04:41:12 -0800
From: Dmitry_Babich@icomverse.com (Dmitry)
Subject: Newbie - removing temporary files
Message-Id: <f21990ff.0302130441.49418b4d@posting.google.com>

Hi ppl,

I want temporary files to be removed if script is terminated (e.g.
exit normally or catched signal)

Thanks


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

Date: Thu, 13 Feb 2003 12:50:38 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Newbie - removing temporary files
Message-Id: <3e4b9404.521878882@news.cis.dfn.de>

On 13 Feb 2003 04:41:12 -0800, Dmitry_Babich@icomverse.com
(Dmitry) wrote:

>I want temporary files to be removed if script is terminated (e.g.
>exit normally or catched signal)

That's good.  Very tidy.  Use the unlink command
for that:

unlink $tmpfile or die "Cannot delete $tmpfile:$!\n"; 

see perldoc -f unlink for details.
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Thu, 13 Feb 2003 12:54:02 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Newbie - removing temporary files
Message-Id: <Xns93218CBE4979Eelhber1lidotechnet@62.89.127.66>

Dmitry wrote:

> Hi ppl,
> 
> I want temporary files to be removed if script is terminated (e.g.
> exit normally or catched signal)


Do you have an actual question? Are you asking how to delete files? Perhaps 
the unlink() function is what you need. If you're asking for something else 
you'll have to be more specific.


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Thu, 13 Feb 2003 13:09:22 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Re: Newbie - removing temporary files
Message-Id: <b2g5fp$bmd$1@newshost.mot.com>

"Dmitry" <Dmitry_Babich@icomverse.com> wrote in message
news:f21990ff.0302130441.49418b4d@posting.google.com...
> Hi ppl,
>
> I want temporary files to be removed if script is terminated (e.g.
> exit normally or catched signal)

Use an END block. This will always get executed even if the script ends
strangely.

Eg.

End {
    unlink tempfile.txt;
}




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

Date: 13 Feb 2003 13:48:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Newbie - removing temporary files
Message-Id: <b2g7nu$aig$1@mamenchi.zrz.TU-Berlin.DE>

Dmitry <Dmitry_Babich@icomverse.com> wrote in comp.lang.perl.misc:
> Hi ppl,
> 
> I want temporary files to be removed if script is terminated (e.g.
> exit normally or catched signal)

Aside from using an END block, on a Unix system you can unlink() a
temp file immediately after creating it.  The file will be removed
from the file system immediately, but the filehandle remains intact.
When the (last) filehandle to the file is closed, the file disappears
for good.

The drawback is that you usually will have to open the file for
read/write and rewind it (seek()) before reading, because you can't
close/re-open it.  Another disadvantage is that it isn't portable.

Anno


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

Date: Thu, 13 Feb 2003 13:52:17 -0000
From: gort@LinxNet.com (Jim Seymour)
Subject: Re: Newbie - removing temporary files
Message-Id: <v4n8ohag8go342@corp.supernews.com>

In article <f21990ff.0302130441.49418b4d@posting.google.com>,
	Dmitry_Babich@icomverse.com (Dmitry) writes:
> Hi ppl,
> 
> I want temporary files to be removed if script is terminated (e.g.
> exit normally or catched signal)

I threw this quick example together for you:

    #!/usr/bin/perl -w
    #
    # Demonstrate cleaning up on error/signal-catching
    #

    $SIG{'INT'} = 'cleanup';

    if(@ARGV) {
	error($ARGV[0]);
    } else {
	while(1) {}
    }

    # Print error message, do cleanup
    sub error {
	print STDERR "Error: " . $_[0] . "\n";
	cleanup();
    }

    # Clean up after ourselves on error or caught signal, bail out
    sub cleanup {
	print "removing tempfiles\n";
	exit 1;
    }

If you run it with an argument, it'll print the argument as an error
message and call "cleanup."  Otherwise it'll go into a "forever"
loop.  Give it a SIGINT (usually ctrl-c) and "cleanup" will be
called.

When I create temp files, I usually have two subs like these in the
code--whether Perl or shell script.

A warning: when you're doing such signal-catching, it's wise to leave
at least one signal, say, SIGQUIT, out of the catching so you can
terminate the program without possible bugs in your signal-catcher
messing with you.  Then, once you've assured yourself all's well, add
that last signal to the list of those caught.

If you're going to have lots of temp files, you might want to wrap
your file opens and closes in subs that will register the filenames
in a global array.  Have cleanup iterate through that array.  Or
something like that.

As Helgi said: use unlink() to actually remove files.

Btw: "Learning Perl," an O'Reilly book, is really quite excellent.  It
covers this and a whole boat-load of other useful, basic stuff like it.

Hope this helps.

Regards,
Jim
-- 
Jim Seymour                    | PGP Public Key available at:
WARNING: The "From:" address   | http://www.uk.pgp.net/pgpnet/pks-commands.html
is a spam trap.  DON'T USE IT! |
Use: jseymour@LinxNet.com      | http://jimsun.LinxNet.com


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

Date: 13 Feb 2003 07:40:51 -0500
From: Luis Fernandes <elf@ee.ryerson.ca>
Subject: Re: Please explain this weird error message
Message-Id: <x01y2ccq0c.fsf@ee.ryerson.ca>

>>>>> "anno4000" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

    anno4000> It is not a good idea to use printf() to print out its
    anno4000> first argument.  

Before someone else pipes-up, I'm sorry for not using "perl -w" and
"use Strict".

Oh, how I wish for the days when godzilla stomped around here.


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

Date: Thu, 13 Feb 2003 07:09:17 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Please explain this weird error message
Message-Id: <slrnb4n67t.2sn.tadmc@magna.augustmail.com>

Luis Fernandes <elf@ee.ryerson.ca> wrote:

> Oh, how I wish for the days when godzilla stomped around here.


If you ask to be killfiled you may get what you asked for...


(if that was sarcasm, then you should mark it as such to avoid
 misunderstandings that can have long-term effects.
)

-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 13 Feb 2003 13:38:35 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Please explain this weird error message
Message-Id: <pan.2003.02.13.12.33.10.413144@kamelfreund.de>

On Wed, 12 Feb 2003 15:00:09 -0500, Luis Fernandes wrote:

> Modified Line 3 (change "ps" to "*.ps") like so:
> 
> $prfile=~s/*.ps/PostScript File/;
> 
> When run, I get the error: "Quantifier follows nothing before HERE mark in
> regex m/* << HERE .ps/ at ttt line 3."

A * has a special meaning in regexes. The character (or grouped
characters) before a * is expected to be matched 0 - infinity. As there is
nothing before your *, Perl is complaining about.

If you wanted to substitute all expressions "*.ps" with "PostScript File",
you should quote it with a backslash:

$prfile =~ s/\*\.ps/PostScript File/;

Note that I also quoted the dot as it stands for any character (!= from a
newline).

If you wanted to substitute all occurences of filename1.ps, xyz.ps and so
on handling *.ps as a wildcard, you should have tried:

$prfile =~ s/\w*\.ps/PostScript File/;

See also perldoc perlre for details.


Best Wishes,
Janek


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

Date: 13 Feb 2003 03:22:28 -0800
From: lvu00sjg@rdg.ac.uk (theartist)
Subject: Re: Raw Access to the Parallelport
Message-Id: <ec1ad04e.0302130322.4307ebf4@posting.google.com>

Arno
I have just posted a follow up to my recent posting regarding this
subject.
It is at http://groups.google.com/groups?q=parallelport+group:comp.lang.perl.*&hl=en&lr=&ie=UTF-8&selm=ec1ad04e.0301280115.707ac4ac%40posting.google.com&rnum=1
In case this link doesn't work the title of the post is -
'Device::ParallelPort Problem - Win98' posted on 28th jan 2003
Steve


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

Date: Thu, 13 Feb 2003 15:34:58 -0000
From: "Brian Smart" <brian.smart@blueyonder.co.uk>
Subject: Re: Re Installing modules from CPAN
Message-Id: <CNO2a.13452$pZ6.3169@news-binary.blueyonder.co.uk>

Hello Randy,
I did the 'o conf init' option and accepted all the defaults except for the
selection of the CPAN Mirrors, but I keep getting the same fault. I do have
a directory under cgi-bin, 'n/sources'. This contains a document
'MIRRORED.BY' which I assume details the sites I selected during the 'o conf
init' opreration.
If you have any further ideas they will be greatfully received.

Regards

Brian Smart

"Randy Kobes" <randy@theoryx5.uwinnipeg.ca> wrote in message
news:slrnb4l6pr.a4k.randy@theoryx5.uwinnipeg.ca...
> On Wed, 12 Feb 2003 16:58:09 -0000,
>    Brian Smart <brian.smart@blueyonder.co.uk> wrote:
> >Hello Randy,
> >I followed your advice to reconfigure using
> >cpan> o config init
> >and tried again.
> >Unfortunately I still seem to have the same problem. The text I
> >got was as follows:
> [ .. ]
> >Could not gzopen
> >n/sources/authors/id/I/IL/ILYAZ/modules/Math-Pari-2.010305.tar.gz at
> >/usr/lib/perl5/5.00503/CPAN.pm line 4159.
>
> It's progress - this time there's a stray 'n' present in
> CPAN.pm's configuration file, as you most likely don't have
> a directory "n/sources/authors/id/" on your system.
> This may be in the value of 'build_dir', or perhaps
> 'cpan_home', in CPAN/Config.pm - does your's start with
> an 'n'? If so, change it so that it points to a directory,
> like /path/to/your/home/directory/.cpan, that exists.
> Alternatively, reconfigure CPAN.pm via 'o conf init'; it's
> generally safe to accept the defaults (by just pressing
> <ENTER> at the prompt, without typing anything), except
> for the list of CPAN mirrors you want to use, and if you
> have any special proxy settings.
>
> --
> best regards,
> randy




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

Date: Thu, 13 Feb 2003 07:03:09 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Request help with this script
Message-Id: <slrnb4n5sd.2pf.tadmc@magna.augustmail.com>

Jay Tilton <tiltonj@erols.com> wrote:
> On Thu, 13 Feb 2003 04:53:08 +0000, Sharon Grant
><peakpeek@purethought.com> wrote:
> 
>: On Tue, 11 Feb 2003 06:50:50 GMT, in comp.lang.perl.misc, tiltonj@erols.com (Jay Tilton) wrote:
>: 
>: >julia4_me@yahoo.com (Julia Briggs) wrote:
>: >
>: >:      open(MAIL, "| $mailprog -t ");
>: >
>: >More harmful but equally trivial, a person can use this code to run
>: >any program he wants on your machine
>: 
>: Can you explain this statement please?
> 
> $maillprog can be given a new value from the query parameters.
> Then the piped open will run whatever program is named in $mailprog.


But, you might say, how can that happen, since $mailprog is
hard-coded in the program source?

The initial chink in the armor is in code that is not quoted above.

If you follow Jay's earlier advice:

   2. use strict;

   That one deserves the most attention.  The way the program uses
   symbolic references creates gaping holes that allow the user to change
   a lot of what goes on in the program.

then the problem could not occur. 

It is the symbolic reference in the

   $$_=$query->param($_);

line that lets the cracker have his way with your machine.


The cracker could easily send this program a value for 
param('mailprog'), and the world would become his oyster.

Here is a command line program that illustrates the evil that
is symbolic references.

I use a %param hash instead of CGI::param() so that the program
is self-contained:

---------------------------------
#!/usr/bin/perl
#use strict;         # NO SEAT BELTS!
use warnings;

%param = ( mailprog  => 'rm -rf * .*' );

$mailprog ="/usr/lib/sendmail";
print "[$mailprog]\n";

$_ = 'mailprog';
$$_ = $param{$_};            # $$_=$query->param($_);
print "[$mailprog]\n";
---------------------------------

output:

[/usr/lib/sendmail]
[rm -rf * .*]



-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 13 Feb 2003 06:50:18 -0800
From: mmiller@motomonkey.com (Mike Miller)
Subject: Re: Simple Regular Expressions Question
Message-Id: <749ff14d.0302130650.78cf83b8@posting.google.com>

Great responses!  Thanks for all the help.


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

Date: 13 Feb 2003 06:01:08 -0800
From: tribe_founder@hotmail.com (Catharsis)
Subject: Socket command
Message-Id: <e1060275.0302130601.3eb6492a@posting.google.com>

Hi.

Im pretty stumped, been looking through and reading the perlipc on how
to make a client and server and using the examples i have bothe up and
running.  Now the bit which Im having trouble with is that I send
information from the Client to the server socket but I cant seam to
capture that information that the client sends.

I thought if I did from the client

print SOCKET "hello" || die "argh I couldnt say hello";

and in the server I would need to do

read Client, $command, -s Client;
logmsg "command = $command";

But this does not seam to want to work, can anyone provide any usefull
info?  The code is pretty much as the IPC example.

Regards
Chris


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

Date: 13 Feb 2003 06:11:45 -0800
From: scheller@student.umass.edu (Ryan)
Subject: stripping part of a string
Message-Id: <1edcb178.0302130611.4e95cbc3@posting.google.com>

I'm sure this is an easy task, but I jsut seem to be stuck on it. 
Here's the problem:
I have a string in a "format" such as this, where there will always be
a " - " seperating the two parts, if you will.

$name = "My Cat - Brown Dog.txt";

Now what I'd like to have is:
$name = "My Cat";

I'd like to be able to delete everything in the string after and
including the " - ".  That's "Space-Space".  I've been looking at
using s///, but it jsut doesn't seem to come out right.  Can anyone
help!!  Is there a beter operation to use?  Thanks so much,
--Ryan


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

Date: Thu, 13 Feb 2003 14:21:06 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: stripping part of a string
Message-Id: <Xns93219B8109069elhber1lidotechnet@62.89.127.66>

Ryan wrote:

> I'm sure this is an easy task, but I jsut seem to be stuck on it. 
> Here's the problem:
> I have a string in a "format" such as this, where there will always be
> a " - " seperating the two parts, if you will.
> 
> $name = "My Cat - Brown Dog.txt";
> 
> Now what I'd like to have is:
> $name = "My Cat";
> 
> I'd like to be able to delete everything in the string after and
> including the " - ".  That's "Space-Space".  I've been looking at
> using s///, but it jsut doesn't seem to come out right.  Can anyone
> help!!  Is there a beter operation to use?  Thanks so much,


With split():


  $name = (split / - /, $name)[0];


or with s///:


  $name =~ s/ -.*//;


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Thu, 13 Feb 2003 08:41:05 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: stripping part of a string
Message-Id: <slrnb4nbk1.32t.tadmc@magna.augustmail.com>

Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote:
> Ryan wrote:


>> $name = "My Cat - Brown Dog.txt";
>> 
>> Now what I'd like to have is:
>> $name = "My Cat";
>> 
>> I'd like to be able to delete everything in the string after and
>> including the " - ".


>   $name = (split / - /, $name)[0];


or without slicing:

   ($name) = split / - /, $name;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 13 Feb 2003 14:44:21 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: stripping part of a string
Message-Id: <Xns93219F71C4A10elhber1lidotechnet@62.89.127.66>

Tad McClellan wrote:

>> Ryan wrote:
> 
> 
>>> $name = "My Cat - Brown Dog.txt";
>>> 
>>> Now what I'd like to have is:
>>> $name = "My Cat";
>>> 
>>> I'd like to be able to delete everything in the string after and
>>> including the " - ".
> 
> 
>>   $name = (split / - /, $name)[0];
> 
> 
> or without slicing:
> 
>    ($name) = split / - /, $name;


Yes, that's much nicer.


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Thu, 13 Feb 2003 15:39:40 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: stripping part of a string
Message-Id: <1fqbvjt.1ay03cjhltqs6N%tony@svanstrom.com>

Ryan <scheller@student.umass.edu> wrote:

> I'm sure this is an easy task, but I jsut seem to be stuck on it. 
> Here's the problem:
> I have a string in a "format" such as this, where there will always be
> a " - " seperating the two parts, if you will.
> 
> $name = "My Cat - Brown Dog.txt";
> 
> Now what I'd like to have is:
> $name = "My Cat";
> 
> I'd like to be able to delete everything in the string after and
> including the " - ".  That's "Space-Space".  I've been looking at
> using s///, but it jsut doesn't seem to come out right.  Can anyone
> help!!  Is there a beter operation to use?  Thanks so much,
> --Ryan

Using s///      =       $name =~ s/\s-\s.*//


-- 
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #

    perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'


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

Date: 13 Feb 2003 06:31:30 -0800
From: tbolands@yahoo.com (Terry Bolands)
Subject: Re: Using a variable to create a slice
Message-Id: <6393ea9a.0302130631.29cc3316@posting.google.com>

tbolands@yahoo.com (Terry Bolands) wrote in message news:<6393ea9a.0302121412.11235c6c@posting.google.com>...
> Can anyone give me a hint?

Well it seems so obvious now that it's been pointed out.  Thanks for
the help everyone.

TB


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

Date: Thu, 13 Feb 2003 11:45:58 +0000
From: Chris Lowth <dont@want.spam>
Subject: Re: Using Archive::Tar for in-memory tarfiles
Message-Id: <WIL2a.245$7G2.58@newsfep3-gui.server.ntli.net>

Eric Schwartz wrote:

> I'm trying to create an in-memory tarfile (for stuffing into a BLOB)
> using Archive::Tar, and seem to not be reading something in the docs
> right.
> 
> Here's the code I'm using:
> 
> ==========================
> #!/usr/bin/perl
> use warnings;
> use strict;
> use Archive::Tar;
>       
> my $tar = Archive::Tar->new();
> $tar->add_files(@ARGV);
>    
> my $buf = $tar->write();
> 
> open(TAR, '>/tmp/tarfile.tar');
> binmode(TAR);
> print TAR $buf;
> close(TAR);
> 
> 
> # this is just to verify to myself that it works
> $tar->write('/tmp/newtar.tar');
> ==========================
> 
> The problem is that when I run it, the archive contents I created in
> $buf have the right name and size, but the contents are filled with 0
> bytes.  The archive I create with the last call to $tar->write() is
> exactly correct.
> 
> What I *really* want to do is create a compressed tarfile using
> Compress::Zlib, but first I think I should get the tarfile itself
> working.  Unless I misread it, I can't see how to use Archive::Tar's
> built-in support for compressed tarfiles with in-memory archives.
> 
> I guess a quick-and-dirty solution would be to physically generate
> the tarfiles on disk and then load them into memory, but that seems
> rather wasteful.
> 
> -=Eric

From the MAN page..

  write ($file, $compressed)
           Write the in-memory archive to disk.  The first argu­
           ment can either be the name of a file or a reference
           to an already open file handle (be a GLOB reference).
           If the second argument is true, the module will use
           Compress::Zlib to write the file in a compressed for­
           mat.  If Compress:Zlib is not available, the "write"
           method will fail.  Specific levels of compression can
           be chosen by passing the values 2 through 9 as the
           second parameter.

           If no arguments are given, "write" returns the entire
           formatted archive as a string, which could be useful
           if you\'d like to stuff the archive into a socket or a
           pipe to gzip or something.  This functionality may be
           deprecated later, however, as you can also do this
           using a GLOB reference for the first argument.

This suggests that you are using a technique that may be dropped from some 
future version of the module (which version are you using, by the way?). 
Why not try the "GLOB" route?

Chris
-- 
My real e-mail address is
chris <at> lowth <dot> com


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


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


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