Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract problem

Status
Not open for further replies.

PerlElvir

Technical User
Aug 23, 2005
68

Hi all ;)

How I can extract to first "?" if I have two "?"

example:

$var= I have ? and I woild like ? finish this;

so I want to from $var make 2 new so extract have to be till ?(first and seconde)

$first= I have
$seconde=I have ? and I woild like
 
Code:

if ($var =~ /((.*?)\?.*?)\?/g)
{
$first = $1;
$second = $2;
print "$second\n$first ";
}

 
hi all,

i am an absolut beginner in using perl skripts.
my problem: i want to extract lines out of a very long file (the lines are existing more than one time in the file).
i try the following methode:

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

use Getopt::Long;
GetOptions("i=s" => \$i, # --i
"o=s" => \$o); # --o

($i && $o) || die "usage: perl extract.pl --i inputfile --o outputfile";

open(FILEIN,"$i") || die "Can't open input filename : $!\n";
open(FILEOUT,">$o") || die "Can't open output filename: $!\n";

while (<FILEIN>) {
if (/**first column of beginningline**/ .. /**first column of endingline/)
}

maybe all of you can see what is going wrong.....
regards, christine (looking for help :eek:) )
 
sorry sorry sorry, its very early in the morning and i am sleeping!
this should be an new threat and no answer....it was silly to do!!!
sorry!!!
 
I think we can let you off just this once!

Code:
while (<FILEIN>) {
  if (/**first column of beginningline**/ .. /**first column of endingline/) {
    [red]print FILEOUT $_;[/red]
    }
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top