I think you need to start reading on a few books my friend.
here are a few places to start:
read the regexp tutorial i wrote at http://japh.nu
read "perldoc perlre" for more details
look into getting "learning perl" by randal schwartz, it will teach you many
of the basics you'll need for Perl
n
t;[EMAIL PROTECTED]>
To: "Tyler Longren" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, July 18, 2001 2:25 PM
Subject: Re: looking at rows in text files
> using 'my' within the while loop will make it lose it's value once the
loop
> exi
using 'my' within the while loop will make it lose it's value once the loop
exits and it will be reset every time you read in a new line
declare 'my @list' above the loop, and you'll not have that problem.
for readabillity, use:
if(/(\S+/){ push @list, $1 }
altho that's a bit superfluous i think,
t print anything to the screen.
Really, thank you!
- Original Message -
From: "Jos I. Boumans" <[EMAIL PROTECTED]>
To: "Tyler Longren" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, July 18, 2001 1:29 PM
Subject: Re: looking at row
it's essentially the same thing, only instead of handing the match to the
print operator, we store it in @list
like so:
open(FP, "$tempfile"); # Open $tempfile for reading
while() { push @list, /(\S+)/ }
$list[0] will hold the first match, $list[1] the 2nd and so forth
hope this helps,
Jos
>
If your file really looks like that and you're really only
trying to print the first column just:
cut -d' ' -f1 < your.file
from the command prompt.
or if you want the dns server name instead:
tr -s '[:blank:]' '\t' < cu.txt | cut -f2
-will
Tyler Longren wrote:
>
> Hello everyone,
>
> I h
a short way:
open I, "file.txt" or die $!;
while () { print /(\S+)/ }
hope this helps,
Jos Boumans
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
gt;
>An: "Perl Beginners" <[EMAIL PROTECTED]>
>Betreff: looking at rows in text files
>Datum: Mit, 18. Jul 2001 15:43 Uhr
>
> Hello everyone,
>
> I have a file that contains a few domain names, and their dns servers (kind
> of like a zonefile). Here's the
How about:
use strict;
open(IN, "file.txt") || die("RRRGGGHHH $!");
while() # loop through file setting each line to $_
{
chomp; # lose newline
/^([^\s]+)\s/; # look for anything at the beginning of the string
up to the first space or tab character and remembe
Hello everyone,
I have a file that contains a few domain names, and their dns servers (kind
of like a zonefile). Here's the format:
my.comdns1.blah.com
me.comdns1.blah.com
we.comdns1.blah.com
you.com dns1.blah.com
How can I get ONLY the domain's out of that file, and print each do
10 matches
Mail list logo