[comp.lang.perl] $/

frech@mwraaa.army.mil (Norman R. Frech CPLS) (09/08/90)

I am working on a mailbox conversion routine and would like to use
^A^A^A^A\n^A^A^A^A\n as $/, slurp the whole file and process each message
as $_.  The problem is when I set $/ it only takes the first ^A as the 
record seperator (this is what the manual also indicates should happen).
Is there a way to overide this convention and specify $/ to longer than
one character?  

Norm Frech < frech@mwraaa.army.mil >

merlyn@iwarp.intel.com (Randal Schwartz) (09/08/90)

In article <1990Sep7.170029.16710@uvaarpa.Virginia.EDU>, frech@mwraaa (Norman R. Frech CPLS) writes:
| I am working on a mailbox conversion routine and would like to use
| ^A^A^A^A\n^A^A^A^A\n as $/, slurp the whole file and process each message
| as $_.  The problem is when I set $/ it only takes the first ^A as the 
| record seperator (this is what the manual also indicates should happen).
| Is there a way to overide this convention and specify $/ to longer than
| one character?  

As it says in the forthcoming book (somewhere :-), $/ takes only one
character.  To get a whole thing, try something like:

@messages = split(/\001\001\001\n\001\001\001\n/, join("",<MESSAGEFILE>));

for (@messages) {
	# $_ is now a single message
}

Note that this requires that you have at least twice the core as your
largest expected mail message file (for a short period of time,
anyway).  If you don't, you're gonna have to eat a line at a time, and
look for the split yourself.

print "Just another Perl [book] hacker,"
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/