[17380] in Perl-Users-Digest
Perl-Users Digest, Issue: 4802 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 3 06:05:27 2000
Date: Fri, 3 Nov 2000 03: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)
Message-Id: <973249508-v9-i4802@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 3 Nov 2000 Volume: 9 Number: 4802
Today's topics:
Re: Again problems executing Perl scripts in a shell nobull@mail.com
Re: Calling a perl script from another domain nobull@mail.com
Changing user quota at FreeBSD <s_h=t-i_r@astelit.ru>
Re: Changing user quota at FreeBSD (Abigail)
Re: Comparison - Execution of scripts (Abigail)
Re: easy data type/pointer problem (i think!) joelyhughes@my-deja.com
Re: embedded variables in a file <m.nine.six@freesurf.ch>
Re: Format Arrays ? Please assist (Garry Williams)
Getting Perl to wait for another Program sty2999@my-deja.com
hello world <nobody@nowhere.net>
Re: Need suggestions on optimization <newspost@coppit.org>
problems with perlcc on Hello World <news@#nospam#althepal.com>
Reading a backslash in a variable? (Christer)
Re: Reading a backslash in a variable? (Rafael Garcia-Suarez)
Re: Reading a backslash in a variable? (Christer)
Re: Reading a backslash in a variable? (Rafael Garcia-Suarez)
Re: Reading a backslash in a variable? (CDM)
Re: Reading a backslash in a variable? (Christer)
Re: Reading a backslash in a variable? (Rafael Garcia-Suarez)
Re: regexp-question (probably simple?) nobull@mail.com
Re: regular expression <bart.lateur@skynet.be>
Re: Removing carriage returns from cgi (Tad McClellan)
Re: script error nobull@mail.com
Re: Sort <news@#nospam#althepal.com>
Re: Unix authentication with an /etc/shadow file (Villy Kruse)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 03 Nov 2000 07:52:45 +0000
From: nobull@mail.com
Subject: Re: Again problems executing Perl scripts in a shell
Message-Id: <u9u29peble.fsf@wcl-l.bham.ac.uk>
PiLoT <spamming@teleline.es> writes:
> I put the 'x' permission to the perl and the header of the script
> contain:
> #!/usr/bin/perl
> and I've checked that perl is in that directory.
>
> I want to execute the script with
> $ ./script_name.pl
> How can I do that???
You've done everything that should normally be necessary - can you
explain how it fails?
BTW: This probably has nothing to do with Perl.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 03 Nov 2000 07:48:53 +0000
From: nobull@mail.com
Subject: Re: Calling a perl script from another domain
Message-Id: <u9vgu5ebru.fsf@wcl-l.bham.ac.uk>
"Andrew" <andrew_long@andrews-models.com.au> writes:
> Wondering whether it is possible to call a perl script in the cgi-bin from
> another domain - I've experimented but had no success so far.
The most common meanings I know of for "domain" are DNS name, and
group of SMB clients/servers sharing a single authentication database.
Neither of these meanings makes causes the above question to make any
sense.
> Reason for doing that is we have a CPU intensive script and we want to share
> the load among a number of machines
So you are looking for some sort of load-ballencing HTTP proxy (as
could be achieved with Apache+mod_proxy+mod_rewrite)? What does this
have to do with Perl? Why would you expect the load-ballencing HTTP
server cluster to care what language was used to write CGI scripts any
more than any other HTTP server?
Or asking if you could write a HTTP proxy as a CGI script in Perl?
You probably could hack together a simple one (using LWP) but it
probably wouldn't be the best approach. Indeed how to go about doing
this has been discussed in this group several times in the past - I
suggest a visit to Deja.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 03 Nov 2000 10:25:58 +0300
From: Shtirlitz <s_h=t-i_r@astelit.ru>
Subject: Changing user quota at FreeBSD
Message-Id: <gvp40t8okkl026e7sd2uctchg4i47o6gum@4ax.com>
Is there anybody who worked with user quota on FreeBSD? What method
did you use to change it?
------------------------------
Date: 3 Nov 2000 10:29:44 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Changing user quota at FreeBSD
Message-Id: <slrn9054so.qjf.abigail@tsathoggua.rlyeh.net>
On Fri, 03 Nov 2000 10:25:58 +0300, Shtirlitz (s_h=t-i_r@astelit.ru) wrote in comp.lang.perl.misc <URL: news:<gvp40t8okkl026e7sd2uctchg4i47o6gum@4ax.com>>:
++ Is there anybody who worked with user quota on FreeBSD? What method
++ did you use to change it?
And your Perl question is?
Abigail
------------------------------
Date: 3 Nov 2000 10:51:24 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Comparison - Execution of scripts
Message-Id: <slrn90565c.qjf.abigail@tsathoggua.rlyeh.net>
On Thu, 2 Nov 2000 14:47:40 -0600, David Williams (dwill@sigecom.net) wrote in comp.lang.perl.misc <URL: news:<mdkM5.224$GI4.182@newsfeed.slurp.net>>:
++ I am new to Perl, have worked with JavaScript some, VBScript some. I am
++ curious as to which scripting language provides the fastest response for the
++ user. Does anyone have a link to this information or your own opinion?
Opinion? Since when is 'fastest' subjective?
Of course, that doesn't mean your question is a valid one. Perl is typically
used on the server side, while JavaScript is enabled in some clients.
You do different stuff with it.
If speed is a real concern; don't even bother with any scripting language
C is the way to go. But more important than the langaue is the programmer.
Bad programs are inefficient is any language. Furthermore, the setup of
your webserver is very important; appropriate caching can nullify many
of the reasons a language X is qualified as "slow".
Abigail
------------------------------
Date: Fri, 03 Nov 2000 08:35:25 GMT
From: joelyhughes@my-deja.com
Subject: Re: easy data type/pointer problem (i think!)
Message-Id: <8tttcd$qmp$1@nnrp1.deja.com>
Thankyou Abe,
thats exactly the answer.
joel
In article <5uegvschd3t3pjrpehkuou07kik2a2ah45@4ax.com>,
Abe Timmerman <abe@ztreet.demon.nl> wrote:
> On Wed, 25 Oct 2000 19:30:16 GMT, joelyhughes@my-deja.com wrote:
>
> > Hi,
> > I'm sure i'm making an elementary mistake here but please can you
have
> > a look at the following code snippets
> >
> > My problem is basically this; FetchURL obviously pulls in URLS and
it
> > works fine if I place the url as a direct string parameter or
> > a 'simple' variable, but if I try to use the result of $Request-
> > >QueryString (a MS ASP call), nothing happens.
> >
> > What am I doing wrong? I'm am using ActiveState on NT
>
> You might want to look at the aspSamples that came with the AP
> distribution:
>
> \Perl\eg\aspSamples\qstring.asp
>
> --
> Good luck,
> Abe
>
> ##
> perl -Mstrict -wle 'sub Just{&$_}sub another{&$_}sub Perl{&$_}sub
hacker{&$_}$_=sub{(split /::/,(caller $^W)[3])[-$^W].$"};print@
{[Just,another,Perl,hacker]}'
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 03 Nov 2000 06:22:36 +0100
From: "m.nine.six" <m.nine.six@freesurf.ch>
Subject: Re: embedded variables in a file
Message-Id: <3A024B9C.CD443D59@freesurf.ch>
Tad McClellan wrote:
>
> [ Please do not send me any more stealth Cc'd email messages
> (or any email messages at all)
>
> Thank you.
> ]
so after you telling that i should not send you any messages at all, i
hope you will read it here.
thanks a lot for your help and also for the explanation how dangerous it
is or could be.
yes i'm not a good coder and also i don't know everything about perl and
yes i have to learn a lot of. but without communication with the other
people and discussion what i don't know and also without asking about
it, i can't learn. so i have to ask and also to fail on my opinions.
>
> On Fri, 03 Nov 2000 04:25:01 +0100, m.nine.six <m.nine.six@freesurf.ch> wrote:
> >Tad McClellan wrote:
>
> >> Never in a hundred million years should that go in the FAQ.
> >
> >ok i believe you.
> >
> >i guess also that you are a little bit excited about suggestion.
>
> No. I am appalled at the suggestion.
>
> >those are the reasons why i told it's better:
> >
> >- it's only one line of code
>
> So is a pattern match.
>
> >- i guess it's also faster than the regex matching and replacing.
> ^^^^^^^
>
> Guesses do not go in FAQs.
>
> Do some benchmarking and _know_ if it is faster.
>
> I very seriously doubt that it is faster.
>
> >- with the regex matching i can't have '$' sign in the text.
>
> Yes you can.
>
> You just put a backslash character in front of it.
>
> >if i would
> >do that the regex matching would be more complicated.
>
> If you would do what? Put in a dollar sign? Adding a backslash
> character _would_ be a very tiny bit more complicated, it's only
> one character after all.
>
> >- i also thought about the security. as far as i know this `eval
> ^^^^^^^^^^^^^^^^
>
> You have not yet thought about security enough.
>
> Go do some more of that :-)
>
> >"qq/$str/"` line doesn't execute the perlfunc and user defined functions
> >in it. so "cracker" could not even change a string or an array. (i could
> >be wrong).
>
> "could be"?. Guesses do not go in FAQs. Get a grip on reality.
>
> eval "qq/$str/"
>
> Whether or not that is dangerous depends on where the value
> of $str came from, which you have not shared with us.
>
> >> In the general case though, it may open the door for a cracker.
> >
> >more generaly you are right. it could be a very dangerous backdoor.
> >(even if i don't know how.)
> ^^^^^^^^^^
>
> People that don't know stuff do not write FAQs. People that
> know stuff write FAQs (that's why your "solution" isn't in
> there).
>
> It's nice of you to try and help, but you are not qualified
> enough yet. Learn a bit more Perl first.
>
> Since you don't know how that code could be dangerous, I'll
> show you how:
>
> -----------------
> #!/usr/bin/perl -w
> use strict;
>
> my $str = '$ARGV[ print "Kaboom!!"]';
>
> eval "qq/$str/";
> -----------------
>
> Now imagine if it was
>
> unlink <* .*>
>
> there instead of a print().
>
> Like what you see?
>
> String eval is evil. Everyday programmers should not even know
> that it exists, let alone use it.
>
> >could you tell me
> >the difference between eval {} and eval "" ??
>
> In addition to what you have doubtless already read about
> eval() in perlfunc.pod, I can add this:
>
> One of them is the kind of eval() that you can use,
> and one of them is the kind that you cannot use.
>
> :-)
>
> >in this case i wrote eval
> >"" works and eval {} does not. i would like to know why....
>
> I cannot troubleshoot imaginary code yet. Sorry.
>
> But neither form of eval() is appropriate for
>
> expanding variables in text strings
>
> (though some of the FAQ answers _do_ use eval. twice even)
>
> --
> Tad McClellan SGML consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
--
bye,
alias m.nine.six.
------------------------------
Date: Fri, 03 Nov 2000 05:17:03 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Format Arrays ? Please assist
Message-Id: <jTrM5.245$FG.17630@eagle.america.net>
On Thu, 02 Nov 2000 20:48:52 GMT, msalerno@my-deja.com
<msalerno@my-deja.com> wrote:
>but after the first line everything is indented.
>... Please let
>me know what I am missing.
>
>#!/usr/bin/perl -w
>use strict;
>{
> my @pids = `/usr/bin/ps -ef -o user -o pid -o args`;
> print "Who's processes do you want to see? ";
> chomp(my$name = <STDIN>);
> my @fin=grep(/$name/,@pids);
> print "\n@fin";
>} ^ ^
> \______\________ this is why
>The script returns:
>
>msalerno 12613 -bash
> msalerno 18501 -bash
> msalerno 18484 -bash
You are interpolating an array with qq//. Each element will be
separated from one another by $", the list separator. Its default
value is " ". Change that print statement to
{
local($") = "";
print "\n@fin";
}
Or simply
print "\n", @fin;
See the perlvar manual page.
--
Garry Williams
------------------------------
Date: Fri, 03 Nov 2000 08:28:51 GMT
From: sty2999@my-deja.com
Subject: Getting Perl to wait for another Program
Message-Id: <8ttt00$qbg$1@nnrp1.deja.com>
Hi,
I am trying to get a perl script running on Windows to interact with a
simple front end program written in VB. The VB app has to be able to
communicate with a perl script that is already running (ie. not just
launch the script).
The solution I found, that seems to work, is to just have the perl
script loop reading a value from a text file. Then the VB app front end
can write the proper value to the text file to initiate an action on
the part of the script. After completing the action, the script goes
back and loops again waiting for another input.
This works great. The only problem is that the looping perl script
consumes a lot of system resources.
Is there any way to improve upon this? If possible, I would like to
retain a similar approach to what I am using. I don't want to get into
complex areas like OLE, and I would like the solution to be portable
(not just Windows--even though currently we are using VB).
Is there some way to get the perl process to idle for a short peroid
during the loop, so it doesn't suck up all the CPU cycles? What I
would really like is something like the Windows timer, where you can
have it check every 10th of a second or so. I believe Perl has some
sort of "wait" function but I think it only works in whole
seconds...which is way to long a period.
Any help/suggestions would be greatly appreciated!
Thanks,
Steve Cramer
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 3 Nov 2000 18:35:33 +0800
From: "»´ä¸}" <nobody@nowhere.net>
Subject: hello world
Message-Id: <8tu4n5$rq4$1@taliesin.netcom.net.uk>
print "hello world"
------------------------------
Date: Fri, 3 Nov 2000 03:10:02 -0500
From: David Coppit <newspost@coppit.org>
Subject: Re: Need suggestions on optimization
Message-Id: <Pine.GSO.4.21.0011030253470.12480-100000@mamba.cs.Virginia.EDU>
On Thu, 2 Nov 2000, brian d foy wrote:
> > 4021 14.48674 14.30000 $matchesBody = ($body_buffer =~
>
> if that is taking up the most time, you might delve into
> Mastering Regular Expressions to see if you can optimize
> the regular expression. :)
Unfortunately, I already have over $100 in Perl books, and I'm a poor
graduate student who can't afford another. :( Here's the situation, in
case anyone has ideas:
sub ReadEmail
{
my $fileHandle = shift;
return undef if $READ_BUFFER eq '' && eof($fileHandle);
while (1)
{
# pos = 1 to avoid matching first email in buffer
pos($READ_BUFFER) = 1;
while ($READ_BUFFER =~ /^From\s.*\d:\d+:\d.* \d{4}/igm)
{
my $email = $`;
my $from_line = $&;
my $rest = $';
# Avoid false positives from included messages. Reverse the email before
# searching (for efficiency).
my $reversed = reverse $email;
if ($reversed !~ /^\n*[^\n]*?----- egasseM dedulcnI nigeB -----\n/i)
{
$READ_BUFFER = $from_line . $rest;
return $email;
}
}
if (eof $fileHandle)
{
my $email = $READ_BUFFER;
$READ_BUFFER = '';
return $email;
}
else
{
read($fileHandle,$block,$READ_SIZE);
$READ_BUFFER .= $block
}
}
$READ_BUFFER has an email at the beginning, and I'm trying to find the
next email (avoiding false positives resulting from headers which
follow "Begin Included Message").
If I don't find a valid match, then I need to read a chunk from the
file, append it to the $READ_BUFFER, and try again.
Some things I noticed/tried:
- reversing the email before looking for text at the end of it is much
faster
- I tried to avoid having to re-match portions of the buffer that were
already searched by setting pos = old length - 80
- I tried pre-extending the buffer when it got small in order to help
the match work on the first try.
- I tried $1,$2,$3 instead of $` $& $'
- I thought of splitting into an array to avoid $` or $1 business, but
that seems like it would add a lot more steps and therefore time
Thanks!
David
------------------------------
Date: Fri, 03 Nov 2000 09:08:18 GMT
From: Alex Hart <news@#nospam#althepal.com>
Subject: problems with perlcc on Hello World
Message-Id: <6gvM5.2561$I3.128033@typhoon1.ba-dsg.net>
I get an error when I do this:
perlcc -e 'print "Hello World"' -otmp
the error message is :
/tmp/ccJCWdsv.o(.text+0x324d): undefined reference to `boot_DynaLoader'
collect2: ld returned 1 exit status
ERROR: In compiling code for comp25312.p.c !
I've gotten perlcc to work on much more complex programs. Why the snag?
Also, what happens if the program has an eval in it? Is it dependent on
having perl on the system in that case?
Thanks in advance.
- Alex Hart
------------------------------
Date: 3 Nov 2000 08:12:53 GMT
From: chho65@hotmail.com (Christer)
Subject: Reading a backslash in a variable?
Message-Id: <8tts25$k6d$1@news.luth.se>
Hi!
I am reading a file line by line into a scalar variable and then I'm trying
to search that variable for a single backslash '\' and substitute it with a
double backslash '\\'. The 's/\\/\\\\/go' does not work since Perl doesn't
seem to read a single backslash as a token. Does anyone have a solution for
this problem?
Thanks in advance
/Christer
------------------------------
Date: Fri, 03 Nov 2000 08:22:57 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Reading a backslash in a variable?
Message-Id: <slrn904tig.pad.rgarciasuarez@rafael.kazibao.net>
Christer wrote in comp.lang.perl.misc:
>Hi!
>I am reading a file line by line into a scalar variable and then I'm trying
>to search that variable for a single backslash '\' and substitute it with a
>double backslash '\\'. The 's/\\/\\\\/go' does not work since Perl doesn't
>seem to read a single backslash as a token.
Yes it does. Example :
perl -e '$a = "a\\b"; $a =~ s/\\/\\\\/go; print "$a\n";'
prints "a\\b".
Your problem comes from another point, but without your source, it is
difficult to point it out.
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: 3 Nov 2000 09:15:48 GMT
From: chho65@hotmail.com (Christer)
Subject: Re: Reading a backslash in a variable?
Message-Id: <8ttvo4$kog$1@news.luth.se>
rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote in
<slrn904tig.pad.rgarciasuarez@rafael.kazibao.net>:
>Christer wrote in comp.lang.perl.misc:
>>Hi!
>>I am reading a file line by line into a scalar variable and then I'm
>>trying to search that variable for a single backslash '\' and
>>substitute it with a double backslash '\\'. The 's/\\/\\\\/go' does not
>>work since Perl doesn't seem to read a single backslash as a token.
>
>Yes it does. Example :
> perl -e '$a = "a\\b"; $a =~ s/\\/\\\\/go; print "$a\n";'
>prints "a\\b".
>Your problem comes from another point, but without your source, it is
>difficult to point it out.
>
My problem is like this:
perl -e '$a = "a\b"; $a =~ s/\\/\\\\/go; print "$a\n";'
Note the contents in $a. This is the way the text looks like in the file, and I
want to change it to look like "a\\b".
Regards
/Christer
------------------------------
Date: Fri, 03 Nov 2000 09:22:51 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Reading a backslash in a variable?
Message-Id: <slrn90512p.pg0.rgarciasuarez@rafael.kazibao.net>
Christer wrote in comp.lang.perl.misc:
>rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote in
><slrn904tig.pad.rgarciasuarez@rafael.kazibao.net>:
>
>>Christer wrote in comp.lang.perl.misc:
>>>Hi!
>>>I am reading a file line by line into a scalar variable and then I'm
>>>trying to search that variable for a single backslash '\' and
>>>substitute it with a double backslash '\\'. The 's/\\/\\\\/go' does not
>>>work since Perl doesn't seem to read a single backslash as a token.
>>
>>Yes it does. Example :
>> perl -e '$a = "a\\b"; $a =~ s/\\/\\\\/go; print "$a\n";'
>>prints "a\\b".
>>Your problem comes from another point, but without your source, it is
>>difficult to point it out.
>
>My problem is like this:
>perl -e '$a = "a\b"; $a =~ s/\\/\\\\/go; print "$a\n";'
^^^
$a does not contain a backslash here! it contains two chars : an "a" and
a backspace ("\b").
>Note the contents in $a. This is the way the text looks like in the file, and I
>want to change it to look like "a\\b".
Post your code!
Here is a one-liner that doubles every backslash in a file:
perl -pi.bak -e 's/\\/\\\\/g' myfile
The original file is renamed with the extension .bak (as described in
perlrun).
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
print map substr($_,7).&$_,grep defined &$_,sort values %::;
sub Just {' another '}; sub Perl {" hacker,\n"};
------------------------------
Date: Fri, 3 Nov 2000 10:32:38 +0100
From: cdemaeyer1@mmm.com (CDM)
Subject: Re: Reading a backslash in a variable?
Message-Id: <8tu0ou$hli$1@magnum.mmm.com>
if you change $a="a/b" to $a='a/b' then it works, obviously you'll then have
problems running it with -e, but why don't you put it in a script and run it
from there....
"Christer" <chho65@hotmail.com> wrote in message
news:8ttvo4$kog$1@news.luth.se...
> rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote in
> <slrn904tig.pad.rgarciasuarez@rafael.kazibao.net>:
>
> >Christer wrote in comp.lang.perl.misc:
> >>Hi!
> >>I am reading a file line by line into a scalar variable and then I'm
> >>trying to search that variable for a single backslash '\' and
> >>substitute it with a double backslash '\\'. The 's/\\/\\\\/go' does not
> >>work since Perl doesn't seem to read a single backslash as a token.
> >
> >Yes it does. Example :
> > perl -e '$a = "a\\b"; $a =~ s/\\/\\\\/go; print "$a\n";'
> >prints "a\\b".
> >Your problem comes from another point, but without your source, it is
> >difficult to point it out.
> >
>
>
> My problem is like this:
> perl -e '$a = "a\b"; $a =~ s/\\/\\\\/go; print "$a\n";'
>
> Note the contents in $a. This is the way the text looks like in the file,
and I
> want to change it to look like "a\\b".
>
> Regards
>
> /Christer
>
>
Opinions expressed herein are my own and may not represent those of my employer.
------------------------------
Date: 3 Nov 2000 10:15:53 GMT
From: chho65@hotmail.com (Christer)
Subject: Re: Reading a backslash in a variable?
Message-Id: <8tu38p$llp$1@news.luth.se>
cdemaeyer1@mmm.com (CDM) wrote in <8tu0ou$hli$1@magnum.mmm.com>:
>if you change $a="a/b" to $a='a/b' then it works, obviously you'll then
>have problems running it with -e, but why don't you put it in a script
>and run it from there....
>
Well, actually I am running the code in a script. :)
The problem seems to be that when reading a line from a file into a
variable the string will be of the type "string" and not 'string'. Is there
a way to convert a variable between the different types?
Thanks
/Christer
------------------------------
Date: Fri, 03 Nov 2000 10:38:06 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Reading a backslash in a variable?
Message-Id: <slrn9055fs.ps2.rgarciasuarez@rafael.kazibao.net>
Christer wrote in comp.lang.perl.misc:
>cdemaeyer1@mmm.com (CDM) wrote in <8tu0ou$hli$1@magnum.mmm.com>:
>
>>if you change $a="a/b" to $a='a/b' then it works, obviously you'll then
>>have problems running it with -e, but why don't you put it in a script
>>and run it from there....
>>
>Well, actually I am running the code in a script. :)
>The problem seems to be that when reading a line from a file into a
>variable the string will be of the type "string" and not 'string'. Is there
>a way to convert a variable between the different types?
No : the following program outputs 'a/b', as expected.
#!/usr/bin/perl
print <DATA>;
__DATA__
a/b
No backslash interpolation is done when reading from a file. I keep
saying your problem comes from another point.
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: 03 Nov 2000 07:45:55 +0000
From: nobull@mail.com
Subject: Re: regexp-question (probably simple?)
Message-Id: <u9zojhebws.fsf@wcl-l.bham.ac.uk>
Felix Drüke <fd@orga.com> writes:
> for (@list) { print "$_\n" if /^(?!line2)/ }
Matches any string that doesn't start with the characters "line2".
> for (@list) { print "$_\n" if /(?!xline3)/ }
Matches any string at all. Well actually matches any string in which
there is any charater position where the next 6 characters are not
"xline3". Since it is always possible to find such a position in any
string then this matches any string.
> What would be the best method to NOT match something without
> saying "if !/bla/" ?
/^(?!.*bla)/
Of course saying !/bla/ is still a _much_ better method. Can you
explain why you don't want to say !/bla/?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 03 Nov 2000 11:00:17 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: regular expression
Message-Id: <m0650tkk4kb0cg4mcuppl5nk2vgli3ustn@4ax.com>
Larry Rosler wrote:
>
>> $re = '\\d+';
>> /($re)/o
>>
>> is pretty much the same as
>>
>> /(\d+)/
>
>Yes, it is. But your example doesn't require that the backslash be
>doubled.
It doesn't. But I wannted a simple example on what you type into a
string needs not always *look* like what you'd type directly into a
regex. But the *string* that results, should *be* what you'd type in.
That, my example clearly demosntrates, I hope.
A more tricky example: suppose you want a regex to look for a backslash.
In argeex, you'd double it:
/\\/
But in a string, you're in trouble, because a backslash is
thequoting/escaping character:
$re = '\\\\';
/$re/o
An interesting twist is that you might use q// to make entering the
string more like a regex:
$re = q/\d+'/;
Heh, you don't even need to escape the single quote. You do need to
escape the slash:
$re = q/\d+\/\d+/;
$_ = ' 1 3/4"';
print /($re)/?"Found: $1\n":"Nothing found\n";
-->
Found: 3/4
Which is exactly the situation as with a normal regex between slashes.
But backslashes may still bite you:
$re = q/\\/;
/$re/;
-->
/\/: trailing \ in regexp at test.pl line 3.
So you still need to double literal backslashes.
$re = q/\\\\/;
' \\\\\\\\\\ ' =~ /($re)/ and print "Found: $1\n";
-->
Found: \
So you need to enter four backslashes to find just one. Backslashitis at
it's worst.
--
Bart.
------------------------------
Date: Thu, 2 Nov 2000 23:18:17 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Removing carriage returns from cgi
Message-Id: <slrn904f49.18a.tadmc@magna.metronet.com>
On Fri, 03 Nov 2000 03:37:55 GMT, Ameen Dausha <ameen@dausha.net> wrote:
>The answer is:
>
>$mailingaddress =~ s/\r//sg;
That is "an answer", but hardly a "good answer".
The s///s option is a red herring to distract maintenance programmers.
The s/// option only affects the dot character, and is therefore
useless if there is no dot character in the pattern.
s/// is for strings or patterns.
tr/// is for characters.
This is a "character problem".
And tr///d is lots faster than s///g is.
>The \r is the carriage return, part of the MS-DOS newline group
>(\n\r).
Errr, I believe that is incorrect as well. DOS line endings are
marked by \r\n.
>"perldoc perlr" I believe is what gives you the manpage on Regex.
... and I think there is something wrong there too.
[snip Jeopardy quoted text, which should have been enough of
a clue to disregard the "answers" given.
]
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 03 Nov 2000 07:48:08 +0000
From: nobull@mail.com
Subject: Re: script error
Message-Id: <u9wvelebt3.fsf@wcl-l.bham.ac.uk>
"munch" <ksiddall@attcanada.net> writes:
> I am using a search script from http://www.kscripts.com and running into
> errors.
> What am I doing wrong this time?
Posting to a comp.lang group (i.e. a programming group) to talk about
problems in a programs that you are simply wanting download and use
rather than programs you are actually writing/debugging.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 03 Nov 2000 09:03:27 GMT
From: Alex Hart <news@#nospam#althepal.com>
Subject: Re: Sort
Message-Id: <zbvM5.2560$I3.130559@typhoon1.ba-dsg.net>
Use
foreach $key (sort {$a <=> $b}keys %DB){
This compares each key numerically.
- Alex Hart
jtjohnston wrote:
> I'm using this to sort the lines in a db file. The problem is each line
> begins with a number.
>
> When the number is below 10, it sorts like this:
>
> 1 asdasd
> 10 asdasd
> 2 asdasda
> 3 wsfdsdfs
>
> etc
>
> I would like to sort so that it would come out like:
>
> 1 asdasd
> 2 asdasda
> 3 wsfdsdfs
> 10 asdasd
>
> What do I have to do differently?
>
> Thanks,
>
> John
>
> ---------snip----------
>
> foreach $key (sort keys %DB){
> ($db_contact_name, $db_email, $db_title, $db_url, $db_desc,
> $db_keywords, $db_hits, $db_flag, $db_date, $db_time)
> = split (/\t/, $DB{$key});
>
> #...etc here I print html code
> }
------------------------------
Date: 3 Nov 2000 08:16:37 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Unix authentication with an /etc/shadow file
Message-Id: <slrn904t35.lf1.vek@pharmnl.ohout.pharmapartners.nl>
On 2 Nov 2000 07:25:14 -0000, Jonathan Stowe <gellyfish@gellyfish.com> wrote:
>On Wed, 1 Nov 2000 13:28:24 -0500 Che Gonzalez wrote:
>> WIthout using the Authen module is there any way to authenticate a user in
>> BSD | Linux that uses a /etc/shadow file. Also, no greping or reading
>> /etc/shadow. Any alternatives?
>>
>
>There are no alternatives to reading the file, how else would you determine
>the contents? You might not explicitly do so but something must.
>
Mayby some tricks with the "su user" and some "expect" magic to hand
the password to the su command when it asks for it might work. If
the password is OK then the su command would be successfull, otherwise
not.
Villy
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4802
**************************************