Hello all,
I have to remove elements from an array if they match a particualr
string and put it into another array
eg if element matches index or default I want it to be in a new array
I am trying this
my @arr = qw( 01.html index.html aa.html bb.html cc.html dd.html );
# the following does
Rob Dixon wrote:
>
> Once more my apologies. I was in a rush this morning and shouldn't have
> posted in haste. Thanks to John I now understand the question :-/ FWIW my
> solution is the same as John's but I put a subroutine around the tr//:
>
> sub SwapUL { (my $s = shift) =~ tr/A-Za-z/a-zA-
Below is a perlscript to do approximately what you asked. I found it
somewhere else on the web. Unfortunately I do not remember where, and I
have seen several similar. It is pretty basic anyway.
I have a database application that outputs pay stubs to a text file. I
then use another script to conv
Hi Dan,
That is a very good question. It is quite possible to write Perl in a clear, readable
manner. For all the fun the guys are having with the concept, it really akes sense
only with a single statement, or a set of statements that is very tightly bound
logically. A good test for whether
Thanks. That will be useful. ;:-)
Joseph
"Beau E. Cox" wrote:
> Yes:
>
> seek HANDLE, 0, 0;
>
> Resets the file pointer to the beginning.
>
> Aloha => Beau.
>
> -Original Message-
> From: Paul Kraus [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 02, 2003 4:37 AM
> To: Perl
> Subje
ActivePerl is free.
http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl
Or you can brave the world of Cygwin. http://www.cygwin.com , but then
you would be diving into Perl and Unix at the same time, all within the
"safe" confines of Windows.
http://danconia.org
John Taf
Hi Rob,
It's been awhile since my DOS days, but I believe ANSI.sys usually was loaded by
default. You usually would have to make a small bartch file to set things like screen
colors and such, though.
Joseph
Rob Dixon wrote:
> If your terminal supports ANSI escape sequences (and I think that,
Hi Beau,
It wouldn't work on DOS either. This does:
#!/usr/bin/perl
use strict;
use warnings;
system("cls");
Joseph
"Beau E. Cox" wrote:
> Well ...
>
> Nothing in Programming Perl
> Perl Cookbook pointed me to CPAN, and I found
> Term::Cap and Term::Screen
>
> This works on Linux:
>
> #!/usr/b
but i am looking for free software. Does any body know where I can download
one for my windows 98
- Original Message -
From: "Kegs" <[EMAIL PROTECTED]>
To: "John Tafasi" <[EMAIL PROTECTED]>
Cc: "Perlbeginners" <[EMAIL PROTECTED]>
Sent: Thursday, January 02, 2003 1:59 PM
Subject: Re: Brand n
Whoops, thanx 4 correction Jenda. I thought perl2exe was from Active...
either way I have used it and found it to be pritty good, although not
always perfict.
Mark
- Original Message -
From: "Jenda Krynicky" <[EMAIL PROTECTED]>
To: "perl" <[EMAIL PROTECTED]>
Sent: Thursday, January 02, 200
From: "Derek Brinson" <[EMAIL PROTECTED]>
> I have a PERL installed on a WinIIS box. This script queries a (SQL)
> database, makes a few minor manipulations to that data, then builds a
> small paragraph of text, from there.
>
> So, how do I send that text info to an e-mail address (gathered from
>
From: Mark Goland <[EMAIL PROTECTED]>
> Active has something called perl2exe
ActiveState has something called PerlApp. It's part of the PDK (Perl
Development Kit). http://www.activestate.com/Products/Perl_Dev_Kit/
perl2exe is from IndigoStar http://www.indigostar.com/
Neither is free.
Jenda
==
From: "Meidling, Keith, CTR, OSD-C3I" <[EMAIL PROTECTED]>
> Hello everyone. I need to be able to find out if a service is logged
> in a user. I have found in the Win32::Lanman where I can change who
> the service loggs in as and the password.
>
> What I would like to do is go through a list of se
> "Paul" == Paul Kraus <[EMAIL PROTECTED]> writes:
Paul> use a hash for many reasons. Speed the best.
Paul> your main statement would be
Paul> %hash{$variable}++;
No it wouldn't. Unless you're coding in Perl6 already. :)
Maybe you meant $hash{$variable}++;
--
Randal L. Schwartz - Stonehe
Active has something called perl2exe
- Original Message -
From: "LRMK" <[EMAIL PROTECTED]>
To: "K Clark" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, January 01, 2003 1:16 PM
Subject: Re: Name a Free PERL Campiler for Win2k
> Yes I Mean to Creat Binary .EXEs
> not
I have a PERL installed on a WinIIS box. This script queries a (SQL)
database, makes a few minor manipulations to that data,
then builds a small paragraph of text, from there.So, how do I send
that text info to an e-mail address (gathered from that same database)? How
about several e-ddresse
UNCLASSIFIED
Hello everyone. I need to be able to find out if a service is logged in a
user. I have found in the Win32::Lanman where I can change who the service
loggs in as and the password.
What I would like to do is go through a list of servers and the services on
each server and see what ser
On Jan 2, Paul Kraus said:
>I don't think your solution will work.
>Since the count being taken is going to be sparadic.
>
>somelements only = 1 at the BOF but by EOF it equals 4. Since you tested
>per line your results will be bad because at test time for that line
>somelement only = 1 when actua
Or $file_data{$id}++;
Like someone else said!
Duh sorry, brain dead
Dan
-Original Message-
From: Dan Muey
Sent: Thursday, January 02, 2003 4:13 PM
To: Ray Seals; Perl
Subject: RE: Use a hash or multi dimensional array?
%file_data = ();
# open file
@lines = ;
# close file
foreach $li
%file_data = ();
# open file
@lines = ;
# close file
foreach $line(@lines) {
$line =~ s/\n|\r//g;
($id, $ct) = split(/,/, $line);
if($id =~ m/^\w\w$/) {
$ct++;
$file_data{$id} = $ct;
}
$id = '';
$ct = '';
}
Dan
--
Use a hash with the two digit code as key and then add to the hash.
(untested)
#!perl -w
my %MyHash = ();
my @MyWorka = ();
open(MYDATAIN,">" . 'datafilenamehere') || die "Unable to open file:
$!";
while ( ) {
@MyWorka = split(/,/
use a hash for many reasons. Speed the best.
your main statement would be
%hash{$variable}++;
have $variable = the two digitcode read from the file.
This statements will make create an a new element if it doesn't exist
and it will set the count to 1. Since it would be normally created as
undef o
DISCLAIMER: I'm new to programming other than a little bit of scripting
for cron jobs.
I'm parsing a comma delimited file for a specific 2 letter code on each
line in the file. Once I find that 2 letter code I want to increment a
count value and store it.
I've thought about putting it into a 2
Kegs, John
ASPN Perl is a professional tool that you have to pay for. It includes
Komodo and the Dev Kit - very nice but very expensive. If you have no budget
then you want just ActivePerl from here:
http://www.activestate.com/Products/ActivePerl/
Click on 'Download' at the top left to fetch
On Thu, 2003-01-02 at 20:41, John Tafasi wrote:
> Hi group,
>
> I am quite new to perl. I will use "Learning Perl, 3rd edition" and my laptop that
>is running windows 98.
Is that the O'Reilly book with the Llama on the cover? If so that is one
of the best books for starting Perl with IMHO.
> W
Hi group,
I am quite new to perl. I will use "Learning Perl, 3rd edition" and my laptop that is
running windows 98.
What exactly the name of the file i should download to install perl into win98? Where
can I download it?
Any other recommended tutorials for beginners
Thanks
Jensen Kenneth B Sra Afpc/Dpdmpq wrote:
> Can else statements be added?
>
> print (hi), $somevar++ if( condition ) else print (bye);
good idea but it doens't work that way. try:
#!/usr/bin/perl -w
use strict;
my $var = 1;
$var ? ( print("hello world\n"),
$var++,
print("
Paul Kraus wrote:
> so foreach dumps the entire file into memory before iterating over the
> lines. Good to know. Thanks.
>
> I don't think your solution will work.
> Since the count being taken is going to be sparadic.
>
> somelements only = 1 at the BOF but by EOF it equals 4. Since you tested
"Tanton Gibbs" <[EMAIL PROTECTED]> wrote in message
010501c2b292$2ff54e10$[EMAIL PROTECTED]">news:010501c2b292$2ff54e10$[EMAIL PROTECTED]...
> also:
> print (hi), $somevar++ if( condition );
Yes, but you have to be careful with parentheses as
print "hi", $somevar++ if condition;
is the same
cool , makes sense, just wondering
-Original Message-
From: Jensen Kenneth B SrA AFPC/DPDMPQ [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 02, 2003 1:29 PM
To: Dan Muey; [EMAIL PROTECTED]
Subject: RE: One liner If statements
No specific reason why, was just exploring other ways to
No specific reason why, was just exploring other ways to do the same thing.
Messing around with the benchmark module and seeing which ways of doing
things are actually faster. Before reading this list, I had never seen
statements like that without the brackets.
-Original Message-
From: Dan
Is there a specific reason you need to do it that way?
If you need to run a bunch of code why not use sub routines
if($hi eq $low) { &hi_is_low; }
else { &hi_is_not_low; }
What's wrong with using brackets?
if($hi eq $low) {
print "hi";
$so
On Thu, Jan 02, 2003 at 12:56:46PM -0600, Jensen Kenneth B SrA AFPC/DPDMPQ wrote:
> In reading messages on this list I've picked up some snippets like
>
> 'do some code here' if (condition);
>
> Can the same be done if you have an if statement like this
>
> If (condition){
> print "hi";
> $s
Can else statements be added?
print (hi), $somevar++ if( condition ) else print (bye);
-Original Message-
From: Tanton Gibbs [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 02, 2003 1:07 PM
To: [EMAIL PROTECTED]
Subject: Re: One liner If statements
also:
print (hi), $somevar++ if( co
also:
print (hi), $somevar++ if( condition );
- Original Message -
From: "Rob Dixon" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, January 02, 2003 1:04 PM
Subject: Re: One liner If statements
> do {
> print "hi";
> $somevar++;
> } if condition;
>
> (
do {
print "hi";
$somevar++;
} if condition;
(You don't need to parenthesize the conditional expression in this format.)
HTH,
Rob
"Jensen Kenneth B Sra Afpc/Dpdmpq" <[EMAIL PROTECTED]> wrote in
message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> In reading messages on
In reading messages on this list I've picked up some snippets like
'do some code here' if (condition);
Can the same be done if you have an if statement like this
If (condition){
print "hi";
$somevar++;
}
Or can you only have 1 command preceding the if?
I tried
Print "hi" $somevar++ if (co
From: "Pavle Lukic" <[EMAIL PROTECTED]>
> what is perl XS in relation
> to perl: extension, subset,
> or something else?
> Is it possible every perl code
> to 'convert' into perl XS, and how?
> I am asking for a generic working concept.
From
perldoc perlxs
XS is an interface descripti
May I be finicky? Nothing wrong with your code Jeff, but I prefer:
while () {
chomp;
s/ +//g;
my ($value, $field) = split /,/;
if ( $dup{field}++ ) { delete $vend{$field} }
else { $vend{$field} = $value };
}
Thank you :oD
Rob
"Jeff 'Japhy' Pinyan"
If your terminal supports ANSI escape sequences (and I think that, in
general, Unix terminals do but Windows has to have the ansi.sys driver
loaded) you can do:
my $clear = "\e[2J";
print $clear;
HTH,
Rob
"Jensen Kenneth B Sra Afpc/Dpdmpq" <[EMAIL PROTECTED]> wrote in
message
[EMAIL PRO
Something about 'red rags' and 'bulls' comes to mind ... :)
/R
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
I have resolved this now, see inline for comments and description. Thanks for your
help Jim and others, looks like stepping away from the problem and the code probably
helped me the most, but your thoughts were definitely appreciated.
On Thu, 2 J
Hi, erm, "Admin-Stress / meerkapot"
There is a Win32::SerialPort module here:
http://search.cpan.org/author/BBIRTH/Win32-SerialPort-0.19/lib/Win32/SerialP
ort.pm
but there my knowledge ends!
Let us know what you find...
Rob
"Admin-Stress" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED
Hi John
See in-line
"John W. Krahn" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Rob Dixon wrote:
> >
> > "John W. Krahn" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > Prasad K M wrote:
> > > >
> > > > I want to
Once more my apologies. I was in a rush this morning and shouldn't have
posted in haste. Thanks to John I now understand the question :-/ FWIW my
solution is the same as John's but I put a subroutine around the tr//:
sub SwapUL { (my $s = shift) =~ tr/A-Za-z/a-zA-Z/; $s; };
my $text = 'aa
so foreach dumps the entire file into memory before iterating over the
lines. Good to know. Thanks.
I don't think your solution will work.
Since the count being taken is going to be sparadic.
somelements only = 1 at the BOF but by EOF it equals 4. Since you tested
per line your results will be ba
Or REALLY silly:
(sleep 1 && print "\n") for (1..100);
Aloha => Beau.
PS: Been up all night getting a project ready -
I;m getting 'punchy' - going to bed...
-Original Message-
From: Jensen Kenneth B SrA AFPC/DPDMPQ
[mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 02, 2003 4:26 AM
Is this too messy for you?
print "\n" for (1..100);
(at lease it's portable!)
Aloha => Beau.
-Original Message-
From: Jensen Kenneth B SrA AFPC/DPDMPQ
[mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 02, 2003 4:26 AM
To: '[EMAIL PROTECTED]'
Subject: Clear command in perl?
Is the
On Jan 2, Paul Kraus said:
>As you can see I am building a hash on the first pass. Then on the
>second pass I am building a second hash but I am checking the first hash
>to see if it had a count greater then two. I don't see any other way to
>do this except two passes through the file. Correct me
That was partial code. Here is the completed script. At least the
pertinent portion.
As you can see I am building a hash on the first pass. Then on the
second pass I am building a second hash but I am checking the first hash
to see if it had a count greater then two. I don't see any other way to
d
On Jan 2, Paul Kraus said:
>I want to read through a file and the read through it again. However the
>only way it seems to work for me is if I open the file, Read the file,
WHY do you want to read the file twice? Is there some way you can do two
things at once?
>foreach (){
> chomp;
> @temp=s
Well ...
Nothing in Programming Perl
Perl Cookbook pointed me to CPAN, and I found
Term::Cap and Term::Screen
This works on Linux:
#!/usr/bin/perl
use strict;
use warnings;
require Term::Screen;
my $scr = new Term::Screen;
unless ($scr) { die " Something's wrong \n"; }
$scr->clrscr();
Yes:
seek HANDLE, 0, 0;
Resets the file pointer to the beginning.
Aloha => Beau.
-Original Message-
From: Paul Kraus [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 02, 2003 4:37 AM
To: Perl
Subject: Restarting at top of file
I want to read through a file and the read through it ag
Mostly for portability. Also just like to stray away from using system
commands when at all possible.
-Original Message-
From: Beau E. Cox [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 02, 2003 8:35 AM
To: Jensen Kenneth B SrA AFPC/DPDMPQ; [EMAIL PROTECTED]
Subject: RE: Clear command
I want to read through a file and the read through it again. However the
only way it seems to work for me is if I open the file, Read the file,
Close the file, and the reopen it. Is there a way to do this with out
having to run the open command twice?
Does not work
--
open PEL, "vend.c
Hi -
Yes: system ("clear");
:)
I don't really know, but what is wrong with
the 'system' approach? The overhead should
be minimal since 'clear' is embedded in the
shell. Are you worried about portability?
system ($^O =~ /win32/i ? 'cls' : 'clear');
(tested OK Win 2000 and Linux)
Aloha => Beau.
>
> > > I am making a call to gpg on the command line, a couple of
> > > the parameters that gpg will accept are file descriptor
> > > numbers that it then writes to, and I would like to capture
> > > that output and then read from it.
> > >
> > > I have successfully made it read directly from a f
Is there a perl command equivalent to:
system ("clear");
?
Thanks,
Ken
Hi,
Anyone know which perl module can be used for COM Port communication?
I have a device that need to be accessed via COM1 for example. It can be tested using
HyperTerminal in Windows.
If connected, it will give 'a prompt' then I need to type 'some commands' and the
device will
return somethin
Alas the latest windows version of Emacs does not have the cperl-db the
only thing it has is cperl-mode. Is there a way I can add the feature?
> -Original Message-
> From: Kieren Diment [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 31, 2002 11:05 PM
> To: Paul Kraus
> Cc: [EMAIL PR
NAME
beginners-faq - FAQ for the beginners mailing list
1 - Administriva
1.1 - I'm not subscribed - how do I subscribe?
Send mail to <[EMAIL PROTECTED]>
You can also specify your subscription email address by sending email to
(assuming [EMAIL PROTECTED] is your email address):
Hi to all
what is perl XS in relation
to perl: extension, subset,
or something else?
Is it possible every perl code
to 'convert' into perl XS, and how?
I am asking for a generic working concept.
Thanks
Pavle
_
Protect your PC -
Tim Martin wrote:
>
> I have run into a small problem with the script we have been working on for
> log management.
> Problem 1 - The script must be in the same sub directory as all the logs.
What makes you think that it must?
> How can I get the script to run from /var/tmp/gatelog a
On Thu, Jan 02, 2003 at 02:32:34AM -0800, John W. Krahn wrote:
> Rob Dixon wrote:
> >
> > "John W. Krahn" <[EMAIL PROTECTED]> wrote in message
> > > $ perl -le'$_ = "This Is A Mixed Case Sentence."; tr/a-zA-Z/A-Za-z/;
> > > print'
> > > tHIS iS a mIXED cASE sENTENCE.
> >
> > Hmm. Sometimes there
On Thu, 2 Jan 2003, John W. Krahn wrote:
> Rob Dixon wrote:
> >
> > "John W. Krahn" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > Prasad K M wrote:
> > > >
> > > > I want to read a file and print all the text , but reverse the case.
> > > > So all sma
Jess Balint wrote:
>
> Thank you for the advice.
>
> > > open( STATES, "sort $hotline |" )
> > > or cust_die( "Cannot open files to get states
> > > ($hotline,$newtofile,$newmover): $!\n" );
> >
> > What does the $hotline variable contain? Is there any reason
> > to use an external sort
Prasad K M wrote:
>
> From: "John W. Krahn" <[EMAIL PROTECTED]>
>
> > Prasad K M wrote:
> > >
> > > I want to read a file and print all the text , but reverse the case.
> > > So all small will become CAPS and CAPS will be small .
> > > The problem is toggling the case. Any idea as how to accompli
Rob Dixon wrote:
>
> "John W. Krahn" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Prasad K M wrote:
> > >
> > > I want to read a file and print all the text , but reverse the case.
> > > So all small will become CAPS and CAPS will be small .
> > > The pro
Ah, my apologies.
To apply the translation explicitly to a variable, do:
$var =~ tr/a-zA-Z/A-Za-z/;
but if no variable is specified, then $_ is used implicitly. Also, if you
specify the name of the input file on the command line you can simply write:
while (<>)
{
tr/a-zA-Z/A
thanks...
i am trying to search a pattern and replace that pattern with its toggled
version...
eg: s/pattern//g
the prob is i can't embed 'tr/a-zA-Z/A-Za-z/' in the part or
atleast i dont know how to do it !!
--prasad
- Original Message -
From: "John W. Krahn" <[EMAIL PROTECTED]>
To:
Hmm. Sometimes there's only one way to do it :)
/R
"John W. Krahn" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Prasad K M wrote:
> >
> > Hi,
>
> Hello,
>
> > I want to read a file and print all the text , but reverse the case.
> >
> > So all small will bec
Assuming we're not using unicode here,
tr/A-Za-z/a-zA-Z/
Cheers,
Rob
"Prasad K M" <[EMAIL PROTECTED]> wrote in message
013101c2b23b$68b45ae0$[EMAIL PROTECTED]">news:013101c2b23b$68b45ae0$[EMAIL PROTECTED]...
Hi,
I want to read a file and print all the text , but reverse the case.
So all s
Prasad K M wrote:
>
> Hi,
Hello,
> I want to read a file and print all the text , but reverse the case.
>
> So all small will become CAPS and CAPS will be small .
>
> The problem is toggling the case. Any idea as how to accomplish it ?
$ perl -le'$_ = "This Is A Mixed Case Sentence."; tr/a-zA
Hi,
I want to read a file and print all the text , but reverse the case.
So all small will become CAPS and CAPS will be small .
The problem is toggling the case. Any idea as how to accomplish it ?
Thanks in advance
--prasad
Hi,
If I get the concept of globbing properly, I have been able to prevent it in Unix by
quoting my parameter list. I'm not sure how this works for spaces, but it helps a lot
with CGI stuff. When I do this, I use an test for STDIN, and if its not preloaded,
take @ARGV from the command-line as
75 matches
Mail list logo